Skip to content

Instantly share code, notes, and snippets.

@elfacht
Created January 5, 2022 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elfacht/f277c4f174907f82c57f4cbe0d157bad to your computer and use it in GitHub Desktop.
Save elfacht/f277c4f174907f82c57f4cbe0d157bad to your computer and use it in GitHub Desktop.
Window Resize Animation Stopper
/**
* Stop animations and transitions
* on window resize
*
* @type {Function}
*/
let resizeTimer;
window.addEventListener('resize', () => {
document.body.classList.add('resize-animation-stopper');
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => {
document.body.classList.remove('resize-animation-stopper');
}, 400);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment