我試圖做一個3階段的動畫,其中打開框最小化,他們都向左滑動,並單擊框擴展。最後的動畫,選中的方框展開,當它被稱爲第二個動畫的參數時重複3次,但如果我單獨調用它,它會正常工作。jQuery animate()重複3x
其在http://st-catherineschool.org/xbox/
$("#box2").click(
function(){
box = 2;
if(boxopen==box)return;
$("#box"+boxopen).animate({height:"-=30%", width:"-=10%", top:"+=20%", fontSize:"14px"}, 500, null,
function(){
$("section").animate({right:"+=25%"},500,null,
function(){
$("#box"+box).animate({height:"+=30%", width:"+=10%", top:"-=20%"}, 500);
$("#box"+boxopen).css("z-index", "8");
$("#box"+box).css("z-level", "9");
boxopen = box;
});
});
});
這不是停止動畫的問題,它是DOM Bubbling的一個問題! – RobertPitt
添加.stop()沒有改變,我不認爲它的冒泡,因爲答案1也沒有幫助。 – austin
我的不好,你是對的,你只是把它與你的例子中的錯誤選擇器。當我把它放在(「#box」+ box)中時,AKA#box2在最後一個函數中,它的工作原理就是我想要的。 – austin