Mobile-click event delay

Source: Internet
Author: User

Using the Click event on the mobile side produces a 300ms delay

The problem arises:

Mobile has double-click to enlarge the problem, so when the mobile click event occurs, in order to determine the user's behavior (in the end to double-click or to click), the browser will usually wait for 300ms, if the user does not click again within 300ms, it is decided to click the event, otherwise decided to double-click Zoom.

Why to solve:

The extreme pursuit of performance by the online web, and the high standard of user experience, make the 300ms lag more difficult to accept

How to resolve:

1, User-scalable:no prohibit scaling--no scaling there is no double click, there is no click Delay

2, pointer event: Css:-ms-touch-action:none After clicking the browser does not enable the zoom operation, there is no delay. However, this approach is not very compatible.

3. Fastclick Library: A lightweight library developed for this issue. Fastclick after detecting the Touchend event, a simulated click event is immediately triggered and the true click event is blocked after 300ms

Usage:

1 window.addeventlistener ("load",function() {2Fastclick.attach ( document.body); 3 }); 4 // while binding to a more specific element, binding to the body can benefit the entire application .

When Fastclick detects that a user-scalable:no or Touch-action:none scheme is used in the page, it exits silently. Great!

Mobile-click event delay

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.