2012-04-20 50 views
0

我有這段代碼有點麻煩之前完成等到這個動畫重複上的另一個鏈接

$('.tree-item').hover(function() { 

    $('#_'+this.id).fadeIn().delay(500).animate({ left: "0px" }, 200); 

},function() { 
    $('#_'+this.id).animate({ left: "3000px" }, 200, function(){ 
     $(this).fadeOut().css('display', 'none').animate({ left: "-3000px" }, 300); 
    }); 
    $(this).stop();  
}); 

我有聯繫上了一棵樹,這段代碼與內容的雲計算帶來的當鏈接懸停時。

我需要等待,直到最後一個環節懸停動作是啓動電流鏈接操作之前完成,因爲它可以看,如果用戶在鏈接快速徘徊很凌亂..

您可以查看我的意思在這裏http://foc.dev.lemon-fresh.co.uk/#program

感謝您的時間。

+0

你也可以停止與[.stop排隊動畫(真)](http://api.jquery.com/stop/) – 2012-04-20 09:44:15

+0

我覺得有一個更大的問題,你不能等待動畫完成,因爲你不知道它通過動畫,你必須首先解決。我建議跟蹤是否有東西是開放的,只有在完成關閉時纔開始顯示。 – will 2012-04-20 09:54:24

+0

嗨,請問您能否詳細說明jQuery noob :) – 2012-04-20 09:58:50

回答

5

所有的jQuery動畫函數都有一個complete回調方法,當動畫完成時它會被執行。

.animate(屬性[,時間] [,緩和] [,完整])

裁判:http://api.jquery.com/animate/

$(this).animate({}, 200, null, function() { 
    //do this when ready... 
}); 
相關問題