From 93cc9981fc4cc556051c7eadf19c98bcc688bdc1 Mon Sep 17 00:00:00 2001 From: Rick Byers Date: Wed, 31 Aug 2016 22:38:45 -0400 Subject: [PATCH 1/2] Leverage touch-action whenever possible Fixes #498 --- lib/fastclick.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/fastclick.js b/lib/fastclick.js index 3af4f9d6..4eaf2fd7 100644 --- a/lib/fastclick.js +++ b/lib/fastclick.js @@ -789,7 +789,7 @@ } // IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97) - if (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') { + if (layer.style.msTouchAction === 'none' || layer.style.msTouchAction === 'manipulation') { return true; } @@ -805,9 +805,13 @@ } } - // IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version - // http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx - if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') { + // Browsers that support touch-action can just use that to disable double-tap. + // https://developers.google.com/web/updates/2013/12/300ms-tap-delay-gone-away?hl=en + if ('touchAction' in layer.style) { + // Only 'auto' (the default) has double-tap enabled + if (layer.style.touchAction === '' || layer.style.touchAction === 'auto') { + layer.style.touchAction = 'manipulation'; + } return true; } From 77681c878068444e0af26efa565ba7ebeb752951 Mon Sep 17 00:00:00 2001 From: Rick Byers Date: Wed, 31 Aug 2016 22:53:27 -0400 Subject: [PATCH 2/2] Use getComputedStyle for touch-action detection 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. --- lib/fastclick.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fastclick.js b/lib/fastclick.js index 4eaf2fd7..16c0f89c 100644 --- a/lib/fastclick.js +++ b/lib/fastclick.js @@ -808,8 +808,8 @@ // Browsers that support touch-action can just use that to disable double-tap. // https://developers.google.com/web/updates/2013/12/300ms-tap-delay-gone-away?hl=en if ('touchAction' in layer.style) { - // Only 'auto' (the default) has double-tap enabled - if (layer.style.touchAction === '' || layer.style.touchAction === 'auto') { + // Only 'auto' (the default) has double-tap enabled. + if (getComputedStyle(layer).touchAction === 'auto') { layer.style.touchAction = 'manipulation'; } return true;