Skip to content

Instantly share code, notes, and snippets.

@YasinKuralay
Created May 11, 2021 12:42
Show Gist options
  • Save YasinKuralay/8500862b31e86674b38a62e7211228b8 to your computer and use it in GitHub Desktop.
Save YasinKuralay/8500862b31e86674b38a62e7211228b8 to your computer and use it in GitHub Desktop.
Disable CSS Transitions on Window Resize
/* PREVENT TRANSITIONS ON WINDOW RESIZE
taken from https://stackoverflow.com/questions/38526764/disable-css-transitions-on-window-resize */
<script>
(function() {
const classes = document.body.classList;
let timer = 0;
window.addEventListener('resize', function () {
if (timer) {
clearTimeout(timer);
timer = null;
}
else
classes.add('stop-transitions');
timer = setTimeout(() => {
classes.remove('stop-transitions');
timer = null;
}, 100);
});
})();
</script>
body.stop-transitions * {
transition: none !important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment