Skip to content

Instantly share code, notes, and snippets.

@NatalieMac
Created August 12, 2015 00:03
Show Gist options
  • Save NatalieMac/be29f6812830dba656c4 to your computer and use it in GitHub Desktop.
Save NatalieMac/be29f6812830dba656c4 to your computer and use it in GitHub Desktop.
var resizeDelay = (function() {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = Math.random() * 100;
}
if (timers[uniqueId]) {
clearTimeout (timers[uniqueId]);
}
timers[uniqueId] = setTimeout(callback, ms);
};
})();
$(window).on('resize orientationchange', function() {
resizeDelay(function() {
name_of_function();
}, 300, 'unique_id');
}).trigger('resize');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment