滚动时不会触发mouseover / mouseenter [英] mouseover/mouseenter not fired when scrolling

查看:246
本文介绍了滚动时不会触发mouseover / mouseenter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有花哨的Apple鼠标,可以检测手指动作,例如滑动和滚动。

I have the fancy Apple mouse that detects finger movements such as "swipe" and "scroll".

将光标固定在屏幕上,但是用我的手指为了向下滚动页面,光标(虽然是固定的)自然地移动到不同的元素上,因为元素正在自行移动。

Leaving the cursor fixed on the screen, but using my finger to scroll down my page, the cursor (although fixed) naturally moves over different elements, because the elements are moving themselves.

我的问题是当这样做时,当鼠标光标直接在它们上方时,不会调用适当的mouseover / mouseenter回调。

My problem is that when doing that, the appropriate mouseover/mouseenter callbacks don't get called when he mouse cursor is directly above them.

如何解决这个问题?

推荐答案

我使用过的大多数浏览器在页面滚动时都不会触发鼠标事件。您可以尝试侦听 onscroll 事件并使用 document.elementFromPoint 来确定在鼠标光标下移动了哪个元素 onscroll 事件触发。

Most browsers that I've used don't fire mouse events when the page scrolls. You could try listening to the onscroll event and using document.elementFromPoint to determine what element has moved underneath the mouse cursor when the onscroll event fires.

这篇关于滚动时不会触发mouseover / mouseenter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆