Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-5980: drag blank board area with the left button to pan horizontally (#6700)

Homyee King ホミイ9ba3a8bdf268
diff --git a/packages/views/issues/components/board-card.tsx b/packages/views/issues/components/board-card.tsx
index 5bffb35c0c..88ef7be1eb 100644
--- a/packages/views/issues/components/board-card.tsx
+++ b/packages/views/issues/components/board-card.tsx
@@ -347,6 +347,7 @@ export const DraggableBoardCard = memo(function DraggableBoardCard({
<div
ref={setNodeRef}
style={style}
+ data-board-card=""
{...attributes}
{...listeners}
className={`group/card ${isDragging ? "opacity-30" : ""}`}
diff --git a/packages/views/issues/components/board-view.tsx b/packages/views/issues/components/board-view.tsx
index fd502aebd3..611ead833b 100644
--- a/packages/views/issues/components/board-view.tsx
+++ b/packages/views/issues/components/board-view.tsx
@@ -43,6 +43,7 @@ import type {
IssueGroupPageState,
} from "../surface/use-issue-group-branches";
import { useDragSettle } from "./use-drag-settle";
+import { useBoardDragPan } from "./use-board-drag-pan";
import { useT } from "../../i18n";
import {
type DragMoveUpdates,
@@ -393,6 +394,10 @@ function BoardViewImpl({
})
);
+ // #6700: drag empty board background with the left button to pan horizontally
+ // (Trello/Linear). Card drags start on `[data-board-card]` and are ignored.
+ const pan = useBoardDragPan<HTMLDivElement>();
+
const handleDragStart = useCallback(
(event: DragStartEvent) => {
isDraggingRef.current = true;
@@ -556,7 +561,15 @@ function BoardViewImpl({
onDragOver={handleDragOver}
onDragEnd={handleDragEnd}
>
- <div className="flex flex-1 min-h-0 gap-4 overflow-x-auto p-2">
+ <div
+ ref={pan.ref}
+ onPointerDown={pan.onPointerDown}
+ onPointerMove={pan.onPointerMove}
+ onPointerUp={pan.onPointerUp}
+ onPointerCancel={pan.onPointerCancel}
+ onLostPointerCapture={pan.onLostPointerCapture}
+ className="flex flex-1 min-h-0 gap-4 overflow-x-auto p-2"
+ >
{groups.length === 0 ? (
groupBranches?.isError ? (
<button
diff --git a/packages/views/issues/components/use-board-drag-pan.test.tsx b/packages/views/issues/components/use-board-drag-pan.test.tsx
new file mode 100644
index 0000000000..938ba8d3be
--- /dev/null
+++ b/packages/views/issues/components/use-board-drag-pan.test.tsx
@@ -0,0 +1,346 @@
+/**
+ * @vitest-environment jsdom
+ */
+import { describe, it, expect, afterEach } from "vitest";
+import { render, cleanup, fireEvent } from "@testing-library/react";
+import { useBoardDragPan } from "./use-board-drag-pan";
+
+function Harness() {
+ const pan = useBoardDragPan<HTMLDivElement>();
+ return (
+ <div
+ data-testid="scroller"
+ ref={pan.ref}
+ onPointerDown={pan.onPointerDown}
+ onPointerMove={pan.onPointerMove}
+ onPointerUp={pan.onPointerUp}
+ onPointerCancel={pan.onPointerCancel}
+ onLostPointerCapture={pan.onLostPointerCapture}
+ >
+ <div data-testid="blank" style={{ width: 10, height: 10 }} />
+ <div data-board-card="" data-testid="card">
+ <span data-testid="card-child" />
+ </div>
+ <button data-testid="ctrl-button">b</button>
+ <label data-testid="ctrl-label">l</label>
+ <div role="link" data-testid="ctrl-rolelink">r</div>
+ </div>
+ );
+}
+
+// jsdom lacks pointer-capture methods and doesn't lay out; stub capture and a
+// scrollable range so the hook's clamp has room to move. Records capture calls.
+function stubCapture(el: HTMLElement, scrollWidth = 1000, clientWidth = 300) {
+ const captured: number[] = [];
+ const released: number[] = [];
+ el.setPointerCapture = (id: number) => void captured.push(id);
+ el.releasePointerCapture = (id: number) => void released.push(id);
+ Object.defineProperty(el, "scrollWidth", { value: scrollWidth, configurable: true });
+ Object.defineProperty(el, "clientWidth", { value: clientWidth, configurable: true });
+ return { captured, released };
+}
+
+function down(target: Element, x: number, button = 0, pointerType = "mouse") {
+ fireEvent.pointerDown(target, {
+ button,
+ clientX: x,
+ clientY: 50,
+ pointerId: 1,
+ pointerType,
+ });
+}
+// `buttons: 1` = left button held — the real browser value during a left drag.
+function move(target: Element, x: number, buttons = 1) {
+ fireEvent.pointerMove(target, {
+ clientX: x,
+ clientY: 50,
+ pointerId: 1,
+ pointerType: "mouse",
+ buttons,
+ });
+}
+function up(target: Element) {
+ fireEvent.pointerUp(target, {
+ clientX: 0,
+ clientY: 50,
+ pointerId: 1,
+ pointerType: "mouse",
+ });
+}
+
+describe("useBoardDragPan", () => {
+ afterEach(cleanup);
+
+ it("pans horizontally on a left drag from blank background (real event order)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ stubCapture(el);
+ el.scrollLeft = 100;
+
+ // pointerdown → move past 5px threshold → follow cursor → up
+ down(getByTestId("blank"), 200);
+ move(el, 208); // 8px > threshold: activates; delta from last (200) = 8
+ expect(el.scrollLeft).toBe(92); // 100 - 8
+ move(el, 188); // moved right 20 -> scroll left
+ expect(el.scrollLeft).toBe(112);
+
+ up(el);
+ move(el, 400); // after release: ignored
+ expect(el.scrollLeft).toBe(112);
+ });
+
+ it("does not activate before the ~5px threshold (plain click)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ stubCapture(el);
+ el.scrollLeft = 50;
+
+ down(getByTestId("blank"), 200);
+ move(el, 203); // 3px < 5px threshold
+ expect(el.scrollLeft).toBe(50);
+ });
+
+ it("ignores drags that start on a card so only dnd-kit runs (P2-5 invariant)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ const { captured } = stubCapture(el);
+ el.scrollLeft = 30;
+
+ down(getByTestId("card-child"), 200); // starts inside [data-board-card]
+ move(el, 260);
+ expect(el.scrollLeft).toBe(30); // never panned, card sorting untouched
+ // The pan hook must not claim the pointer for a card-origin gesture, or it
+ // would steal the drag from dnd-kit.
+ expect(captured).toEqual([]);
+ expect(el.style.userSelect).toBe(""); // no selection suppression either
+ });
+
+ it("ignores drags that start on interactive controls (label, role=link, button)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ stubCapture(el);
+
+ for (const id of ["ctrl-button", "ctrl-label", "ctrl-rolelink"]) {
+ el.scrollLeft = 30;
+ down(getByTestId(id), 200);
+ move(el, 260);
+ expect(el.scrollLeft).toBe(30);
+ }
+ });
+
+ it("ignores the right button entirely (context menu path untouched)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ stubCapture(el);
+ el.scrollLeft = 40;
+
+ down(getByTestId("blank"), 200, 2); // right button
+ move(el, 260, 2);
+ expect(el.scrollLeft).toBe(40);
+ });
+
+ it("does not stay stuck when the release event is lost", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ stubCapture(el);
+ el.scrollLeft = 100;
+
+ down(getByTestId("blank"), 200);
+ move(el, 220); // activates, pans
+ expect(el.scrollLeft).toBe(80);
+
+ // Release happened off-window: no pointerup fired. Next move reports the
+ // button no longer held (buttons === 0) and must NOT keep panning.
+ move(el, 400, 0);
+ expect(el.scrollLeft).toBe(80);
+ move(el, 500, 0);
+ expect(el.scrollLeft).toBe(80);
+ });
+
+ it("only reads the horizontal axis (scrollTop untouched)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ stubCapture(el);
+ el.scrollLeft = 50;
+ const topBefore = el.scrollTop;
+
+ down(getByTestId("blank"), 200);
+ move(el, 220); // activate
+ fireEvent.pointerMove(el, {
+ clientX: 220,
+ clientY: 400,
+ pointerId: 1,
+ pointerType: "mouse",
+ buttons: 1,
+ });
+ expect(el.scrollTop).toBe(topBefore);
+ });
+
+ it("clamps at the left edge without bouncing back (scrollLeft never goes negative)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ stubCapture(el);
+ el.scrollLeft = 10;
+
+ down(getByTestId("blank"), 100);
+ move(el, 110); // activate; delta 10 -> would be 0
+ expect(el.scrollLeft).toBe(0);
+ // Keep dragging in the same direction well past the edge: stays at 0, no
+ // negative overscroll that would spring back on the next frame.
+ move(el, 300);
+ expect(el.scrollLeft).toBe(0);
+ move(el, 500);
+ expect(el.scrollLeft).toBe(0);
+ });
+
+ it("clamps at the right edge (never exceeds scrollWidth - clientWidth)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller"); // max = 1000 - 300 = 700
+ stubCapture(el);
+ el.scrollLeft = 690;
+
+ down(getByTestId("blank"), 300);
+ move(el, 290); // drag left -> content moves right, scrollLeft += 10 -> 700
+ expect(el.scrollLeft).toBe(700);
+ move(el, 100); // further past the edge stays clamped
+ expect(el.scrollLeft).toBe(700);
+ });
+
+ it("suppresses text selection from pointerdown (P1-3) and restores it on release", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ stubCapture(el);
+ el.scrollLeft = 100;
+
+ down(getByTestId("blank"), 200);
+ // Suppressed immediately on down — NOT deferred to the 5px threshold.
+ expect(el.style.userSelect).toBe("none");
+ move(el, 220); // activate
+ expect(el.style.userSelect).toBe("none");
+
+ up(el);
+ expect(el.style.userSelect).toBe(""); // restored on release
+ });
+
+ it("vetoes selectstart / dragstart while a gesture is pending (P1-3)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ stubCapture(el);
+
+ // `selectstart` isn't in fireEvent's map; dispatch a real cancelable event
+ // and check whether the handler called preventDefault (dispatchEvent
+ // returns false when it did).
+ const fireSelectStart = () =>
+ el.dispatchEvent(new Event("selectstart", { bubbles: true, cancelable: true }));
+ const fireDragStart = () =>
+ el.dispatchEvent(new Event("dragstart", { bubbles: true, cancelable: true }));
+
+ // No gesture yet: events pass through untouched.
+ expect(fireSelectStart()).toBe(true);
+ expect(fireDragStart()).toBe(true);
+
+ down(getByTestId("blank"), 200);
+ // Gesture pending: both are prevented (dispatchEvent returns false when
+ // preventDefault was called).
+ expect(fireSelectStart()).toBe(false);
+ expect(fireDragStart()).toBe(false);
+
+ up(el);
+ expect(fireSelectStart()).toBe(true); // released after gesture end
+ });
+
+ it("does not set touch-action because touch/pen stay browser-owned", () => {
+ const { getByTestId } = render(<Harness />);
+ expect(getByTestId("scroller").style.touchAction).toBe("");
+ });
+
+ it("ignores touch and pen pointerdown entirely (mouse-only scope)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ const { captured } = stubCapture(el);
+ el.scrollLeft = 100;
+
+ const touchDown = fireEvent.pointerDown(getByTestId("blank"), {
+ button: 0,
+ clientX: 200,
+ clientY: 50,
+ pointerId: 11,
+ pointerType: "touch",
+ });
+ expect(touchDown).toBe(true);
+ expect(captured).toEqual([]);
+ expect(el.style.userSelect).toBe("");
+ fireEvent.pointerMove(el, {
+ clientX: 260,
+ clientY: 50,
+ pointerId: 11,
+ pointerType: "touch",
+ buttons: 1,
+ });
+ expect(el.scrollLeft).toBe(100);
+
+ const penDown = fireEvent.pointerDown(getByTestId("blank"), {
+ button: 0,
+ clientX: 200,
+ clientY: 50,
+ pointerId: 12,
+ pointerType: "pen",
+ });
+ expect(penDown).toBe(true);
+ expect(captured).toEqual([]);
+ expect(el.style.userSelect).toBe("");
+ fireEvent.pointerMove(el, {
+ clientX: 260,
+ clientY: 50,
+ pointerId: 12,
+ pointerType: "pen",
+ buttons: 1,
+ });
+ expect(el.scrollLeft).toBe(100);
+ });
+
+ it("captures the pointer on pointerdown (before any move) so exit can't lose it", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ const { captured, released } = stubCapture(el);
+
+ down(getByTestId("blank"), 200);
+ expect(captured).toEqual([1]); // captured immediately, not deferred to move
+
+ up(el);
+ expect(released).toEqual([1]); // released on gesture end
+ });
+
+ it("keeps panning after the pointer leaves the container (no scroll-back on exit)", () => {
+ const { getByTestId } = render(<Harness />);
+ const el = getByTestId("scroller");
+ stubCapture(el);
+ el.scrollLeft = 300;
+
+ down(getByTestId("blank"), 200);
+ move(el, 220); // activate; delta 20 -> 280
+
+ // Pointer moves outside the container bounds. Because it's captured on
+ // pointerdown, the events still target `el` and we keep following clientX.
+ // Nothing pulls scrollLeft back toward the start.
+ fireEvent.pointerMove(el, {
+ clientX: 260,
+ clientY: 5000,
+ pointerId: 1,
+ pointerType: "mouse",
+ buttons: 1,
+ });
+ expect(el.scrollLeft).toBe(240); // 280 - 40, monotonic follow, no bounce
+ fireEvent.pointerMove(el, {
+ clientX: 300,
+ clientY: 5000,
+ pointerId: 1,
+ pointerType: "mouse",
+ buttons: 1,
+ });
+ expect(el.scrollLeft).toBe(200); // 240 - 40, still following
+
+ up(el);
+ expect(el.scrollLeft).toBe(200); // stays put after release
+ });
+});
diff --git a/packages/views/issues/components/use-board-drag-pan.ts b/packages/views/issues/components/use-board-drag-pan.ts
new file mode 100644
index 0000000000..b817688b41
--- /dev/null
+++ b/packages/views/issues/components/use-board-drag-pan.ts
@@ -0,0 +1,219 @@
+import { useCallback, useEffect, useRef } from "react";
+
+/** Threshold (px) that distinguishes a click from a pan drag. Mirrors the
+ * board's dnd-kit PointerSensor `activationConstraint: { distance: 5 }` so a
+ * blank-area press and a card press feel identical up to the moment one is
+ * recognized as a drag. */
+const PAN_ACTIVATION_DISTANCE = 5;
+
+// Elements whose press must NOT start a board pan — they own their own pointer
+// semantics (dnd-kit cards, links, form controls, menus). A gesture starting
+// anywhere inside one of these is left untouched. Kept broad on purpose (P2-4):
+// besides the obvious controls it covers label/checkbox/radio, ARIA link/menu/
+// option roles, and elements that opt out via `data-no-board-pan`.
+const INTERACTIVE_SELECTOR = [
+ "[data-board-card]",
+ "[data-no-board-pan]",
+ "a",
+ "button",
+ "input",
+ "textarea",
+ "select",
+ "option",
+ "label",
+ "summary",
+ "[role='button']",
+ "[role='link']",
+ "[role='menuitem']",
+ "[role='option']",
+ "[role='checkbox']",
+ "[role='radio']",
+ "[role='tab']",
+ "[role='switch']",
+ "[contenteditable='true']",
+].join(", ");
+
+/**
+ * Blank-area left-drag panning for a horizontally scrollable board (#6700,
+ * Trello/Linear pattern): pressing the LEFT mouse button on empty board
+ * background and dragging pans the board horizontally — the page follows the
+ * cursor. Dragging a card still moves the card (dnd-kit); this hook stays out
+ * of the way because it never activates when the gesture starts on a card or
+ * any interactive element. Touch and pen input are intentionally left to the
+ * browser; this PR only owns the left-mouse-button gesture.
+ *
+ * ### dnd-kit coexistence invariant (P2-5 — do not break)
+ * These pointer handlers sit on the SAME scroll container that hosts the
+ * `DndContext`. They are mutually exclusive with card dragging purely by
+ * ORIGIN: `onPointerDown` bails whenever the press starts inside
+ * `INTERACTIVE_SELECTOR`, and every draggable card root carries
+ * `data-board-card` (see `DraggableBoardCard` in `board-card.tsx`). If a future
+ * change removes that attribute from the card root, or nests the pan container
+ * below the card listeners, card drags and board pans will start fighting.
+ * Keep `data-board-card` on the card root and keep this exclusion in sync.
+ *
+ * ### Design notes
+ * - Pointer Events + pointer capture claimed on `pointerdown` (not deferred
+ * to first move), so every `pointermove` keeps dispatching to the container
+ * even after the pointer leaves it or the window. Deferring capture was the
+ * "scrolls back when the pointer exits the board" bug: without an early
+ * capture the browser ran a native selection-drag whose auto-scroll fought
+ * `scrollLeft`, and re-entering the container produced a jumped delta.
+ * - Text selection is suppressed from `pointerdown` (P1-3): `user-select:
+ * none` on the container plus `selectstart` / `dragstart` preventers, then
+ * restored in `reset`. Doing it on down (not after the 5px threshold) closes
+ * the window where Safari/Firefox would start a selection whose auto-scroll
+ * yanks the board back. Because selection can no longer begin, `pointermove`
+ * no longer needs a per-frame `removeAllRanges` (P3-7).
+ * - Mouse left button only (`event.pointerType === "mouse"` and
+ * `event.button === 0`). Touch/pen are untouched so native touch scrolling
+ * and pinch zoom stay browser-owned.
+ * - Activation is gated on a ~5px move so a plain click is not swallowed.
+ * - Panning uses the captured pointer's `clientX` deltas — never a hover
+ * target or `elementFromPoint` — so leaving the container can't lose track.
+ * - Horizontal axis only: `deltaY` is never read, `scrollTop` never written.
+ * `scrollLeft` is clamped to `[0, scrollWidth - clientWidth]` so reaching an
+ * edge stops cleanly instead of bouncing back.
+ * - Cleanup on `pointerup` / `pointercancel` / `lostpointercapture` and
+ * window `blur`, plus a `buttons` check on move, so a lost release cannot
+ * leave the board stuck in a panning state.
+ *
+ * Returns props to spread onto the scroll container.
+ */
+export function useBoardDragPan<T extends HTMLElement>() {
+ const ref = useRef<T | null>(null);
+ // Pointer id of the active/pending gesture, or null when idle.
+ const pointerIdRef = useRef<number | null>(null);
+ // True once the ~5px threshold is crossed and we are actually panning.
+ const activeRef = useRef(false);
+ const startXRef = useRef(0);
+ const lastXRef = useRef(0);
+
+ const beginSelectionSuppression = useCallback((el: T) => {
+ el.style.userSelect = "none";
+ el.style.setProperty("-webkit-user-select", "none");
+ }, []);
+
+ const reset = useCallback(() => {
+ const el = ref.current;
+ if (el && pointerIdRef.current !== null) {
+ // releasePointerCapture throws if the capture was already lost; ignore.
+ try {
+ el.releasePointerCapture(pointerIdRef.current);
+ } catch {
+ /* capture already released */
+ }
+ }
+ pointerIdRef.current = null;
+ activeRef.current = false;
+ if (el) {
+ el.style.removeProperty("cursor");
+ // Restore text selection once the gesture ends.
+ el.style.removeProperty("user-select");
+ el.style.removeProperty("-webkit-user-select");
+ }
+ }, []);
+
+ const onPointerDown = useCallback((event: React.PointerEvent<T>) => {
+ // Left mouse button only. Primary touch/pen also report button === 0, but
+ // this board gesture is intentionally scoped to mouse input.
+ if (event.pointerType !== "mouse" || event.button !== 0) return;
+ const el = ref.current;
+ if (!el) return;
+ // Ignore gestures that begin on a card or interactive control — those
+ // belong to dnd-kit / links / form fields (see coexistence invariant).
+ const target = event.target as Element | null;
+ if (target && target.closest(INTERACTIVE_SELECTOR)) return;
+
+ pointerIdRef.current = event.pointerId;
+ activeRef.current = false;
+ startXRef.current = event.clientX;
+ lastXRef.current = event.clientX;
+
+ // Suppress text selection from the very first event (P1-3), before the 5px
+ // threshold, so no selection can begin and auto-scroll the container.
+ beginSelectionSuppression(el);
+
+ // Claim the pointer immediately so subsequent moves keep coming to this
+ // element even once the cursor leaves the board.
+ try {
+ el.setPointerCapture(event.pointerId);
+ } catch {
+ // Pointer capture unsupported/rejected (older engines, synthetic events).
+ // The gesture still works: pointer events keep flowing to the container
+ // while the button is held, and the window `blur` handler plus the
+ // per-move `buttons` check below guarantee cleanup if a release is missed.
+ }
+ event.preventDefault();
+ }, [beginSelectionSuppression]);
+
+ const onPointerMove = useCallback((event: React.PointerEvent<T>) => {
+ if (pointerIdRef.current === null || event.pointerId !== pointerIdRef.current) return;
+ const el = ref.current;
+ if (!el) return;
+
+ // The primary button was released somewhere we didn't hear about (window
+ // blur, drag out of the document). buttons bit 0 is the left button.
+ if ((event.buttons & 1) === 0) {
+ reset();
+ return;
+ }
+
+ if (!activeRef.current) {
+ if (Math.abs(event.clientX - startXRef.current) < PAN_ACTIVATION_DISTANCE) return;
+ // Cross the threshold: begin panning. Pointer is already captured and
+ // selection already suppressed from pointerdown; just show the affordance.
+ activeRef.current = true;
+ el.style.cursor = "grabbing";
+ }
+
+ // Horizontal axis only, driven by captured-pointer clientX deltas. Clamp to
+ // the scrollable range so hitting an edge simply stops. (Selection was
+ // suppressed on pointerdown, so no per-frame range clearing is needed.)
+ const delta = event.clientX - lastXRef.current;
+ lastXRef.current = event.clientX;
+ const maxScroll = el.scrollWidth - el.clientWidth;
+ const next = Math.min(Math.max(el.scrollLeft - delta, 0), Math.max(maxScroll, 0));
+ el.scrollLeft = next;
+ event.preventDefault();
+ }, [reset]);
+
+ const onPointerUp = useCallback((event: React.PointerEvent<T>) => {
+ if (event.pointerId !== pointerIdRef.current) return;
+ reset();
+ }, [reset]);
+
+ // Belt-and-suspenders selection/native-drag blockers while a gesture is
+ // pending or active (P1-3): `user-select` covers most engines, but Safari and
+ // Firefox can still start a selection or an image/text drag, so veto the
+ // events outright until the gesture ends. Attached as native listeners
+ // because React has no synthetic `selectstart` event.
+ useEffect(() => {
+ const el = ref.current;
+ if (!el) return;
+ const veto = (event: Event) => {
+ if (pointerIdRef.current !== null) event.preventDefault();
+ };
+ el.addEventListener("selectstart", veto);
+ el.addEventListener("dragstart", veto);
+ return () => {
+ el.removeEventListener("selectstart", veto);
+ el.removeEventListener("dragstart", veto);
+ };
+ }, []);
+
+ useEffect(() => {
+ const handleBlur = () => reset();
+ window.addEventListener("blur", handleBlur);
+ return () => window.removeEventListener("blur", handleBlur);
+ }, [reset]);
+
+ return {
+ ref,
+ onPointerDown,
+ onPointerMove,
+ onPointerUp,
+ onPointerCancel: onPointerUp,
+ onLostPointerCapture: onPointerUp,
+ };
+}