Skip to content

Commit

Permalink
ignore the same event if it's already been processed
Browse files Browse the repository at this point in the history
(this typically happens on the crosshair mark which uses the same shared pointer transform on its submarks)

closes #2052
  • Loading branch information
Fil committed Jan 3, 2025
1 parent 7d18179 commit 3099083
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/interactions/pointer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 3099083

Please sign in to comment.