Skip to content

Bouncer: a Javascript plugin to throttle and debounce functions

Notifications You must be signed in to change notification settings

edwardpayton/bouncer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Bouncer

Bouncer: a Javascript plugin to throttle and debounce callbacks easily.

Installation

Install with Bower

bower install Bouncer

Or by cloning this repository.

How to use

The plugin can be used with or without jQuery.

The syntax is like so:

namespace.option(delay,callback,runBefore);
  • namespace: use $ with jQuery, use bouncer without
  • option: throttle or debounce
  • delay: number - use 0 or greater in milliseconds
  • callback: your callback function, eg an ajax call
  • runBefore: for debounce, run your callback before or after the delay

With jQuery

Use the $ namespace

$.throttle(500,callback);
$.debounce(500,callback[,true]);
$("#foo").click($.debounce(500,function() {
  // My ajax callback
});

Plain Javascript

Use the bouncer namespace

bouncer.throttle(500,callback);  
bouncer.debounce(500,callback[,true]);  
document.getElementById('foo')addEventListener('click', bouncer.debounce(500,function(){
// My ajax callback  
}),false);

About

Bouncer: a Javascript plugin to throttle and debounce functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published