1

我正在尝试让 Enquire.js 与 fullpage.js 一起工作。

我在 afterLoad 上为一些元素制作动画,并希望这些动画在移动设备上有所不同。

这是一个不带查询的 afterLoad 示例:

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"
            });
        }

我用 Inquire 的目标是这个

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"
            });
        }
    });
}
}

但这似乎不起作用。它只会触发匹配的,而不会触发无与伦比的,为什么?如果我输入控制台日志或警报,两者都会触发。

4

0 回答 0