Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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