As we all know, the Click event on the phone will have a delay of 300ms problem. However, we need to cancel this delay when we do some small game on the mobile phone side.
The first step: Prohibit page zoom
- <Meta name="viewport" content= "width=device-width user-scalable= ' no '">
This piece of content can solve some of the problems of mobile phones
Step Two: fastclick.js
Fastclick is a lightweight library developed by FT Labs specifically to address the 300 millisecond Click Latency issue for mobile browsers. In short, when the Touchend event is detected, Fastclick immediately triggers a simulated click event via DOM custom events and blocks the browser from the Click event that was actually triggered after 300 milliseconds. Use the following method.
1: Introduce the Fastclick.js file in the page.
2: Add the following code to the JS file
After the window load event, the body is raised with Fastclick.attach ().
Window.addeventlistener (function () {
Fastclick.attach (document.body);
},false);
If you are using a jquery plugin
$ (function () {
Fastclick.attach (document.body);
});
I use the code here.
<script src= "Js/fastclick.js" ></script>
Handling Mobile Click Latency
if (' AddEventListener ' in document) {
Document.addeventlistener (' domcontentloaded ', function () {
Fastclick.attach (document.body);
}, False);
}
js-Resolving latency issues for mobile-click events