fix(scroll): larger release tolerance for buttons

Closes #1378
This commit is contained in:
Adam Bradley
2014-05-14 13:08:19 -05:00
parent cb0d17c065
commit fab4a41d9a

View File

@@ -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) {