Recently done the end page, so while the weekend combed the next mobile side of the event this piece.
By judging where your finger moves on the screen minus the position of your finger on the screen, you can figure out what direction you are sliding:
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Document</title> <styletype= "Text/css">Div{position:relative;width:500px;Height:500px;Background-color:#ccc; } </style></Head><Body> <DivID= "D"></Div> <Scripttype= "Text/javascript"> varD=document.getElementById ('D'), Startx,starty,movex,movey; D.addeventlistener ('Touchstart',function(e) {varTarget=e.targettouches[0]; StartX=Target.clientx, Starty=Target.clienty; }); D.addeventlistener ('Touchmove',function(e) {varTarget=e.targettouches[0]; MoveX=Target.clientx; Movey=Target.clienty; varx=MoveX-StartX, y=Movey-Starty; //if x>0 and the distance moved on the x-axis is greater than the distance traveled on the y-axis if(Math.Abs (x)>math.abs (y)&&x> 0) {alert ('Right'); } Else if(Math.Abs (x)>math.abs (y)&&x< 0) {alert ('left'); } Else if(Math.Abs (x)<math.abs (y)&&y> 0) {alert ('downward'); } Else if(Math.Abs (x)<math.abs (y)&&x< 0) {alert ('Upward'); } }); </Script></Body></HTML>
This is determined by calculating the distance of the x-axis from the y-axis.
The mobile side determines the direction of the touch