Skip to content

Instantly share code, notes, and snippets.

@6eDesign
Last active December 15, 2015 04:09
Show Gist options
  • Save 6eDesign/5199580 to your computer and use it in GitHub Desktop.
Save 6eDesign/5199580 to your computer and use it in GitHub Desktop.
This delay function is neat. Useful for events which can fire repeatedly such as the window re-size. If the delay function is called again before the supplied 'ms' parameter, another timer is started (In other words: the browser only executes your window-just-changed-size function after the window has been re-sized and remained that size for a c…
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
var checkIfMobile = function() {
};
jQuery(window).resize(function() {
delay(checkIfMobile, 500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment