Last active
August 29, 2015 14:07
-
-
Save RyoSugimoto/a446908aed6dad6a9e05 to your computer and use it in GitHub Desktop.
要素をフェードインさせる関数。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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