Skip to content

Throttle or debounce calls to window.addEventListener(). The listener will additionally be throttled by window.requestAnimationFrame().

License

Notifications You must be signed in to change notification settings

vivmaha/throttled-event-listener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

throttled-event-listener

Throttle or debounce calls to window.addEventListener(). The listener will additionally be throttled by window.requestAnimationFrame().

Install

$ npm install --save-dev throttled-event-listener

Usage

Throttle

var throttler = require('throttled-event-listener');
throttler.add(
    'scroll',
    1000,
    function(event) {
        // called a maximum of once per 1000ms
    }
);

Debounce

throttler.add(
    'scroll',
    1000,
    function(event) {
        // waits for a cooldown period of 1000ms between calls
    }, {
        debounce : true,
    }
);

Stop throttle

// Start throttle
var throttle = throttler.add(
    // ...
);

// Stop throttle
throttle.end();

Build

$ git clone ...
$ npm install
$ grunt serve

// Deployed to http://localhost:9001/

About

Throttle or debounce calls to window.addEventListener(). The listener will additionally be throttled by window.requestAnimationFrame().

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published