2013-10-23 47 views
0

我正在使某个窗格上的轮播的div更大。要扩大窗格我做:撤消JavaScript动画

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

阴影效果返回到它的原始位置,但传送带拒绝减小尺寸。

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

回答

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); 
} 
+0

谢谢这个现在工作的一种享受! – HastingsDirect

+0

真棒!你可能希望稍后再做一个if else语句以获得更清晰的代码 –