在阅读和测试它不起作用之后,为一个元素设置动画,而另一个元素在动画中:
var wWidth = $(window).innerWidth(),
count = $('.slide').length;
$('body *').css('width',wWidth);
$('.slide div').each(function(ind,el) {
$(el).css({
'left': (wWidth*(ind+1))
});
});
function startAnimation() {
$(".slide div.image2" ).animate({
left: wWidth/4,
opacity:1
}, {
duration: 1800,
step: function( now, fx ){
$( ".slide div.image1" ).animate( {left:0,opacity:1 },1800);
}
});
};
function finishAnimation() {
$(".slide div.image2" ).animate({left: -wWidth,opacity:0}, {
duration: 1000,
step: function(now, fx) {
if (fx.state > 0.5 && fx.prop === "width") {
if(!$( ".slide div.image1" ).is(':animated')) // Make sure you didn't start the animation already
$( ".slide div.image1" ).animate({left:-wWidth,opacity:0}, 1000);
}
}
})
}
startAnimation();
finishAnimation();
startAnimation 工作正常,但 finishAnimation 没有隐藏并移动到左侧 .image1 div
请帮忙