Skip to content

Instantly share code, notes, and snippets.

@kayluhb
Created November 29, 2011 16:35
Show Gist options
  • Save kayluhb/1405432 to your computer and use it in GitHub Desktop.
Save kayluhb/1405432 to your computer and use it in GitHub Desktop.
Throttle
// example: throttle(app.onScroll, 150)
function throttle(fn, delay) {
var timer = null;
return function() {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function() {
fn.apply(context, args);
}, delay);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment