Created
March 30, 2017 13:11
-
-
Save TravisMullen/59b1ae4ccb4f4517c34db67ef4a862ab to your computer and use it in GitHub Desktop.
Making Animations Wait
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
// wait for document | |
document.body.className += " js-loading"; | |
window.addEventListener("load", removeLoadingClass, false); | |
function removeLoadingClass() { | |
document.body.className = document.body.className.replace("js-loading",""); | |
} | |
// wait for image | |
// Adjust the "querySelector" value to target your image | |
var img = document.querySelector("img"); | |
document.body.className += " js-loading"; | |
img.addEventListener("load", removeLoadingClass); | |
function removeLoadingClass() { | |
document.body.className = document.body.className.replace("js-loading",""); | |
} | |
/* | |
.js-loading *, | |
.js-loading *:before, | |
.js-loading *:after { | |
animation-play-state: paused !important; | |
} | |
*/ | |
// ref: https://css-tricks.com/making-animations-wait/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment