Created
May 11, 2021 12:42
-
-
Save YasinKuralay/8500862b31e86674b38a62e7211228b8 to your computer and use it in GitHub Desktop.
Disable CSS Transitions on Window Resize
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body.stop-transitions * { | |
transition: none !important; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment