JS phone-triggered events, JavaScript phone-side/mobile-triggered events

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.