移动端js如何组织浏览器左右快速滑动会切换tab的问题

移动端在做左右滑动效果的时候, 已经e.preventDefault 和 e.stopPropagation 了, 但是当快速左右滑动的时候 还是会出现 滑到上一个选项卡和下一个选项卡的 现象, 请问能否阻止 这个动作

刚发现只要手指点到屏幕边缘 就会触发切换标签的动作,document.body上也加preventDafult了, 仍然会触发, 如何阻止这个动作

-----------补上代码---------

function handleStart(e) {
    stopDefault(e);
    ...
}
function handleMove(e) {
    stopDefault(e);
    ...
}
function handleEnd(e) {
    stopDefault(e);
    ...
}
function stopDefault(e) {
    e.stopPropagation();
    e.preventDefault();
}
...
document.addEventListener("touchstart", stopDefault, false)
document.addEventListener("touchmove", stopDefault, false);
document.addEventListener("touchend", stopDefault, false);
...
tab.addEventListener("touchend", handleEnd, false);
tab.addEventListener("touchmove", handleMove, false);
tab.addEventListener("touchstart", handleStart, false);

这是我的代码

阅读 4.6k
1 个回答

是在哪个事件下面阻止的默认事件?
试试给document绑定touchmove事件,然后阻止默认事件。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题