Skip to content

Instantly share code, notes, and snippets.

@nishanc
Created March 4, 2019 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nishanc/2530a178a10bcc9db393f89ca2482b0d to your computer and use it in GitHub Desktop.
Save nishanc/2530a178a10bcc9db393f89ca2482b0d to your computer and use it in GitHub Desktop.
var loader;
function loadNow(opacity) {
if (opacity <= 0) {
displayContent();
} else {
loader.style.opacity = opacity;
window.setTimeout(function() {
loadNow(opacity - 0.05);
}, 50);
}
}
function displayContent() {
loader.style.display = 'none';
document.getElementById('content').style.display = 'block';
}
document.addEventListener("DOMContentLoaded", function() {
loader = document.getElementById('loader');
loadNow(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment