autoTimer
Automatically debounced timer.
Even if called if called multiple times, only the last call will be executed.
Installation
npm install autotimer
Usage
const AutoTimer = require('autotimer');
import AutoTimer from 'autotimer';
const timer = new Autotimer();
timer(delay, callback);
const timerOne = timer(delay, callback);
clearTimeout(timerOne);
function responsive() {
}
function scrolled() {
}
const respTimer = new AutoTimer();
const scrollTimer = new Autotimer();
window.addEventListener('resize', () => {
respTimer(100, responsive);
});
window.addEventListener('scroll', () => {
scrollTimer(200, scrolled);
});