From 3099083e39c9131264108ad8c81201048e3ba755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Rivi=C3=A8re?= Date: Fri, 3 Jan 2025 15:06:48 +0100 Subject: [PATCH] ignore the same event if it's already been processed (this typically happens on the crosshair mark which uses the same shared pointer transform on its submarks) closes #2052 --- src/interactions/pointer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/interactions/pointer.js b/src/interactions/pointer.js index f0c0f765b0..c75b0a7c26 100644 --- a/src/interactions/pointer.js +++ b/src/interactions/pointer.js @@ -4,6 +4,7 @@ import {isArray} from "../options.js"; import {applyFrameAnchor} from "../style.js"; const states = new WeakMap(); +const processedEvents = new WeakSet(); function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...options} = {}) { maxRadius = +maxRadius; @@ -162,12 +163,13 @@ function pointerK(kx, ky, {x, y, px, py, maxRadius = 40, channels, render, ...op } function pointerdown(event) { + if (processedEvents.has(event)) return; // ignore same event on a shared pointer + processedEvents.add(event); if (event.pointerType !== "mouse") return; if (i == null) return; // not pointing if (state.sticky && state.roots.some((r) => r?.contains(event.target))) return; // stay sticky if (state.sticky) (state.sticky = false), state.renders.forEach((r) => r(null)); // clear all pointers else (state.sticky = true), render(i); - event.stopImmediatePropagation(); // suppress other pointers } function pointerleave(event) {