2010-11-30 55 views
0

在快速移動鼠標時(與往常一樣,只在IE中)兩個懸停處理程序都被觸發,因此沒有任何內容出現。 我試過使用hoverIntend,但是這個插件與e.pageX混淆/ Y 任何想法如何解決這個問題,5小時後我沒有成功。當快速移動鼠標時,Jquery懸停觸發兩個處理程序

yOffset = 10; 
xOffset = 30;  

$("img.hover-preview").hover(function(e){ 
//alert('hover'); 

this.t = this.title; 
this.title = ""; 
var c = (this.t != "") ? "<br/>" + this.t : ""; 

preview_link = $('#' + this.id + '-url').attr('src'); //Get the src of the bigger preview image 
zoom_link = $('#' + this.id + '-url-zoom').attr('src'); //Get the src of the ZOOM image 

//Output of the preview element 
$("body").append("<div id='hover-preview-active'><img src='"+ preview_link +"' alt='Loading Image Preview' /><span>" 
       + Drupal.t("Press and hold Z key to zoom") + "</span></div>");  

$("#hover-preview-active") 
    .css("top", (e.pageY - yOffset) + "px") 
    .css("left",(e.pageX + xOffset) + "px") 
    .fadeIn("fast"); 
}, 

function(){ 
    this.title = this.t; 
    $("#hover-preview-active").remove(); 
}); 
+0

你想如何工作? – 2010-11-30 21:10:04

回答

0

您可以在懸停了功能做到這一點:

function(){ 
    if($("#hover-preview-active").is(":animated")) 
     return; 

    this.title = this.t; 
    $("#hover-preview-active").remove(); 
}); 

將從如果當它被稱爲你的#hover-preview-active是動畫停止執行功能。

相關問題