手机UC禁止左右滑动切页

手机UC 左右滑动时会切换页面,禁止的方法其一为阻止【document】的 【touchmove】事件 的默认操作,

其次就是调用,UC API   代码如下:

var xStart,xEnd,yStart,yEnd;
document.addEventListener('touchmove',function(evt){
    xEnd=evt.touches[0].pageX;
    yEnd=evt.touches[0].pageY;
    Math.abs(xStart-xEnd)> Math.abs(yStart-yEnd)&&
    evt.preventDefault();
},false);

document.addEventListener("touchstart",function(evt){
    xStart=evt.touches[0].pageX;
    yStart=evt.touches[0].pageY;
},false);

=========================  或者  =====================================

if(navigator.control&&navigator.control.gesture){
    navigator.control.gesture(false);
}


猜你喜欢

转载自blog.csdn.net/sflf36995800/article/details/51853814