2013-10-23 45 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語句以獲得更清晰的代碼 –