alvarotrigo / fullPage.js

fullPage plugin by Alvaro Trigo. Create full screen pages fast and simple
http://alvarotrigo.com/fullPage/
GNU General Public License v3.0
35.24k stars 7.3k forks source link

animate element on scroll everytime entering a section, not just one time. #2247

Closed debutifyaccounts closed 8 years ago

debutifyaccounts commented 8 years ago

Hey thanks for fullpage its awesome! :) I i'm using the on leave function to animate element when entering sections, but I only managed to make it animate one time and I don't know how to make it animate everytime! So yeah it would be really nice of you if you can guide me in the right direction on how to make an animation happen everytime;

for exemple: when leaving page1 , I use a slide in effect on my text(on page2). But How to make this animation happen again when coming from page 3 up to page 2?

Thank you !!!

    $(document).ready(function() {
        $('#fullpage').fullpage({
            anchors: ['page1', 'page2', 'page3', 'page4', 'page5'],
            navigation: true,
            navigationPosition: 'right',

            //animation section1
            'afterLoad': function(anchorLink, index){
                var $AnimPage1 = $('#section1 .is-animated');

                if(index == 1){
                    $AnimPage1.addClass('animated slideInDown');
                }
            },

            //animation section ONLEAVE
            'onLeave': function(index, nextIndex, direction){
                var $AnimPage1 = $('#section1 .is-animated');
                var $AnimPage2 = $('#section2 .is-animated');
                var $AnimPage3 = $('#section3 .is-animated');
                var $AnimPage4 = $('#section4 .is-animated');
                var $AnimPage5 = $('#section5 .is-animated');

                if (index == 1 && direction == 'down'){
                    $AnimPage2.addClass('animated slideInUp');
                }
                if (index == 2 && direction == 'down'){
                    $AnimPage3.addClass('animated slideInUp');
                }
                if (index == 3 && direction == 'down'){
                    $AnimPage4.addClass('animated slideInUp');
                }
                if (index == 4 && direction == 'down'){
                    $AnimPage5.addClass('animated slideInUp');
                }

            }

        });
    });
alvarotrigo commented 8 years ago

I replied you on stackoverflow. http://stackoverflow.com/questions/39339925/fullpage-js-use-2-differents-animation-on-direction-up-direction-down

It is more an issue of Animate.css than fullpage.js.

debutifyaccounts commented 8 years ago

Oh it was you ! howdyou knew I was the same person haha, I'll look into that thanks!

alvarotrigo commented 8 years ago

Use the animateCss method that I pointed you out instead of the addClass one. What it does is removing the animated class and the animation one after the animation ends so you can add them again generate a new animation.

debutifyaccounts commented 8 years ago

Oh cool ! Thanks again man really appreciate your help:)