Last active
December 15, 2015 04:09
-
-
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…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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