Skip to content

Instantly share code, notes, and snippets.

@LulzAugusto
Created May 20, 2015 22:15
Show Gist options
  • Save LulzAugusto/533347f462ab265326df to your computer and use it in GitHub Desktop.
Save LulzAugusto/533347f462ab265326df to your computer and use it in GitHub Desktop.
function fadeOut(el){
el.style.opacity = 1;
(function fade() {
el.style.opacity -= 0.1;
if (el.style.opacity < 0) {
el.style.display = "none";
el.classList.add('tago-playerbox-hide');
} else {
requestAnimationFrame(fade);
}
})();
}
function fadeIn(el, display){
if (el.classList.contains('tago-playerbox-hide')){
el.classList.remove('tago-playerbox-hide');
}
el.style.opacity = 0;
el.style.display = display || "block";
(function fade() {
var val = parseFloat(el.style.opacity);
if (((val += 0.2) < 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