Mobile end Web development, CLICK,TOUCH,TAP events

Source: Internet
Author: User

1. Click and Tap Events Comparison

Both will have a click on the trigger, but on the phone web side, click will have a 200~300ms delay, so use Zepto tap instead of click as a click event

Singletap and Doubletap Click on the events and double-click the events on each side.

2. Point-through processing of tap events

(1) When using the Zepto frame tap as a mobile device browser Click event to circumvent the Click event Delay response, it is possible to have a point through the situation, that is, click will trigger the non-current level of click events, and Delivery events.

Treatment mode:

Using the Fastclick library Https://github.com/ftlabs/fastclick

Introduce the Fastclick library and add:

$ (function () {

New Fastclick (document.body);

});

Then give the "no delay click" element to bind the Click event, note that the tap event is no longer bound zepto

Of course, you can no longer initialize it on the body, but initialize it on a DOM, so that only this dom and its child elements can enjoy a click without delay.

When the element is bound Fastclick, the click Response speed is faster than the tap. (There is no click event that triggers the DOM, the new event supports bubbling events, and, if it is click, implicitly invokes the declared method)

(2) Bind the Touchend event for the element and add the E.preventdefault () method internally

$el. On (' Touchend ', function (e) {

E.preventdefault ();

Do some thing

});

3, Touch incident touch is for touchscreen phone contact screen events

Touchstart: When the finger touches the screen it triggers

Touchmove: Triggers when the finger moves on the screen

Touchend: Triggers when the finger leaves the screen

Touchcancel:: When the finger has not left the screen, there is a system operation.

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.