Last active
May 9, 2016 15:44
-
-
Save englishextra/818ba5b558f9c15f9776684b8e8feaf9 to your computer and use it in GitHub Desktop.
FadeOut in pure 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
/*! | |
* Fade Out | |
* gist.github.com/englishextra/818ba5b558f9c15f9776684b8e8feaf9 | |
* youmightnotneedjquery.com | |
* chrisbuttery.com/articles/fade-in-fade-out-with-javascript/ | |
* fadeOut(el); | |
*/ | |
function fadeOut(el){el.style.opacity=1;(function fade(){if((el.style.opacity-=.1)<0){el.style.display="none";}else{requestAnimationFrame(fade);}})();} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment