Enquire.js and Fullpage.js not playing nice

19 views Asked by At

I am trying to get Enquire.js to work with fullpage.js.

I am animating some elements on afterLoad, and would like those animations to be deferent on mobile.

Here is an example og the afterLoad without Enquire:

afterLoad: function(anchorLink, index){

        var $serviceAnimation = $('.services .is-animated')

        //Services
        if(index == 1){
            //Set easing on all
            $serviceAnimation.slice(0,8).css({animationTimingFunction: "ease-in-out"});
            //h1
            $serviceAnimation.eq(0).addClass('animated fadeIn').css({
                animationDelay: "0s",
                animationDuration: "1s"
            });
        }

What i am aiming for with Enquire is this

afterLoad: function(anchorLink, index){

var $serviceAnimation = $('.services .is-animated')

//Services
if(index == 1){
    //Set easing on all
    $serviceAnimation.slice(0,8).css({animationTimingFunction: "ease-in-out"});
    //h1
    enquire.register("screen and (max-width: 767px)", {
        match : function() {
            $serviceAnimation.eq(0).addClass('animated fadeIn').css({
                animationDelay: "0s",
                animationDuration: "1s"
            });
        },
        unmatch : function() {
            $serviceAnimation.eq(0).addClass('animated fadeInLeft').css({
                animationDelay: "0s",
                animationDuration: "1s"
            });
        }
    });
}
}

But this doesn't seem to work. it only fires the matched one never the unmatched, why? if i put in a console log or alert, both fire just fine.

0

There are 0 answers