统一触摸和点击事件 [英] unifying touch and click events
问题描述
我以为这个问题已经死了,但是我没有找到任何好的方法. 我想要的是跨越设备的一组统一事件.我知道映射并不总是1对1,而是覆盖了诸如以下内容的基本内容:
I'd assume this question has been asked to death, but I'm not finding anything good. What I'd like is a unified set of events that span devices. I know the mapping isn't always 1 to 1, but just something that covers the basics like:
-
忽略/禁用触摸设备上的悬停事件/样式
ignores/disables hover events/styles on a touch device
将touchstart映射到鼠标按下
maps a touchstart to a mousedown
类似地,将鼠标悬停在鼠标上
similarly, touchend to mouseup
点击以点击
等...
甚至可以触摸,按住1秒钟,触摸移动以拖动开始...
maybe even touch, hold 1s, touchmove to dragstart...
我还没有考虑所有细节.当然,特定于设备的事件(例如,在桌面上悬停或在平板电脑上滑动)无法翻译,如果不支持,则应将其忽略.
I haven't thought through all the specifics. And of course device specific events like hover on a desktop, or swipe on a tablet, can't be translated and should just be ignored if not supported.
任何人都知道可以做到这一点的图书馆.最好是一个看不见的jQuery补丁.
Anybody know of a library that will do this. Preferably an invisible jQuery patch.
谢谢.
推荐答案
jQuery Mobile 确实做到了这一点事情.
jQuery Mobile does exactly this, amongst many other things.
请参见虚拟鼠标事件上的文档,其中:
See their documentation on virtual mouse events, which:
...提供了一组虚拟"鼠标事件,试图将鼠标和触摸事件抽象化
... provide a set of "virtual" mouse events that attempt to abstract away mouse and touch events
这篇关于统一触摸和点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!