unifying touch and click events

試著忘記壹切 提交于 2019-12-11 00:48:59

问题


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

  • maps a touchstart to a mousedown

  • similarly, touchend to mouseup

  • tap to click

  • etc...

  • 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.

Anybody know of a library that will do this. Preferably an invisible jQuery patch.

Thanks.


回答1:


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



来源:https://stackoverflow.com/questions/11752506/unifying-touch-and-click-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!