mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Update FastClick
This commit is contained in:
parent
465a172025
commit
3fd686a92e
1 changed files with 33 additions and 2 deletions
35
assets/javascripts/vendor/fastclick.js
vendored
35
assets/javascripts/vendor/fastclick.js
vendored
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
|
* @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
|
||||||
*
|
*
|
||||||
* @version 1.0.2
|
* @version 1.0.3
|
||||||
* @codingstandard ftlabs-jsv2
|
* @codingstandard ftlabs-jsv2
|
||||||
* @copyright The Financial Times Limited [All Rights Reserved]
|
* @copyright The Financial Times Limited [All Rights Reserved]
|
||||||
* @license MIT License (see LICENSE.txt)
|
* @license MIT License (see LICENSE.txt)
|
||||||
|
@ -197,6 +197,12 @@ var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);
|
||||||
*/
|
*/
|
||||||
var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent);
|
var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BlackBerry requires exceptions.
|
||||||
|
*
|
||||||
|
* @type boolean
|
||||||
|
*/
|
||||||
|
var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a given element requires a native click.
|
* Determine whether a given element requires a native click.
|
||||||
|
@ -401,7 +407,10 @@ FastClick.prototype.onTouchStart = function(event) {
|
||||||
// with the same identifier as the touch event that previously triggered the click that triggered the alert.
|
// with the same identifier as the touch event that previously triggered the click that triggered the alert.
|
||||||
// Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
|
// Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
|
||||||
// immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
|
// immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
|
||||||
if (touch.identifier === this.lastTouchIdentifier) {
|
// Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
|
||||||
|
// which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
|
||||||
|
// random integers, it's safe to to continue if the identifier is 0 here.
|
||||||
|
if (touch.identifier && touch.identifier === this.lastTouchIdentifier) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -723,6 +732,7 @@ FastClick.notNeeded = function(layer) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var metaViewport;
|
var metaViewport;
|
||||||
var chromeVersion;
|
var chromeVersion;
|
||||||
|
var blackberryVersion;
|
||||||
|
|
||||||
// Devices that don't support touch don't need FastClick
|
// Devices that don't support touch don't need FastClick
|
||||||
if (typeof window.ontouchstart === 'undefined') {
|
if (typeof window.ontouchstart === 'undefined') {
|
||||||
|
@ -754,6 +764,27 @@ FastClick.notNeeded = function(layer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deviceIsBlackBerry10) {
|
||||||
|
blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/);
|
||||||
|
|
||||||
|
// BlackBerry 10.3+ does not require Fastclick library.
|
||||||
|
// https://github.com/ftlabs/fastclick/issues/251
|
||||||
|
if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {
|
||||||
|
metaViewport = document.querySelector('meta[name=viewport]');
|
||||||
|
|
||||||
|
if (metaViewport) {
|
||||||
|
// user-scalable=no eliminates click delay.
|
||||||
|
if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// width=device-width (or less than device-width) eliminates click delay.
|
||||||
|
if (document.documentElement.scrollWidth <= window.outerWidth) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// IE10 with -ms-touch-action: none, which disables double-tap-to-zoom (issue #97)
|
// IE10 with -ms-touch-action: none, which disables double-tap-to-zoom (issue #97)
|
||||||
if (layer.style.msTouchAction === 'none') {
|
if (layer.style.msTouchAction === 'none') {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue