Handling Touch events allows you to track the location of each finger of the user. You can bind the following four kinds of touch events:
Touchstart: Trigger When the finger is placed on the screen
Touchmove://Trigger when the finger moves on the screen
Touchend://Trigger when finger is picked up from the screen
Touchcancel://The system triggers when the touch event is canceled. As to when the system will be canceled, unknown
client/clienty://the location of the touch point relative to the browser window viewport
pagex/pagey://the position of the touch point relative to the page
screenx/screeny://the position of the touch point relative to the screen
Identifier://Unique ID of touch object
Each Touch object contains the following properties.
ClientX: Touch the x-coordinate of the target in the viewport.
ClientY: Touch the y-coordinate of the target in the viewport.
Identifier: Represents the unique ID of the touch.
PageX: Touch the x-coordinate of the target in the page.
Pagey: Touch the y-coordinate of the target in the page.
ScreenX: Touch the x-coordinate of the target in the screen.
ScreenY: Touch the y-coordinate of the target in the screen.
Target: The coordinates of the DOM node of the touch.
//touchstart event function touchsatrtfunc (e) { // Evt.preventdefault () //block Browser zoom, scroll bar scrolling, etc. when blocking touch var touch = e.touches[0]; //gets the first contact var x = number (Touch.pageX); //page Contact x coordinate var y = number (touch.pagey) //page Contact Y coordinate //Record Contact initial position startX = x; starty = y; } //touchmove Event function touchmovefunc (e) { //evt.preventdefault (); //the browser's zoom when blocking the touch, Scroll bar scrolling and other var touch = evt.touches[0]; //get the first contact var x = number (Touch.pagex); //page contact x-coordinate var y&Nbsp;= number (touch.pagey); //page Contact y-coordinate var text = ' Touchmove Event Trigger: (' + x + ', ' + y + ') '; //Judging slide Direction if (x - startx != 0) { //left } Right slide if (y - starty != 0) { //swipe up and down } }