Throttle or debounce calls to window.addEventListener(). The listener will additionally be throttled by window.requestAnimationFrame().
$ npm install --save-dev throttled-event-listener
var throttler = require('throttled-event-listener');
throttler.add(
'scroll',
1000,
function(event) {
// called a maximum of once per 1000ms
}
);
throttler.add(
'scroll',
1000,
function(event) {
// waits for a cooldown period of 1000ms between calls
}, {
debounce : true,
}
);
// Start throttle
var throttle = throttler.add(
// ...
);
// Stop throttle
throttle.end();
$ git clone ...
$ npm install
$ grunt serve
// Deployed to http://localhost:9001/