Jquery,在淡入/淡出期间禁用/忽略悬停事件?

发布于 2024-09-11 11:05:45 字数 232 浏览 4 评论 0原文

我想弄清楚这是否可能。我有一个图像地图,它会根据悬停在某些部分上而淡入/淡出。问题是,当用户在淡入淡出期间将鼠标悬停到不同区域时,它会完成它所做的淡入淡出然后是鼠标移动到的区域的淡入淡出。如果用户在几个不同的区域之间快速移动,那么淡入淡出显得非常跳跃和尴尬,所以我希望能够禁用悬停事件(淡入淡出)在另一个淡入淡出发生期间,所以它只是忽略它。

我考虑过使用某种延迟,但我不知道这是否可行,因为我认为它也会延迟淡入淡出。任何建议表示赞赏。

I'm trying to figure out if this is possible.. I have an image map that does fade in / fade out based on hovers over certain parts.. the problem is that when the user hovers to a different area during the fade it finishes the fade it was doing then does the one for the area the mouse was moved to.. if the user moves quickly between a few different areas then the fades appear really jumpy and awkward, so I want to be able to disable the hover event (the fade) during the time that another fade is going on so it just ignores it..

I have thought about using some sort of delay but I don't know if this can work since I would think it would delay the fade too.. any advice is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

嘿咻 2024-09-18 11:05:47

在看不到代码的情况下,您的工具是 :animated 和 jQuerys .stop() 方法的混合体。

这可能看起来像

$('imagemap').hover(function(){
   // only do something if no animation is in process (like fading)
   if(!$(this).is(':animated')){
   }
}, function(){
});

您还可以在链中的任何 .fadeIn() 之前调用 .stop(true, true) 。这将停止当前动画并跳转到 fx 队列 的末尾。

参考文献::动画选择器.stop(), .is()

Without seeing your code, your tools are a mix of :animated and jQuerys .stop() method.

That could look like

$('imagemap').hover(function(){
   // only do something if no animation is in process (like fading)
   if(!$(this).is(':animated')){
   }
}, function(){
});

You might also call .stop(true, true) before any .fadeIn() in your chain. That will stop the current animation and jump to the end of the fx queue.

References: :animated selector, .stop(), .is()

花桑 2024-09-18 11:05:47

我认为您指的是 队列构建那里有问题。尝试在动画方法之前使用 stop 方法,例如:

$(...).stop().fadeIn();

更多信息:

http://www.learningjquery.com/2009/ 01/quick-tip-prevent-animation-queue-buildup

至于平滑的动画,你可以选择 jQuery 缓动插件

I think you are referring to queue buildup problem there. Try using the stop method before the animation method eg:

$(...).stop().fadeIn();

More Info:

http://www.learningjquery.com/2009/01/quick-tip-prevent-animation-queue-buildup

As for smooth animation, you can go for jQuery Easing Plugin.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文