Skip to content

Commit

Permalink
Switch from debounce to throttle so method is called at regular time (f…
Browse files Browse the repository at this point in the history
…ix #166)
  • Loading branch information
Adrien Denat committed Jul 14, 2018
1 parent 0f8ec5c commit b52e5d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/simplebar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test:e2e": "jest -c jest-e2e.config.js"
},
"dependencies": {
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"resize-observer-polyfill": "^1.5.0",
"scrollbarwidth": "^0.1.3"
},
Expand Down
6 changes: 2 additions & 4 deletions packages/simplebar/src/simplebar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import scrollbarWidth from 'scrollbarwidth';
import debounce from 'lodash.debounce';
import throttle from 'lodash.throttle';
import ResizeObserver from 'resize-observer-polyfill';

export default class SimpleBar {
Expand All @@ -25,9 +25,7 @@ export default class SimpleBar {
this.classNames = this.options.classNames;
this.offsetSize = 20;

this.recalculate = debounce(this.recalculate.bind(this), 1000, {
leading: true
});
this.recalculate = throttle(this.recalculate.bind(this), 1000);

this.init();
}
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5920,6 +5920,10 @@ lodash.templatesettings@^4.0.0:
dependencies:
lodash._reinterpolate "~3.0.0"

lodash.throttle@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"

[email protected]:
version "4.0.1"
resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c"
Expand Down

0 comments on commit b52e5d5

Please sign in to comment.