The issue:
..mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap.
(from a new defunct https://developers.google.com/mobile/articles/fast_buttons article)
touch-action
CSS property can be used to disable this behaviour.
touch-action: manipulation
The user agent may consider touches that begin on the element only for the purposes of scrolling and continuous zooming. Any additional behaviors supported by auto are out of scope for this specification.
– https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action#Values
touch-action
is now supported by all major mobile browsers.
Note that iOS 9.3 has not been released yet. (2016 02 13)
In ./webpack.js I am first detecting if the touch-action
property is supported. If it is, I am using it to set the style of document.body
. If it is not, then I am using webpack require.ensure
to download FastClick polyfill to fix the issue.
@simevidas
Personally, I like the explicit, declarative nature of having a rule in my styles that clearly states the browser's intended behavior, rather than relying on magical heuristics (even if they're becoming universal) like
width=device-width
. But you're correct that pragmatically, all main browsers are (finally, once iOS 9.3 is out) adopting this optimisation. Still, I'm hoping Firefox/Android (the last major player to drag its heels) will implement this soon.As a side note, on desktop/laptop devices with touchscreen, Microsoft Edge also has double-tap to zoom, and any viewport setting has no effect...so in this scenario,
touch-action
is the only reliable method of suppressing the click delay. Other browsers (Chrome, Firefox, ...) don't seem to (yet) have double-tap to zoom on these platforms...but if they decide to implement it, they'll likely also ignore viewport the same way. So one saving grace of using both mobile viewport andtouch-action
is the potential future-proofing for this case.