向jQuery添加自定义动画类

向jQuery添加自定义动画类,jquery,css-animations,animate.css,Jquery,Css Animations,Animate.css,我已经在CSS中创建了一个自定义动画类,我正在使用jQuery动态添加到元素中。一旦animate.css动画完成,我的自定义动画类就开始了 我遇到的问题是,我的自定义动画没有播放,就我的一生而言,我不知道我做错了什么。我可以在dev工具中看到该类被添加到我的元素中,但动画没有发生 自定义淡入css: .custom-fade{ -webkit-animation: 3s ease 0s normal forwards 1 custom; animation: 3s ease 0

我已经在CSS中创建了一个自定义动画类,我正在使用jQuery动态添加到元素中。一旦animate.css动画完成,我的自定义动画类就开始了

我遇到的问题是,我的自定义动画没有播放,就我的一生而言,我不知道我做错了什么。我可以在dev工具中看到该类被添加到我的元素中,但动画没有发生

自定义淡入css:

.custom-fade{
    -webkit-animation: 3s ease 0s normal forwards 1 custom;
    animation: 3s ease 0s normal forwards 1 custom;
}

@keyframes custom{
    0% { opacity:.5; }
    66% { opacity:.2; }
    100% { opacity:0; }
}

@-webkit-keyframes custom{
    0% { opacity: .5; }
    66% { opacity: .2; }
    100% { opacity: 0; }
}

@-moz-keyframes custom{
    0% { opacity: .5; }
    66% { opacity: .2; }
    100% { opacity: 0; }
}
jQuery:

var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
var fadeInUp = 'animated fadeIn fadeInUp';
var fadeOut = 'animated fadeOut';
var customFade = '.custom-fade';

$('.bg-img').addClass(fadeInUp);

    $('.bg-img').one( animationEnd, function(){
        $(this).removeClass(fadeInUp).addClass('.custom-fade');
    });

问题出在添加类中。您应该在
addClass()
中指定
'custom-fade',而不是
'

示例代码
jQuery:
var animationEnd='webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationEnd';
var fadeInUp=‘动画fadeIn fadeInUp’;
var fadeOut=‘动画淡出’;
var customFade='.customFade';
$('.bg img').addClass(fadeInUp);
$('.bg img').on(animationEnd,function(){
$(this.removeClass(fadeInUp.addClass('custom-fade');
});
。自定义淡入淡出{
-webkit动画:3s轻松0s正常转发1自定义;
动画:3s轻松0s正常向前1自定义;
}
@自定义关键帧{
0%{不透明度:.5;}
66%{不透明度:.2;}
100%{不透明度:0;}
}
@-webkit关键帧自定义{
0%{不透明度:.5;}
66%{不透明度:.2;}
100%{不透明度:0;}
}
@-moz关键帧自定义{
0%{不透明度:.5;}
66%{不透明度:.2;}
100%{不透明度:0;}
}
.bg img{
宽度:200px;
高度:500px;
背景:红色;
}


您是否有意放置“一”以附加事件处理程序$('.bg img').one(…)@eeya我想那是个打字错误。他想在(…)