// 禁止浏览器左右滑动
// document.addEventListener('touchmove', function (e) {
// e.preventDefault();
// }, {
// passive: false
// });
var startX, startY, moveX, moveY;
document.addEventListener("touchstart", function (e) {
startX = e.targetTouches[0].pageX;
startY = e.targetTouches[0].pageY;
});
document.addEventListener("touchmove", function (e) {
moveX = e.targetTouches[0].pageX;
moveY = e.targetTouches[0].pageY;
if (Math.abs(moveX - startX) > 80 && Math.abs(moveX - startX) > Math.abs(moveY - startY)) {
// e.preventDefault();
startX = null;
startY = null;
window.history.back();
}
}, {
passive: false
});
// window.addEventListener("popstate", function(){
// }, false)
移动端浏览器左右滑动
最新推荐文章于 2024-05-05 18:17:26 发布