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://When the finger is placed on the screen, the touchmove is triggered://When the finger moves on the screen, the touchend is triggered://finger from the screen Pick up when trigger Touchcancel://The system cancels the touch event when triggered. As to when the system will be canceled, the unknown//attribute client/clienty://the position of the touch point relative to the viewport of the browser window pagex/pagey://the position of the touch point relative to the page screenx/screeny:// The location of the touch point relative to the screen identifier://Touch Object unique ID//touchstart event function Touchsatrtfunc (e) {//evt.preventdefault ();//Resistance Browser zoom, scroll bar scrolling, etc. 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 ();//block touch when browser zoom, scroll bar scrolling, etc. var touch = evt.touches [0]; Gets the first contact var x = number (Touch.pagex); Page contact x coordinate var y = number (touch.pagey); Page contact y-coordinate var text = ' Touchmove Event Trigger: (' + x + ', ' + y + ') '; To determine the sliding direction if (x-startx! = 0) {//swipe left and right} if (Y-starty! = 0) {//swipe up/down}}
JS phone-triggered events, JavaScript phone-side/mobile-triggered events