撤消javascript动画

时间:2013-10-23 22:00:02

标签: javascript jquery css html5

我正在某个窗格上制作一个较大的旋转木马的div。要扩大我做的窗格:

if(currentPane==2)
{
    $("#carousel").animate({height:320},1000);
    $("#carousel").animate({top:411},1000);
    $("#dropShadow").animate({top:731},1000);
}

这非常有效。当我离开这个窗格时,我想再次将轮播返回到较小的尺寸,我这样做:

if(currentPane==3)
{
    $("#dropShadow").animate({top:672},1000);
    $("#carousel").animate({top:411},1000);
    $("#carousel").animate({height:100},1000);
}

Drophadow返回到它的原始位置,但旋转木马拒绝减小尺寸。

对我而言,似乎我使用相同的代码,所以不明白为什么它不起作用。

1 个答案:

答案 0 :(得分:0)

你试过添加.stop()吗?如: 只是一个不是100%肯定的想法,制作jsfiddle

if(currentPane==3)
{
    $("#dropShadow").stop(true).animate({top:672},1000);
    $("#carousel").stop(true).animate({top:411},1000);
    $("#carousel").stop(true).animate({height:100},1000);
}