Skip to content

Instantly share code, notes, and snippets.

@RyoSugimoto
Last active August 29, 2015 14:07
Show Gist options
  • Save RyoSugimoto/a446908aed6dad6a9e05 to your computer and use it in GitHub Desktop.
Save RyoSugimoto/a446908aed6dad6a9e05 to your computer and use it in GitHub Desktop.
要素をフェードインさせる関数。
function fadeIn (elm) {
var last = +new Date();
elm.style.opacity = 0;
tick();
function tick () {
elm.style.opacity = +el.style.opacity + (new Date() - last) / 400;
last = +new Date();
if (+elm.style.opacity < 1) {
(window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment