General write a slide code that we might write
Initevent:function () {This.el.addEventListener ("Touchstart", This.touchStart.bind (this)); This.el.addEventListener ("Touchmove", This.touchMove.bind (this)); This.el.addEventListener ("Touchend", This.touchEnd.bind (this)); }, Touchstart:function (e) {var touches = e.touches[0]; This.startstatus = {X:touches.pagex, Time:Date.now ()} THIS.VALIDSL IDE = FALSE; }, Touchmove:function (e) {var touches = e.touches[0]; E.preventdefault (); This.endstatus = {X:touches.pagex, Time:Date.now ()} This.delta = { X:this.endstatus.x-this.startstatus.x, Time:this.endstatus.time-this.startstatus.time } this.translate (this.delta.x + ' px ', 0); This.validslide = true; }, Touchend:function (e) { if (this.validslide) {var deltax = Math.Abs (this.delta.x), dir = this.delta.x/d Eltax, con = (DeltaX > WINDOW.INNERWIDTH/3 | | this.delta.time < + && DeltaX > 20) && ((this.delta.x > 0 && this.el.querySelector ('. Prev ')) | | (this.delta.x < 0 && this.el.querySelector ('. Next '))); if (con) {this.translate (dir * window.innerwidth + ' px ', this.speed); SetTimeout (function () {Window.s.trigger (' slide ', [dir]); }, This.speed); } else {this.translate (' 0px ', this.speed); } } },
To copy and paste directly, please ignore the relevant business code. Generally, add E.preventdefault () in Touchmove to prevent the Android phone from triggering only one move and not triggering the end event.
But this will still be in the Android part of the model, such as Samsung mobile phone does not trigger the touch event problem, the specific hack method is to bind the document also a Touchmove event to prevent the browser default action
Hack mode of touch event invalidation for Android part model