From fab4a41d9a9864094dce70de04c2e4b0dc56ea59 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Wed, 14 May 2014 13:08:19 -0500 Subject: [PATCH] fix(scroll): larger release tolerance for buttons Closes #1378 --- js/utils/tap.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/js/utils/tap.js b/js/utils/tap.js index 022747aebd9..11fbf35930d 100644 --- a/js/utils/tap.js +++ b/js/utils/tap.js @@ -78,7 +78,9 @@ var tapTouchFocusedInput; var tapLastTouchTarget; var tapTouchMoveListener = 'touchmove'; -var TAP_RELEASE_TOLERANCE = 6; // how much the coordinates can be off between start/end, but still a click +// how much the coordinates can be off between start/end, but still a click +var TAP_RELEASE_TOLERANCE = 6; // default tolerance +var TAP_RELEASE_BUTTON_TOLERANCE = 50; // button elements should have a larger tolerance var tapEventListeners = { 'click': tapClickGateKeeper, @@ -234,8 +236,9 @@ ionic.tap = { return false; }, - setTolerance: function(val) { - TAP_RELEASE_TOLERANCE = val; + setTolerance: function(releaseTolerance, releaseButtonTolerance) { + TAP_RELEASE_TOLERANCE = releaseTolerance; + TAP_RELEASE_BUTTON_TOLERANCE = releaseButtonTolerance; } }; @@ -502,8 +505,10 @@ function tapHasPointerMoved(endEvent) { } var endCoordinates = getPointerCoordinates(endEvent); - return Math.abs(tapPointerStart.x - endCoordinates.x) > TAP_RELEASE_TOLERANCE || - Math.abs(tapPointerStart.y - endCoordinates.y) > TAP_RELEASE_TOLERANCE; + var releaseTolerance = (endEvent.target.classList.contains('button') ? TAP_RELEASE_BUTTON_TOLERANCE : TAP_RELEASE_TOLERANCE); + + return Math.abs(tapPointerStart.x - endCoordinates.x) > releaseTolerance || + Math.abs(tapPointerStart.y - endCoordinates.y) > releaseTolerance; } function getPointerCoordinates(event) {