Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Leverage touch-action whenever possible #499

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

RByers
Copy link

@RByers RByers commented Sep 1, 2016

If the browser supports touch-action then disable the tap delay explicitly by disabling the double-tap-to-zoom gesture and not installing touch listeners at all.

Setting touch-action to manipulation on an element (when not already set to something else) has no other impact than disabling double-tap (which normal FastClick code does anyway), so there shouldn't be much (any?) downside to this approach. It has several advantages to the existing behavior:

  • doesn't require the author to know they need to explicitly opt-in to touch-action
  • avoids the potential scroll performance impact of installing non-passive touch listeners
  • doesn't disable browser-defined tap recognition features such as touch adjustment (small target handling), tap suppression (don't click on a tap during a fling), system-defined slop regions (eg. different Android devices can have different configurations for how much movement is permitted for a 'tap').

Fixes #498

@RByers
Copy link
Author

RByers commented Sep 1, 2016

Note that I haven't tested this yet - just wanted to propose a simple possible fix.

If the page author has set an explicit `touch-action` on the layer via CSS (eg. `pan-y` for an image carousel), then don't override that.
@calebfaruki
Copy link

This fix worked to resolve a bug I was experiencing with iOS Safari 9.1 and above, since the 350ms delay was removed.

https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_9_1.html#//apple_ref/doc/uid/TP40014305-CH10-SW8

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants