mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user