Created
October 28, 2013 21:42
-
-
Save yellowberri-snippets/7205364 to your computer and use it in GitHub Desktop.
JS: Resize Polling Function
This file contains 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 poll = (function(){ | |
var timer = 0; | |
return function(callback, ms){ | |
clearTimeout(timer); | |
timer = setTimeout(callback, ms); | |
}; | |
})(); | |
$(window).resize(function(){ | |
// Poll the window.resize event every 25ms for changes and fire specific code. | |
poll(function(){ | |
// Call function here. | |
}, 25); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment