Skip to content

Instantly share code, notes, and snippets.

Created February 21, 2012 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/1877871 to your computer and use it in GitHub Desktop.
Save anonymous/1877871 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment