移动端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);


慕斯709654
浏览 905回答 1
1回答

皈依舞

是在哪个事件下面阻止的默认事件?试试给document绑定touchmove事件,然后阻止默认事件。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript