The difference between touch-related variables touches,targettouches and changedtouches in JS

Source: Internet
Author: User

    1. touches: A list of all touch points (fingers) on the current screen;
    2. targetTouches: A list of all touch points (fingers) on the current DOM element;
    3. changedTouches: A list of touch points (fingers) that involve the current event
Use an example to distinguish between these three properties in a touch event:
    • Touch the screen with one finger, triggering the event, at which point the three properties have the same value.
    • With the second finger touching the screen, at this point, the touches has two elements, each finger touch point is a value. When two fingers touch the same element, the values of targettouches and touches are the same, otherwise targettouches has only one value. Changedtouches this time there is only one value for the second finger of the touch point.
    • Touch the screen with two fingers at the same time, the changedtouches has two values, each finger touch point has a value
    • Three values change when you swipe your finger
    • One finger leaves the screen, and the corresponding elements in touches and targettouches are removed at the same time, and the changedtouches still has elements.
    • After your fingers have left the screen, there will be no more values in touches and targettouches, Changedtouches will also have a value that is the contact point of the last finger that left the screen.

The difference between touch-related variables touches,targettouches and changedtouches in

JS

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.