Skip to content

Commit

Permalink
fix(scroll): larger release tolerance for buttons
Browse files Browse the repository at this point in the history
Closes #1378
  • Loading branch information
adamdbradley committed May 14, 2014
1 parent cb0d17c commit fab4a41
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions js/utils/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

};
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit fab4a41

Please sign in to comment.