Skip to content

Instantly share code, notes, and snippets.

@creage
Created April 25, 2014 20:37
Show Gist options
  • Save creage/11302449 to your computer and use it in GitHub Desktop.
Save creage/11302449 to your computer and use it in GitHub Desktop.
jquery's bounced on('windowresize')
(function ($) {
// Special event definition.
$.event.special.windowresize = {
setup: function () {
$(this).ondelay('resize', { timeout: 300 }, resizeHandler);
},
teardown: function () {
$(this).off('resize', resizeHandler);
}
};
function resizeHandler(event) {
$.each([event.target, event.currentTarget], function (i, ptr) {
if ($.isWindow(ptr)) {
$(ptr).trigger('windowresize', event);
return false;
}
});
return true;
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment