Wow. Js Is Not Working After Using Page Loader

I used wow.js to add some animations to my content to earn some time instead of using my own animations on .appear()

Everything was working great until I had to use some kind of loader that hides the whole wrapper until the window loads. After doing that, the animations are already triggered when I'm scrolling the page. (It's a parallax page). Is this some kind of bug, or did I mess up?

Here's the html and javascript:

<img src="loading.gif" alt="" class="loading"/>
<div class="MainWrapper" style="display: none">

and

$('.MainWrapper').hide();
    new WOW().init();
$(window).load(function() {
    $('.loading').hide(); 
    $('.MainWrapper').show(); 
});
1

1 Answer

Wow.js will trigger ALL animations when you switch display to block.. i.e when you change $('.MainWrapper').hide() (display none) to $('.MainWrapper').show() (display block).

To use a "loader" and still keep the functionality of displaying the animation on scroll just initiate WOW.js inside the .load function after you display the page content.

Your js code should look something like this

$('.MainWrapper').hide();
$(window).load(function() {
   $('.loading').hide(); 
   $('.MainWrapper').show();
   new WOW().init();
});

Hope that helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest