Last active
May 16, 2018 03:48
-
-
Save hideya/30019195b20d3dbf9b265deed7331dd9 to your computer and use it in GitHub Desktop.
This file contains 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
document.addEventListener("DOMContentLoaded", function() { | |
var elems = document.getElementsByClassName("fadein-after-load"); | |
for (var i = 0; i < elems.length; i++) { | |
(function() { | |
var elem = elems.item(i); | |
elem.style.transition = ""; | |
elem.style.opacity = 0; | |
window.addEventListener("load", function() { | |
var duration = elem.getAttribute("data-duration"); | |
duration = duration || "0.5s"; | |
elem.style.transition = "opacity " + duration; | |
elem.style.opacity = 1; | |
}); | |
})(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment