History

Update FastClick

Thibaut committed 12 years ago

Commit 3fd686a1 parent 465a1721 file · +33 −2Browse files

Unified · Split

assets/javascripts/vendor/fastclick.js+33−2
@@ -1,7 +1,7 @@
11 /**
22 * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
33 *
4− * @version 1.0.2
4+ * @version 1.0.3
55 * @codingstandard ftlabs-jsv2
66 * @copyright The Financial Times Limited [All Rights Reserved]
77 * @license MIT License (see LICENSE.txt)
@@ -197,6 +197,12 @@ var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent); · 189 unmodified lines
197197 */
198198 var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent);
199199
200+/**
201+ * BlackBerry requires exceptions.
202+ *
203+ * @type boolean
204+ */
205+var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0;
200206
201207 /**
202208 * Determine whether a given element requires a native click.
@@ -401,7 +407,10 @@ FastClick.prototype.onTouchStart = function(event) { · 198 unmodified lines
401407 // with the same identifier as the touch event that previously triggered the click that triggered the alert.
402408 // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
403409 // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
404− if (touch.identifier === this.lastTouchIdentifier) {
410+ // Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
411+ // which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
412+ // random integers, it's safe to to continue if the identifier is 0 here.
413+ if (touch.identifier && touch.identifier === this.lastTouchIdentifier) {
405414 event.preventDefault();
406415 return false;
407416 }
@@ -723,6 +732,7 @@ FastClick.notNeeded = function(layer) { · 315 unmodified lines
723732 'use strict';
724733 var metaViewport;
725734 var chromeVersion;
735+ var blackberryVersion;
726736
727737 // Devices that don't support touch don't need FastClick
728738 if (typeof window.ontouchstart === 'undefined') {
@@ -754,6 +764,27 @@ FastClick.notNeeded = function(layer) { · 25 unmodified lines
754764 }
755765 }
756766
767+ if (deviceIsBlackBerry10) {
768+ blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/);
769+
770+ // BlackBerry 10.3+ does not require Fastclick library.
771+ // https://github.com/ftlabs/fastclick/issues/251
772+ if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {
773+ metaViewport = document.querySelector('meta[name=viewport]');
774+
775+ if (metaViewport) {
776+ // user-scalable=no eliminates click delay.
777+ if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
778+ return true;
779+ }
780+ // width=device-width (or less than device-width) eliminates click delay.
781+ if (document.documentElement.scrollWidth <= window.outerWidth) {
782+ return true;
783+ }
784+ }
785+ }
786+ }
787+
757788 // IE10 with -ms-touch-action: none, which disables double-tap-to-zoom (issue #97)
758789 if (layer.style.msTouchAction === 'none') {
759790 return true;