Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hideya/30019195b20d3dbf9b265deed7331dd9 to your computer and use it in GitHub Desktop.
Save hideya/30019195b20d3dbf9b265deed7331dd9 to your computer and use it in GitHub Desktop.
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