Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova adds 350ms delay on click() events in iOS

If I use something like $('button').click(function() { alert('hi'); } and I add the following to my <head>:

<meta name="viewport" content="user-scalable=no, width=device-width">

..and I run it as a normal mobile site on iOS 11, there is no delay (=> expected behaviour).

However, if I run the exact same code in a compiled Cordova hybrid app on iOS, the delay is back! (=> not good)

Do I have to start using fastclick.js or some other workaround again like it's 2013? What about other Cordova developers on here: do you experience the same problem?

PS: It works fine on Android.

PPS: Adding touch-action: manipulation; in CSS doesn't help unfortunately

like image 232
Tonald Drump Avatar asked Mar 16 '18 14:03

Tonald Drump


2 Answers

About the fastclick issue, apparently, it's a new bug introduced with iOs 11.3.

Here is the full explanation

And here is a fork which resolves the fastclick issue with iOs 11.3

I'm also looking for a workaround, since fastclick doesn't look to be maintained anymore...

like image 122
Romain Le Qllc Avatar answered Oct 21 '22 01:10

Romain Le Qllc


We experience the exact same problem.

Using FastClick as a workaround works for most iOS versions, except for the latest iOS release: 11.3. After a fresh start of a Cordova app, FastClick works as expected but after a while (especially when calling native iOS calls like taking a photo), it shows weird behaviour where your input fields (nested in other divs) do not get selected at all and you have to tap multiple times to select an input field.

I have no clue why the 350ms delay is still active for (Cordova) apps and not for a standard mobile website opened in Safari.

Thanks to the tip from Romain Le Qllc, I replaced fastclick with the fork that he mentioned (https://github.com/lasselaakkonen/fastclick). This resolves the issues in both iOS 11.3 and 11.4.

Also big thanks to lasselaakkonen.

like image 41
pj3s Avatar answered Oct 21 '22 00:10

pj3s