触摸事件让我发疯
我到处读到有关触摸的内容,但我无法完全理解它。我有一个应用程序,我阻止文档上的所有触摸事件。
document.addEventListener('touchstart', function (e) { e.preventDefault(); }, false);
document.addEventListener('touchend', function (e) { e.preventDefault(); }, false);
现在,我在文档中的某处在添加上述行之前工作正常,但现在不行。
<form onsubmit="search(event)">
<input id="q" type="text" placeholder="Search.." />
</form>
阻止文档触摸是非常需要的。我该如何解决这个问题,如果您知道任何详细描述触摸事件的指南,那就太好了。
I read here and there about touch but I can't get to it completely. I have an app where I am blocking all touch events on the document.
document.addEventListener('touchstart', function (e) { e.preventDefault(); }, false);
document.addEventListener('touchend', function (e) { e.preventDefault(); }, false);
Now I have somewhere in the document which was working fine before adding above lines but now not.
<form onsubmit="search(event)">
<input id="q" type="text" placeholder="Search.." />
</form>
Blocking document touch are very needed. How can I recitfy the problem and please if you know of any guide that describes touch events in detail that would be wonderful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在您正在阻止所有触摸事件,但您真正想做的是阻止所有触摸事件,除了:x、y 和 z;
您只需将
preventDefault()
设置为有条件即可。例如
Right now you are blocking ALL touch events, but what you really want to do is block all touch events EXCEPT: x, y and z;
You'll just have to make your
preventDefault()
conditional.e.g.