Created
August 12, 2015 00:03
-
-
Save NatalieMac/be29f6812830dba656c4 to your computer and use it in GitHub Desktop.
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 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