// mouse slip event // start pressing the phone starting coordinate var the startPoint = null ; document.addEventListener ( " touchstart " , function (E) { var E = E || window. Event ; the startPoint = e.touches [ 0 ] ; }) document.addEventListener ( " touchEnd " , function (E) { var E = E || window. Event ; // e.changedTouches finger from the mobile phone can be found, returns an array var endPoint, e.changedTouches = [ 0]; // calculate the difference between end and start var X = endPoint.clientX - startPoint.clientX; var Y = endPoint.clientY - startPoint.clientY; // set the reference value of the sliding distance var D = 100 ; IF (the Math. ABS (X)> D) { IF (X> 0 && (Y < 10 || Y> 10 )) { the console.log ( " swipe right " ); the window.location = " / Best " ; }else if (x < 0 && (y < 10 || y > 10)) { console.log("向左滑动"); window.location = "/home/Seeview"; } } if (Math.abs(y) > d) { if (y > 0) { console.log("向下滑动"); } else { console.log(""Swipe up); } } })
Transfer :: https://blog.csdn.net/gg451516921/article/details/79133416