Skip to content

Instantly share code, notes, and snippets.

@charisTheo
Created January 25, 2019 10:43
Show Gist options
  • Select an option

  • Save charisTheo/fbb9eceb08b06bc6af761333d299d34c to your computer and use it in GitHub Desktop.

Select an option

Save charisTheo/fbb9eceb08b06bc6af761333d299d34c to your computer and use it in GitHub Desktop.
function fadeOut(el){
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= .1) < 0) {
el.style.display = "none";
} else {
requestAnimationFrame(fade);
}
})();
};
function fadeIn(el, display){
el.style.opacity = 0;
el.style.display = display || "block";
(function fade() {
var val = parseFloat(el.style.opacity);
if (!((val += .05) > 1)) {
el.style.opacity = val;
requestAnimationFrame(fade);
}
})();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment