Skip to content

Instantly share code, notes, and snippets.

@englishextra
Created May 9, 2016 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save englishextra/cbf5137a95ed5e02927cd3e19e271bae to your computer and use it in GitHub Desktop.
Save englishextra/cbf5137a95ed5e02927cd3e19e271bae to your computer and use it in GitHub Desktop.
FadeIn in pure JS
/*!
* Fade In
* gist.github.com/englishextra/cbf5137a95ed5e02927cd3e19e271bae
* youmightnotneedjquery.com
* fadeIn(el);
* fadeIn(el, "inline-block");
*/
function fadeIn(el){el.style.opacity=0;var last=+new Date();var tick=function(){el.style.opacity=+el.style.opacity+(new Date()-last)/400;last=+new Date();if(+el.style.opacity<1){(window.requestAnimationFrame&&requestAnimationFrame(tick))||setTimeout(tick,160);}};tick();}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment