Skip to content

Instantly share code, notes, and snippets.

@ziadoz ziadoz/example.js forked from anonymous/example.js
Created Feb 23, 2012

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

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
You can’t perform that action at this time.