任何人都知道用键盘滚动时触发的鼠标悬停技巧/替代方案
是否有替代方法或悬停方法的技巧,可以在用户滚动页面时光标从一个 div 移动到另一个 div 时触发一个功能。
我在当前帖子 div 的悬停事件上使用一些 javascript (jQuery) 有点让它工作。 但是,我注意到悬停事件仅在鼠标实际移动时才会触发。 如果使用键盘(页面)向上/向下滚动页面,则不会触发。
(我可以注意到,例如 soup.io 已经找到了一种方法来实现这一点,但我找不到他们是如何做到的)
Is there an alternative method or a trick to the hover method which can trigger a function when the cursor moves from one div to another as the user scrolls the page.
I have sort of got it working using some javascript (jQuery) on the hover event of the current post div. However, I've noticed the hover event only triggers when the mouse is actually moved. If the page is scrolled using the keyboard (page) up/down it does not trigger.
(I can note that soup.io for instance has found a way to get this working, but I can't find how they do it)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不幸的是,它相当复杂; 您不能再依赖
onMouseOver
事件 - 页面滚动时触发的唯一事件是onScroll
。 涉及的步骤:快速(不可靠)原型:http://pastie.org/507589
Unfortunately, it's quite complicated; you can no longer rely on the
onMouseOver
event - the only event that triggers when a page is scrolled isonScroll
. The steps involved:Quick (unreliable) prototype: http://pastie.org/507589
你有样品吗? 我猜测页面上元素的布局阻止了 mouseover 事件。 我下面的简单示例按照您的描述工作。 当光标位于页面顶部并使用键盘导航时,将触发 mouseover 事件。
Do you have a sample? I'm guessing that the layout of the elements on the page are blocking the mouseover event. My simple example below works as you described it should. With the cursor at the top of the page and using keyboard navigation, the mouseover events are fired.
您正在寻找鼠标滚轮事件。
我只在 Chrome (webkit) 中测试过这个
You're looking for the mousewheel event.
I only tested this in Chrome (webkit)