jquery/IE mousemove 事件随着工具提示消失而触发,但鼠标没有移动
我正在尝试让工具提示起作用,以便它在显示后淡出。我的代码工作得很好,除了在 IE8 中 - mousemove 事件(在图像上)随着工具提示的淡入而不断被触发,并产生脉动效果......淡入/淡出/淡入/淡出。
该问题与工具提示有关,因为如果我删除工具提示代码,则仅在移动鼠标时才会调用 mousemove 事件。
您可以在此处查看简化示例:
I'm trying to get a tooltip to work so that it fades out after it is shown. My code works great except in IE8 - the mousemove event (over an image) keeps getting triggered as the tooltip fades and it creates a pulsating effect... fading in/out/in/out.
The problem has something to do with the tooltip because if I get rid of the tooltip code, the mousemove event is only called when the mouse is moved.
You can see a simplified example here:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,我的修复想法似乎有效:
Yep, my idea for a fix seems to work:
是的,我可以在 IE7 和 IE8 中重现这一点,jquery-1.6.2
我编写了一个图像幻灯片,它使用 fadeIn()/fadeOut() 在图像之间切换。如果鼠标光标位于幻灯片上,则切换图像时会出现 img title="..." 工具提示。当工具提示消失(浏览器在几秒钟后消失)时,将调用 mousemove() 处理程序。
有关当前(2011 年 7 月 24 日)在 IE7 中引发此错误的示例,请参阅 http://davidhoulder.com 的首页/8。如果我设法解决或解决此问题,我将更新此答案。
一种可能的解决方法是将 .pageX 和 .pageY 保存在 .mousemove() 处理程序中,如果鼠标确实没有移动则返回。
Yep, I can reproduce this in IE7 and IE8, jquery-1.6.2
I've written an image slideshow that uses fadeIn()/fadeOut() to switch between images. If the mouse cursor is over the slideshow, the img title="..." tooltip appears when an image is switched in. When the tooltip disappears (the browser fades it after a few seconds), the mousemove() handler is called.
See the front page of http://davidhoulder.com for an example which currently (24 July 2011) provokes this bug in IE7/8. If I manage to fix or workaround this I'll update this answer.
One possible fix is to save .pageX and .pageY in the .mousemove() handler and just return if the mouse really hasn't moved.