varstartpos = 0,endpos = 0,isscrolling = 0;d Ocument.addeventlistener (' Touchstart ',function(event) {vartouch = event.targettouches[0];//touches array objects get all the touch on the screen, take the first touchstartpos = {x:touch.pagex,y:touch.pagey,time:+NewDate};//take the coordinate value of the first touchisscrolling = 0;//This parameter determines whether to scroll vertically or horizontally},false);//Unbind Event web front-end developmentDocument.addeventlistener (' Touchend ',function(event) {Document.removeeventlistener (' Touchmove ', This,false);d Ocument.removeeventlistener (' Touchend ', This,false);}, false);d Ocument.addeventlistener (' Touchmove ',function(event) {//do not perform a move operation when the screen has multiple touch or the page is being retractedif(Event.targetTouches.length > 1 | | event.scale && event.scale!== 1)return;varTouch = Event.targettouches[0];endpos= {X:touch.pagex-startpos.x,y:touch.pagey-Startpos.y};//alert (Math.Abs (endpos.x) + "----" +math.abs (ENDPOS.Y));isscrolling = Math.Abs (endpos.x) < Math.Abs (ENDPOS.Y)? 1:0;//isscrolling is 1 o'clock, indicates longitudinal slide, 0 is transverse slideif(isscrolling = = 0){//Event.preventdefault ();//blocking the default behavior of touch events, which is to prevent scrolling}if(Math.Abs (endpos.x) > 5) {event.preventdefault ();//Horizontal slide Ban}}, false);//Prevent page scrolling//document.body.addEventListener (' Touchmove ', function (event) {//Event.preventdefault ();//}, True);
No scrolling on the mobile side