Skip to content

Instantly share code, notes, and snippets.

@easierbycode
Last active October 4, 2017 19:43
Show Gist options
  • Save easierbycode/859140f2c9e2a57bd52793c0928c5903 to your computer and use it in GitHub Desktop.
Save easierbycode/859140f2c9e2a57bd52793c0928c5903 to your computer and use it in GitHub Desktop.
utils for transitioning between game and DOM elements
function fadeIn(id,speed) {
var element = document.getElementById(id);
var op = 0.1; // initial opacity
element.style.visibility = 'visible';
element.style.opacity = op;
var timer = setInterval(function () {
if (op >= 1){
clearInterval(timer);
}
element.style.opacity = op;
element.style.filter = 'alpha(opacity=' + op * 100 + ")";
op = op * 1.5;
}, speed);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment