Preventing touch from generating mouseOver and mouseMove events in Android browser

余生长醉 提交于 2020-01-13 10:30:15

问题


I am building a page that needs to work with touch and mouse interaction on PC, Mac, and mobile browsers.

In the event handler methods for touchStart, touchMove, touchEnd, and touchCancel I am calling event.preventDefault to prevent mobile browsers from firing both touch and mouse events.

This works great for mouseDown and mouseUp, which do not get fired when I touch the screen, but for some reason a short while (couple 100ms) after each touchStart is fired, the android browser still fires a mouseMove event (on the very first touchStart, this mouseMove is preceded by a mouseOver). If I touch quickly enough, the mouseMove gets fired after touchEnd (with the same delay relative to touchStart).

I'd really like to prevent any mouse events from being generated from touches and I'd also like to understand in detail what's going on here, so I have the following questions:

  • Is there some other touch event that I am not capturing which causes the mouseMove event?
  • Why is the mouseMove delayed a bit relative to the touch start?
  • Why isn't the mouseMove generated by any other touch events (touchMove, touchEnd)?
  • Do any other browsers have quirks that might generate mouse events from touches?
  • Is there a different cross-platform approach for preventing touch to cause mouse events? Maybe some CSS?

来源:https://stackoverflow.com/questions/28665855/preventing-touch-from-generating-mouseover-and-mousemove-events-in-android-brows

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