Skip to content

Instantly share code, notes, and snippets.

@dmitryshimkin
Last active January 19, 2023 00:40
Show Gist options
  • Select an option

  • Save dmitryshimkin/5691740 to your computer and use it in GitHub Desktop.

Select an option

Save dmitryshimkin/5691740 to your computer and use it in GitHub Desktop.
resizeStart and resizeEnd events for $(window)
(function () {
var THRESHOLD = 750;
var timeoutId;
var resizing = false;
var win = $(window);
win.on('resize', function () {
var timeout = function () {
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
resizing = false;
win.trigger('resizeEnd');
}, THRESHOLD);
};
if (!resizing) {
resizing = true;
win.trigger('resizeStart');
}
timeout();
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment