Skip to content

Instantly share code, notes, and snippets.

@redpop
Forked from branneman/event.js
Last active April 4, 2021 15:44
Show Gist options
  • Select an option

  • Save redpop/40d9a5feb511c2bd5301 to your computer and use it in GitHub Desktop.

Select an option

Save redpop/40d9a5feb511c2bd5301 to your computer and use it in GitHub Desktop.
JavaScript window resize event with a 100ms delay #resize #event #window
$(function() {
let resizeEnd;
$(window).on('resize', function() {
clearTimeout(resizeEnd);
resizeEnd = setTimeout(function() {
$(window).trigger('resize-end');
}, 100);
});
// Example
$(window).on('resize-end', function() {
console.log('window resized!');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment