|
|
il y a 10 mois | |
|---|---|---|
| .. | ||
| index.d.ts | il y a 10 mois | |
| index.js | il y a 10 mois | |
| license | il y a 10 mois | |
| package.json | il y a 10 mois | |
| readme.md | il y a 10 mois | |
Debounce a function
$ npm install debounce-fn
const debounceFn = require('debounce-fn');
window.onresize = debounceFn(() => {
// Do something on window resize
}, {wait: 100});
Returns a debounced function that delays calling the input function until after wait milliseconds have elapsed since the last time the debounced function was called.
It comes with a .cancel() method to cancel any scheduled input function calls.
Type: Function
Function to debounce.
Type: object
Type: number\
Default: 0
Time to wait until the input function is called.
Type: boolean\
Default: false
Trigger the function on the leading edge of the wait interval.
For example, can be useful for preventing accidental double-clicks on a "submit" button from firing a second time.
Type: boolean\
Default: true
Trigger the function on the trailing edge of the wait interval.