Skip to content

Instantly share code, notes, and snippets.

@ericwwsun
Created June 26, 2012 20:57
Show Gist options
  • Save ericwwsun/2998950 to your computer and use it in GitHub Desktop.
Save ericwwsun/2998950 to your computer and use it in GitHub Desktop.
Javascript: Delay fire window resize handler
window.onresize = function(e) {
delay(function(){
// do something.....
}, 250);
}
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment