Javascript 何时使用 touchmove 与 mousemove?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13510999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
When to use touchmove vs mousemove?
提问by Soliman
I build a web mobile game, it runs on browsers (PC/Mobile).
我构建了一个网络手机游戏,它在浏览器(PC/手机)上运行。
Do I need to use the touchmove or not?
我是否需要使用touchmove?
How can I run the touchmove event like the mousemove event?
如何像 mousemove 事件一样运行 touchmove 事件?
回答by Konstantin Dinev
For parity between desktop and touch you have the following equivalences:
对于桌面和触摸之间的奇偶校验,您有以下等效项:
mousedown === touchstart
mousemove === touchmove
mouseup === touchend
Thus if you handle mousedown, mousemove and mouseup then you don't need to handle the corresponding equivalent events under touch. The same handlers should be executing.
因此,如果您处理 mousedown、mousemove 和 mouseup,那么您就不需要在触摸下处理相应的等效事件。应该执行相同的处理程序。
回答by guest
Except on the ipad -- where mouse hover, mouse down, mouse up and click are all triggered... except if you change anything in mouse hover .. then nothing else gets triggered.... very annoying...more details see http://sitr.us/2011/07/28/how-mobile-safari-emulates-mouse-events.html
除了在 ipad 上——鼠标悬停、鼠标按下、鼠标抬起和点击都被触发......除非你在鼠标悬停中改变任何东西......然后没有其他东西被触发......非常烦人......更多细节见http://sitr.us/2011/07/28/how-mobile-safari-emulates-mouse-events.html

