Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当快速移动鼠标时,Jquery hover将触发两个处理程序_Jquery_Hover_Performance - Fatal编程技术网

当快速移动鼠标时,Jquery hover将触发两个处理程序

当快速移动鼠标时,Jquery hover将触发两个处理程序,jquery,hover,performance,Jquery,Hover,Performance,当鼠标快速移动时(通常仅在IE中),两个悬停处理程序都会被触发,所以不会显示任何内容。 我试着使用hoverintent,但那个插件把e.pageX/Y搞砸了 任何关于如何解决这个问题的想法,我在5个小时后都没有成功 yOffset = 10; xOffset = 30; $("img.hover-preview").hover(function(e){ //alert('hover'); this.t = this.title; this.title = ""; var c

当鼠标快速移动时(通常仅在IE中),两个悬停处理程序都会被触发,所以不会显示任何内容。 我试着使用hoverintent,但那个插件把e.pageX/Y搞砸了 任何关于如何解决这个问题的想法,我在5个小时后都没有成功

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();
});   
yOffset=10;
xOffset=30;
$(“img.hover预览”).hover(函数(e){
//警报(“悬停”);
this.t=this.title;
this.title=“”;
var c=(this.t!=”)?“
”+this.t:”; preview#link=$('#'+this.id+'-url').attr('src');//获取较大预览图像的src zoom_link=$('#'+this.id+'-url zoom').attr('src');//获取缩放图像的src //预览元素的输出 $(“正文”)。附加(“”) +t(“按住Z键缩放”)+”; $(“#悬停预览活动”) .css(“顶部”(e.pageY-yOffset)+“px”) .css(“左”(e.pageX+xOffset)+“px”) .fadeIn(“快速”); }, 函数(){ this.title=this.t; $(“#悬停预览处于活动状态”).remove(); });
您可以在悬停功能中执行此操作:

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

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

如果调用时
#悬停预览处于活动状态
正在设置动画,则该函数将停止执行。

它正在使用aditya的解决方案