Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Forked from anonymous/example.js
Created February 23, 2012 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziadoz/1895154 to your computer and use it in GitHub Desktop.
Save ziadoz/1895154 to your computer and use it in GitHub Desktop.
JQuery Resize Events
// See: http://ejohn.org/blog/learning-from-twitter/
(function($) {
$(document).ready(function() {
var resizeCallable = function() {
switch (true)
{
case (window.innerWidth <= 768):
// Do some exciting device size specific magic here.
break;
}
};
var didResize = false;
$(window).on('load resize', function() {
didResize = true;
});
setInterval(function() {
if (didResize) {
didResize = false;
resizeCallable();
}
}, 250);
});
})(jQuery);
@ziadoz
Copy link
Author

ziadoz commented Nov 1, 2012

This is probably easier to achieve using Underscore JS: http://underscorejs.org/#throttle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment