Created
March 1, 2017 13:44
-
-
Save fnnzzz/e5fdc716b792bb4d62217a49fcaaae75 to your computer and use it in GitHub Desktop.
fadeOut on vanilla JS
This file contains 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
fadeOut(el) { | |
el.style.opacity = 1; | |
(function fade() { | |
if ((el.style.opacity -= 0.03) < 0) { | |
el.style.display = "none"; | |
} else { | |
requestAnimationFrame(fade); | |
} | |
})(); | |
} | |
setTimeout(() => this.fadeOut(document.querySelector('#preloader')), 1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment