caoge c760052ff9 机车状态修改 | 8 months ago | |
---|---|---|
.. | ||
test | 8 months ago | |
.editorconfig | 8 months ago | |
.eslintrc | 8 months ago | |
.travis.yml | 8 months ago | |
LICENSE.md | 8 months ago | |
README.md | 8 months ago | |
debounce.js | 8 months ago | |
index.d.ts | 8 months ago | |
index.js | 8 months ago | |
karma.conf.js | 8 months ago | |
package.json | 8 months ago | |
throttle.js | 8 months ago |
Throttle/debounce your functions.
This module is the same as jquery-throttle-debounce (with some differences), but it’s transferred to CommonJS so it can be easily used with tools like Browserify or Webpack.
npm install throttle-debounce --save
var throttle = require('throttle-debounce/throttle');
var debounce = require('throttle-debounce/debounce');
throttle(300, function () {
// Throttled function
});
debounce(300, function () {
// Debounced function
});
Returns: Function
Throttle execution of a function. Especially useful for rate limiting execution of handlers on events like resize and scroll.
Type: Number
A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
Type: Boolean
Optional, defaults to false. If noTrailing is true, callback will only execute every delay
milliseconds while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time after the last throttled-function call. (After the throttled-function has not been called for delay
milliseconds, the internal counter is reset)
Type: Function
A function to be executed after delay milliseconds. The this
context and all arguments are passed through, as-is, to callback
when the throttled-function is executed.
Type: Boolean
If debounceMode
is true (at begin), schedule clear
to execute after delay
ms. If debounceMode
is false (at end), schedule callback
to execute after delay
ms.
Returns: Function
Debounce execution of a function. Debouncing, unlike throttling, guarantees that a function is only executed a single time, either at the very beginning of a series of calls, or at the very end.
Type: Number
A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
Type: Boolean
Optional, defaults to false. If atBegin
is false or unspecified, callback will only be executed delay
milliseconds after the last debounced-function call. If atBegin
is true, callback will be executed only at the first debounced-function call. (After the throttled-function has not been called for delay
milliseconds, the internal counter is reset).
Type: Function
A function to be executed after delay milliseconds. The this
context and all arguments are passed through, as-is, to callback
when the debounced-function is executed.
$.throttle
and $.debounce
to be availableTested in IE8+ and all modern browsers.
Original module license: Copyright (c) 2010 "Cowboy" Ben Alman (Dual licensed under the MIT and GPL licenses. http://benalman.com/about/license/)
This module license: MIT © Ivan Nikolić