Skip to content

Commit fab4a41

Browse files
committed
fix(scroll): larger release tolerance for buttons
Closes #1378
1 parent cb0d17c commit fab4a41

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

js/utils/tap.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ var tapTouchFocusedInput;
7878
var tapLastTouchTarget;
7979
var tapTouchMoveListener = 'touchmove';
8080

81-
var TAP_RELEASE_TOLERANCE = 6; // how much the coordinates can be off between start/end, but still a click
81+
// how much the coordinates can be off between start/end, but still a click
82+
var TAP_RELEASE_TOLERANCE = 6; // default tolerance
83+
var TAP_RELEASE_BUTTON_TOLERANCE = 50; // button elements should have a larger tolerance
8284

8385
var tapEventListeners = {
8486
'click': tapClickGateKeeper,
@@ -234,8 +236,9 @@ ionic.tap = {
234236
return false;
235237
},
236238

237-
setTolerance: function(val) {
238-
TAP_RELEASE_TOLERANCE = val;
239+
setTolerance: function(releaseTolerance, releaseButtonTolerance) {
240+
TAP_RELEASE_TOLERANCE = releaseTolerance;
241+
TAP_RELEASE_BUTTON_TOLERANCE = releaseButtonTolerance;
239242
}
240243

241244
};
@@ -502,8 +505,10 @@ function tapHasPointerMoved(endEvent) {
502505
}
503506
var endCoordinates = getPointerCoordinates(endEvent);
504507

505-
return Math.abs(tapPointerStart.x - endCoordinates.x) > TAP_RELEASE_TOLERANCE ||
506-
Math.abs(tapPointerStart.y - endCoordinates.y) > TAP_RELEASE_TOLERANCE;
508+
var releaseTolerance = (endEvent.target.classList.contains('button') ? TAP_RELEASE_BUTTON_TOLERANCE : TAP_RELEASE_TOLERANCE);
509+
510+
return Math.abs(tapPointerStart.x - endCoordinates.x) > releaseTolerance ||
511+
Math.abs(tapPointerStart.y - endCoordinates.y) > releaseTolerance;
507512
}
508513

509514
function getPointerCoordinates(event) {

0 commit comments

Comments
 (0)