aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-06-07 13:42:44 -0400
committerbobzel <zzzman@gmail.com>2022-06-07 13:42:44 -0400
commit1809276483fb29e734b04c351152f796528e4ec1 (patch)
treef5fe8737234d08a9f612bf5e82dcb04573b89c45
parent69fbc57e813b55963911629dba552f633928d10b (diff)
added a click event suppressor to setupMoveUpEvents
-rw-r--r--src/Utils.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index 4dd9979ea..b87980397 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -677,6 +677,8 @@ export function StopEvent(e: React.PointerEvent | React.MouseEvent) {
e.preventDefault();
}
+
+
export function setupMoveUpEvents(
target: object,
e: React.PointerEvent,
@@ -692,6 +694,7 @@ export function setupMoveUpEvents(
(target as any)._lastTap = Date.now();
(target as any)._downX = (target as any)._lastX = e.clientX;
(target as any)._downY = (target as any)._lastY = e.clientY;
+ (target as any)._noClick = false;
const _moveEvent = (e: PointerEvent): void => {
if (Math.abs(e.clientX - (target as any)._downX) > Utils.DRAG_THRESHOLD || Math.abs(e.clientY - (target as any)._downY) > Utils.DRAG_THRESHOLD) {
@@ -723,17 +726,20 @@ export function setupMoveUpEvents(
clearTimeout((target as any)._doubleTime);
(target as any)._doubleTime = undefined;
}
- clickEvent(e, (target as any)._doubleTap);
+ (target as any)._noClick = clickEvent(e, (target as any)._doubleTap);
}
document.removeEventListener("pointermove", _moveEvent);
document.removeEventListener("pointerup", _upEvent);
};
+ const _clickEvent = (e: MouseEvent): void => {
+ if ((target as any)._noClick) e.stopPropagation();
+ document.removeEventListener("click", _clickEvent, true);
+ }
if (stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
- document.removeEventListener("pointermove", _moveEvent);
- document.removeEventListener("pointerup", _upEvent);
document.addEventListener("pointermove", _moveEvent);
document.addEventListener("pointerup", _upEvent);
+ document.addEventListener("click", _clickEvent, true);
} \ No newline at end of file