Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecated touch operations on mobile apps

In past mobile apps that I developed, I found that the click event did not work as expected in all devices (for example: in games in which the user had to tap/click quickly on the screen, instead of triggering the click event, the double click was triggered), and using touchstart gave better results for what I wanted.

Since then, I started listening to the touchstart event instead of click; but testing on Chrome, I got the following warning message in the JS console:

Performing operations that require explicit user interaction on touchstart events is deprecated and will be removed in M54, around October 2016. See https://www.chromestatus.com/features/5649871251963904 for more details.

I visited the linked page (and the links inside it) and it seems that this new behavior is to avoid certain unwanted actions, and in particular to avoid third-party iframes or ads (my app has none) from opening pop-ups. I tried changing the event to touchend (as one of the links stated "The touchend event will continue to behave as before"), but got a similar warning message.

And my questions:

  • Is this something that only affects Chrome, or will it affect my web apps (with Cordova/Phonegap) for Android and iOS?
  • What event should I use to replace touchstart and avoid the issues I faced in the past? I could go back to click, but fast clicking/tapping would still be a problem.
like image 443
Alvaro Montoro Avatar asked Sep 06 '16 13:09

Alvaro Montoro


1 Answers

When creating Cordova app, you target different OS versions, Android 5 and up has auto updating webview based on Chromium, so that problem will probably affect your apps.

But since Chrome 32, when using this viewport <meta name="viewport" content="width=device-width">, the click delay should go away (see this article), so you could safely use click event. Latest webviews on android 5 and 6 are based on Chromium 52.

You can also use fastclick library that will "fix" the click delay only where it's necessary

like image 75
jcesarmobile Avatar answered Nov 12 '22 10:11

jcesarmobile