| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Delay function calls until a set time elapses after the last invocation
npm install debounceimport debounce from 'debounce';
function resize() {
console.log('height', window.innerHeight);
console.log('width', window.innerWidth);
}
window.onresize = debounce(resize, 200);To check if the debounce delay is currently active:
window.onresize.isPending;To later clear the timer and cancel currently scheduled executions:
window.onresize.clear();Execute immediately only if a call is pending (and reset the timer):
window.onresize.flush();To execute immediately and reset the timer if it was previously set:
window.onresize.trigger();Creates a debounced function that delays execution until wait milliseconds have passed since its last invocation.
Set the immediate option to true to execute the function immediately at the start of the wait interval, preventing issues such as double-clicks on a button.
The returned function has the following methods:
| Back | FazBrowse Home | New Git URL |