varPRESSX = 0, Pressy = 0;d Ocument.body.addEventListener (' Touchmove ',function(event) {//If there's only one finger in the position of this element , if(Math.Abs (SpanX) >Math.Abs (Spany)) { //Horizontal Direction if(SpanX > 0) {Direct= "Right";//Right //Do Right function}Else{Direct= "Left";//left //Do left function } } Else { //Vertical Direction if(Spany > 0) {Direct= "Down";//downward //Do-down function}Else{Direct= "Up";//Upward //Do up function } }}, false);d Ocument.body.addEventListener (' Touchstart ',function(event) {//If there's only one finger in the position of this element , if(Event.targetTouches.length = = 1) { varTouch = Event.targettouches[0]; //Place the element where the finger is locatedPRESSX =Touch.pagex; Pressy=Touch.pagey; Touchstart.value= Pressx + '; ' +Pressy; }}, false);
The direction of touch event judgment in Mobile Internet terminal