Javascript 中的触摸与点击事件 - iOS 移动 Safari

发布于 2024-12-01 06:09:29 字数 232 浏览 2 评论 0原文

我有一个容器 div,我设置了 touchstart/move/end 事件侦听器,以便在不滚动页面的情况下滚动其中的内容。现在我的问题是如何允许其中的链接可点击?我在 touchstart 处理程序中设置 e.preventDefault();,以防止页面在滚动时出现抖动,从而阻止我的链接可点击。有什么想法或建议吗?

I have a container div I have set touchstart/move/end event listeners in order to scroll the content within it without the page scrolling. Now my issue is how do you allow links within it to be clickable? I am setting e.preventDefault(); within my touchstart handler to prevent the page from jerking while scrolling and this is preventing my links from being clickable. Any ideas or suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

つ可否回来 2024-12-08 06:09:29

尝试绑定到 touchmove。仅当用户触摸然后拖动时才会触发此操作,因此不应干扰他们的单击。 (在此处测试

Try binding to touchmove instead. This will only be triggered if the user touches and then drags, so should not interfere with them clicking. (Tested here)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文