1$ ("Body"). On ("Touchstart",function(e) {2 E.preventdefault ();3StartX = E.originalevent.changedtouches[0].pagex,4Starty = E.originalevent.changedtouches[0].pagey;5 });6$ ("Body"). On ("Touchmove",function(e) {7 E.preventdefault ();8Moveendx = E.originalevent.changedtouches[0].pagex,9Moveendy = E.originalevent.changedtouches[0].pagey,TenX = Moveendx-StartX, OneY = Moveendy-Starty; A -if(Math.Abs (x) > Math.Abs (Y) && X > 0 ) { -Alert ("Left 2 right"); the } -Else if(Math.Abs (x) > Math.Abs (Y) && X < 0 ) { -Alert ("Right 2 left"); - } +Else if(Math.Abs (Y) > Math.Abs (X) && Y > 0) { -Alert ("Top 2 Bottom"); + } AElse if(Math.Abs (Y) > Math.Abs (X) && Y < 0 ) { atAlert ("Bottom 2 Top"); - } -Else{ -Alert ("Just Touch"); - } -});
Test examples can be accessed by clicking here: Judging finger Slide direction Demo
Mobile browser Touch Event judging finger slide direction method