From cd37e8b4fd4325e557dd07ae35c145a690e10876 Mon Sep 17 00:00:00 2001 From: wangzilong03 Date: Fri, 4 Aug 2017 11:41:53 +0800 Subject: [PATCH] Feature: Change default option values tapDelay => 30 tapTimeout => 100 touchBoundary => 30 And make focusDelay configurable --- lib/fastclick.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/fastclick.js b/lib/fastclick.js index 3af4f9d6..cac64cdc 100644 --- a/lib/fastclick.js +++ b/lib/fastclick.js @@ -78,7 +78,7 @@ * * @type number */ - this.touchBoundary = options.touchBoundary || 10; + this.touchBoundary = options.touchBoundary || 30; /** @@ -93,14 +93,21 @@ * * @type number */ - this.tapDelay = options.tapDelay || 200; + this.tapDelay = options.tapDelay || 30; /** * The maximum time for a tap * * @type number */ - this.tapTimeout = options.tapTimeout || 700; + this.tapTimeout = options.tapTimeout || 1000; + + /** + * Them minimum tap time for element that needs focus + * + * @type number + */ + this.focusDelay = options.focusDelay || 100; if (FastClick.notNeeded(layer)) { return; @@ -571,7 +578,8 @@ // Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through. // Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37). - if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) { + // The default value for this.focusDelay is 100ms. + if ((event.timeStamp - trackingClickStart) > this.focusDelay || (deviceIsIOS && window.top !== window && targetTagName === 'input')) { this.targetElement = null; return false; }