0

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?

bodanus7
  • 29
  • 4

1 Answers1

1

SetTimeout:

window.addEventListener('load', function load() {
     window.removeEventListener('load', load, false);               
     setTimeout(function(){document.body.classList.remove('js-loading');},2000);

},false);
Jaydip Jadhav
  • 12,179
  • 6
  • 24
  • 40