Reference settings for JS touch events

Source: Internet
Author: User

At the beginning of the front page, the contact is JS, but then the simple and efficient jquery was attracted to the past, and has been used so far.

And JS, it is my subjective thinking of the underlying technology and abandoned.

Until a few days of work, the search for touch-screen sliding events on a mobile page, the corresponding technical support for jquery is tedious (and probably not enough for my understanding of jquery), and JS can be defined in just a few simple steps.

Because of the less understanding of JS, the simplest application I have tried for a long time ... Here's a real reference to the next JS Touch event:

1 $ (function() {2     false); 3 })45function  _touch (event) {6     alert (1); 7 }

The above code inevitably uses some of jquery's things, not the use of jquery can be ignored.

The corresponding events are:

Touchstart: Triggered when the finger touches the screen, even if a finger has been placed on the screen.

Touchmove: A continuous trigger when the finger is sliding on the screen. During this event, calling Preventdefault () can prevent scrolling. Touchend: Triggered when the finger moves away from the screen. Touchcancel: Triggered when the system stops tracking touch. The exact trigger event for this event is not explicitly stated in the documentation.the event object above has the following properties:Touches: Represents an array of touch objects that are currently tracked by touching operations. Targettouches: An array of touch objects that are specific to the event target. Changetouches: An array of touch objects that represent what has changed since the last touch.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 DOM node coordinates of the touch OK, I actually just started to learn, anyway, some of the attributes of Baidu to write down to say.

Reference settings for JS touch 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.