fix(tap): cancel simulated click w/ hold events

Gesture hold event and ionic’s tap will both fire since the tap has no
strict duration between its start and end (a click will always fire no
matter how long the press is held). If a hold event fires from
ionic.Gesture, then the simulated click which would fire on
touchend/mouseup should be canceled.
This commit is contained in:
Adam Bradley
2014-06-09 22:00:35 -05:00
parent a8af748af6
commit f5bb023ef7
2 changed files with 9 additions and 1 deletions

View File

@@ -1030,6 +1030,7 @@
// we trigger the hold event
this.timer = setTimeout(function() {
if(ionic.Gestures.detection.current.name == 'hold') {
ionic.tap.cancelClick();
inst.trigger('hold', ev);
}
}, inst.options.hold_timeout);
@@ -1088,8 +1089,9 @@
// do a single tap
if(!did_doubletap || inst.options.tap_always) {
ionic.tap.cancelClick();
ionic.Gestures.detection.current.name = 'tap';
inst.trigger(ionic.Gestures.detection.current.name, ev);
inst.trigger('tap', ev);
}
}
}

View File

@@ -239,6 +239,12 @@ ionic.tap = {
setTolerance: function(releaseTolerance, releaseButtonTolerance) {
TAP_RELEASE_TOLERANCE = releaseTolerance;
TAP_RELEASE_BUTTON_TOLERANCE = releaseButtonTolerance;
},
cancelClick: function() {
// used to cancel any simulated clicks which may happen on a touchend/mouseup
// gestures uses this method within its tap and hold events
tapPointerMoved = true;
}
};