Skip to content

Commit f5bb023

Browse files
author
Adam Bradley
committed
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.
1 parent a8af748 commit f5bb023

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Diff for: js/utils/gestures.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,7 @@
10301030
// we trigger the hold event
10311031
this.timer = setTimeout(function() {
10321032
if(ionic.Gestures.detection.current.name == 'hold') {
1033+
ionic.tap.cancelClick();
10331034
inst.trigger('hold', ev);
10341035
}
10351036
}, inst.options.hold_timeout);
@@ -1088,8 +1089,9 @@
10881089

10891090
// do a single tap
10901091
if(!did_doubletap || inst.options.tap_always) {
1092+
ionic.tap.cancelClick();
10911093
ionic.Gestures.detection.current.name = 'tap';
1092-
inst.trigger(ionic.Gestures.detection.current.name, ev);
1094+
inst.trigger('tap', ev);
10931095
}
10941096
}
10951097
}

Diff for: js/utils/tap.js

+6
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ ionic.tap = {
239239
setTolerance: function(releaseTolerance, releaseButtonTolerance) {
240240
TAP_RELEASE_TOLERANCE = releaseTolerance;
241241
TAP_RELEASE_BUTTON_TOLERANCE = releaseButtonTolerance;
242+
},
243+
244+
cancelClick: function() {
245+
// used to cancel any simulated clicks which may happen on a touchend/mouseup
246+
// gestures uses this method within its tap and hold events
247+
tapPointerMoved = true;
242248
}
243249

244250
};

0 commit comments

Comments
 (0)