Unified · Split
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | /** |
| 2 | 2 | * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs. |
| 3 | 3 | * |
| 4 | − * @version 1.0.2 | |
| 4 | + * @version 1.0.3 | |
| 5 | 5 | * @codingstandard ftlabs-jsv2 |
| 6 | 6 | * @copyright The Financial Times Limited [All Rights Reserved] |
| 7 | 7 | * @license MIT License (see LICENSE.txt) |
| @@ -197,6 +197,12 @@ var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent); · 189 unmodified lines | ||
| 197 | 197 | */ |
| 198 | 198 | var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent); |
| 199 | 199 | |
| 200 | +/** | |
| 201 | + * BlackBerry requires exceptions. | |
| 202 | + * | |
| 203 | + * @type boolean | |
| 204 | + */ | |
| 205 | +var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0; | |
| 200 | 206 | |
| 201 | 207 | /** |
| 202 | 208 | * Determine whether a given element requires a native click. |
| @@ -401,7 +407,10 @@ FastClick.prototype.onTouchStart = function(event) { · 198 unmodified lines | ||
| 401 | 407 | // with the same identifier as the touch event that previously triggered the click that triggered the alert. |
| 402 | 408 | // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an |
| 403 | 409 | // 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) { | |
| 405 | 414 | event.preventDefault(); |
| 406 | 415 | return false; |
| 407 | 416 | } |
| @@ -723,6 +732,7 @@ FastClick.notNeeded = function(layer) { · 315 unmodified lines | ||
| 723 | 732 | 'use strict'; |
| 724 | 733 | var metaViewport; |
| 725 | 734 | var chromeVersion; |
| 735 | + var blackberryVersion; | |
| 726 | 736 | |
| 727 | 737 | // Devices that don't support touch don't need FastClick |
| 728 | 738 | if (typeof window.ontouchstart === 'undefined') { |
| @@ -754,6 +764,27 @@ FastClick.notNeeded = function(layer) { · 25 unmodified lines | ||
| 754 | 764 | } |
| 755 | 765 | } |
| 756 | 766 | |
| 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 | + | |
| 757 | 788 | // IE10 with -ms-touch-action: none, which disables double-tap-to-zoom (issue #97) |
| 758 | 789 | if (layer.style.msTouchAction === 'none') { |
| 759 | 790 | return true; |