有没有办法让触摸启动事件不会触发点击事件?
当访问者点击图像时,click
事件将被触发。但是,当有人触摸图像时,即使 touchstart
事件也可用,也会触发相同的 click
事件。
我喜欢实际单击(鼠标)事件和触摸事件的不同行为。奇怪的是,在智能手机上使用时甚至会触发 mouseup
事件。无论如何,您可以将鼠标与触摸事件分开吗?
When a visitor clicks on an image the click
event will be triggered. However when someone touches the image, that same click
event will be triggered, even if a touchstart
event is available as well.
I like a different behavior for an actual click (mouse) event and a touch event. The strange thing is, even a mouseup
event is triggered when used on a smartphone. Is there anyway you can separate the mouse from the touch events?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
成功了,希望这对人们有帮助!
Did the trick, hope this helps people!
您可以规范化事件..
请参阅我对此问题的回答:
在 iPad 的 touchend 上调用两次点击事件
您还可以查看 jQuery mobile 源代码来寻找灵感:http://code.jquery.com/mobile/1.0。 1/jquery.mobile-1.0.1.js 从第982行开始
看tap事件:(第1049行)
you can normalize an event..
See my answer to this question:
Click event called twice on touchend in iPad
You can also look in the jQuery mobile source code to find inspiration: http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.js Start at line 982
Look at the tap event: (line 1049)
这是一种防止 touchstart 后点击的复杂方法。 touchstart 之后传播的点击称为幽灵点击。
谷歌已经实施了一个解决方案。给您。
http://code.google.com/mobile/articles/ fast_buttons.html#ghost
It is a complex way to prevent click after touchstart. The click which propagates after touchstart is called ghost click.
Google has implemented a solution. Here you go..
http://code.google.com/mobile/articles/fast_buttons.html#ghost