2011-10-06 57 views
0

我有一個jQuery腳本,它需要一個img src,將src放在隱藏的div中,並在懸停請求img時用動畫放大img。但是,當我從img跳到img時,clearQueuestop不能按需使用。jQuery中的clearQueue

在這個示例中,當我從img緩慢跳到另一個img時,它工作正常,但是當我快速跳轉時,img在img和img之間完全消失。

我想要的只是能夠快速或緩慢地從img移動到img,並且不會留下任何隊列。

如果有人能幫助我,我會很高興。

下面是代碼:

$(document).ready(function(){ 
    $(".thumb").hover(function(e) { 
     $('#popm').css('left',e.pageX+50); 
     $('#popm').css('top', e.pageY+50); 
     e.preventDefault(); 
     var src= $(this).attr("src"); 
     $('.popimg').attr({"src": src}); 
     $('#popm').stop().fadeIn(100); 
     $('.popimg').stop() 
      .animate({ 
       width: '145px', /* Set new width */ 
       height: '145px' /* Set new height */ 
      }, 200); 
    }, function() { 
     $('#popm').stop().fadeOut(100); 
     $('.popimg').stop() 
      .animate({   
       width: '45px', /* Set new width */ 
       height: '45px' /* Set new height */ 
     }, 200); 
    }); 
}); 

回答

1

你可能想要做.stop(true, true),而不是僅僅.stop()

jQuery.stop()文檔中明確指出,停止有兩個參數,其中第一個是一個布爾清除動畫隊列:

.stop([clearQueue,] [jumpToEnd])

clearQueue - 一個布爾指示是否刪除排隊的動畫。默認爲false。

jumpToEnd - 布爾值,指示是否立即完成當前動畫。默認爲false。

+0

tnx mate it works – user973378