Question

I am using animate.css to give some animations for divs when scrolling. It is working, but the animation play when I start scrolling not when the animated area is visible. Any ideas how can i play the animation when area is visible ?! Following is my JavaScript code:

    $(document).ready(function (){
        $(window).scroll(function() {
            var scroll = getCurrentScroll();
            if ( scroll) {
                $('.anim-left').addClass('animated bounceInLeft');
                $('.anim-fade-right').addClass('animated flipInY');
            }
        });

        function getCurrentScroll() {
            return window.pageYOffset || document.documentElement.scrollTop;
        }
    });
Était-ce utile?

La solution

Use wow.js will reveal animation with scrolling.

http://mynameismatthieu.com/WOW/

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top