2014-02-14 62 views
0

編輯17/2/14:我試圖使用.toggle JQuery函數來解決這個問題,但它似乎沒有與我目前的設置一起工作。我一直在Chrome的開發控制檯中關注它,它在嘗試執行時幾乎沒有任何問題。下面是更新後的代碼:從排隊停止jQuery動畫?

$(document).ready(function(){ 
$(".remove").toggle(function() { 
       $($(this).attr("data-ref")).stop(true,true).fadeIn(); 
        }, 
        function() { 
       $($(this).attr("data-ref")).stop(true,true).fadeOut(); 
       }); 
}); 

OLD:

我試圖去出現,其各自的圖像映射區的一個獨特的工具提示>徘徊,但是當涉及到他們的動畫來淡入淡出或滑入時,它們可以一個接一個地排隊和動畫,如果很多是一次徘徊,或者根本沒有動畫,則在圖像映射後面剪切。

這是我的代碼。我寧願不改變加價:

懸停在:1 懸停在:2 鼠標懸停:3 鼠標懸停:4 懸停在:( '除去')5

$ .mouseover(function(){($(this).attr(「data-ref」))。show(); }); ('。remove')。mouseout(function(){ $($(this).attr(「data-ref」))。hide(); });

+0

嘗試'$($(本).attr(「數據 - ref)))。stop(true).fadeIn();'和'$($(this).attr(「data-ref」))。stop(true).fadeOut();' –

+0

我似乎仍然遇到幾個div一個接一個地衰落而沒有中斷在動畫演出之間,或者根本沒有演奏。 –

回答

0

使用.stop(true,true

$($(this).data("ref")).stop(true,true).fadeIn(); 

.data()

.fadein()

+0

這似乎工作得最好。我仍然在將動畫疊加起來,但是我會嘗試和停止值一起玩,看看我能不能找到工作。 –

+0

另外:.data(「ref」)似乎不起作用。 .data是否按照我的屬性插入連字符?我將它改回.attr(「data-href」)並沒有問題。 –

0

就這樣做:

$('.remove').mouseover(function(){ 
$($(this).attr("data-ref")).stop(); 
$($(this).attr("data-ref")).show(); 
}); 

$('.remove').mouseout(function(){ 
$($(this).attr("data-ref")).stop(); 
$($(this).attr("data-ref")).hide(); 
});