问题描述
在移动设备(iPad、Galaxy Tab)上查看网站时,点击元素(常规链接或其他任何使用 javascript/jquery 可点击的内容)总是会出现延迟.
When viewing a web site on a mobile device (iPad, Galaxy Tab) there's always a lag when I click an element (regular link or anything else that is made clickable using javascript/jquery).
在网上阅读时,我发现浏览器使用的是 touchstart 后跟 touchend 事件,然后触发常规点击事件.有没有办法让点击响应更快并删除延迟的点击事件?也许通过使用 javascript 或其他方式?
While reading online, I found out that the browser is using touchstart followed by touchend events, and afterwards it triggers the regular click event. Is there a way to have a more responsive tap and remove the click event that is delayed? Maybe by using javascript, or something else?
推荐答案
如果您正在自己编写网页,您可以为 touchstart 和 touchend 注册一个侦听器,并在没有任何延迟的情况下直接从触摸端触发 onclick 代码.
if you are writing a web page your self you can register a listener for touchstart and touchend and trigger the onclick code directly from on touch end without any delay.
如果您不处理触摸移动事件,浏览器将向元素发送(有一些延迟)点击事件
If you don`t handle the event in touch move the browser will dispatch (with some lag) a click event to the element
看看谷歌的这个描述来创建快速按钮":http://code.google.com/intl/de-DE/mobile/articles/fast_buttons.html
Take a look at this description from google to create "fast buttons": http://code.google.com/intl/de-DE/mobile/articles/fast_buttons.html
这篇关于有没有办法消除移动触摸设备上的点击延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!