Reputation: 29
I'm creating a website loader and have the following code:
window.addEventListener('load', function load() {
window.removeEventListener('load', load, false);
document.body.classList.remove('js-loading');
},
false);
Thanks to this I'm creating a CSS animation with .js-loading class, and when the page is loaded this class is removed. To have a smooth finished animation I need add some delay time after that this class will disappear. (website load time + additional delay) Could you help me?
Upvotes: 0
Views: 1424
Reputation: 12309
window.addEventListener('load', function load() {
window.removeEventListener('load', load, false);
setTimeout(function(){document.body.classList.remove('js-loading');},2000);
},false);
Upvotes: 1