Phone-side HTML5 Touch Event (Touch events) "Go"

Source: Internet
Author: User

Touchstart: trigger when Touch is started

touchmove: triggers when the finger slides on the screen

touchend: trigger at end of touch

Each touch event includes three touch lists, each containing a series of touch points (for multi-Touch):

touches: a list of all the fingers that are currently on the screen.

targettouches: the list of fingers located on the current DOM element.

changedtouches: a list of fingers that involve the current event.

Each touch point consists of the following touch information (commonly used):

identifier: A numeric value that uniquely identifies the current finger in the touch session. usually starting from 0 serial number (ANDROID4.1,UC)

Target: The DOM element, which is the target of the action.

pagex/pagex/clientx/clienty/screenx/screeny: A numeric value where the action takes place on the screen (page contains scrolling distance, client does not contain scrolling distance, Screens are based on the screen).

Radiusx/radiusy/rotationangle: draw an ellipse roughly equivalent to the shape of a finger, two radii and rotation angles of the ellipse, respectively. initial test Browser does not support, fortunately the function is not commonly used, welcome feedback.

1  varobj = document.getelementbyidx_x ('ID');2Obj.addeventlistener ('Touchmove', Function (Event) {3      //If there's only one finger in the position of this element ,4     if(Event. Targettouches.length = =1) {5        Event. Preventdefault ();//Block Browser default events, important6         varTouch =Event. targettouches[0];7         //Place the element where the finger is located8Obj.style.left = touch.pagex- -+'px';9Obj.style.top = touch.pagey- -+'px';Ten         } One},false);

Note: This feature can only be viewed on mobile devices or emulated mobile devices

Originally from: http://blog.sina.com.cn/s/blog_51048da70101f0ex.html

Phone-side HTML5 Touch Event (Touch events) "Go"

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.