Skip to content

Instantly share code, notes, and snippets.

@navio
Last active August 29, 2015 14:20
Show Gist options
  • Save navio/8c4d50575edc2c82dd26 to your computer and use it in GitHub Desktop.
Save navio/8c4d50575edc2c82dd26 to your computer and use it in GitHub Desktop.
Debounce Example
(function(){
var debounce = function(fn,time){
var status = true;
var timer = setTimeout(updateTimer(),time);
function updateTimer(){
status = true;
}
return function(){
if(status){
fn.apply(this,params); status = false;
}else{
clearTimeout(timer);
}
};
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment