Components
← All components

Pointer Drag

stimeo--pointer-drag

A normalized drag lifecycle (start / move / end / cancel) with a built-in keyboard alternative.

  • Core

The stimeo--pointer-drag controller is the drag primitive everything draggy composes from — sortable, swipe actions, bottom sheets, split panes. It normalizes pointer/touch/mouse into one clean signal and owns the hard parts once: the start threshold (below it a press stays a plain click), axis locking, pointer capture, a touch-action derived from the axis so the page never pans mid-drag, and pointercancel/Escape cancelation. It deliberately does not decide what a drag means: by default it moves nothing and renders nothing — consumers react to the events and the data-dragging / data-grabbed hooks. The one classic case, "just move the element", is absorbed by the opt-in follow value: translate applied on move, committed on drop, restored on cancel (independent of transform). The keyboard alternative is built in: Space or Enter on the handle grabs, the arrow keys emit synthetic moves of keyboardStep pixels (cumulative, axis-filtered), Space/Enter drops, and Escape cancels — so every consumer gets a keyboard path for free. Deltas are cumulative from the origin and physical (client coordinates). Without a handle target, the element itself is the handle.

running

Drag the card with a pointer, or focus it and press Space, move with the arrow keys, then Space to drop (Esc snaps back). The follow value moves the card — this demo's JS only fills the status line.

Keyboard

KeyAction
Space / Enter Grab the handle, or drop it while grabbed (start / end).
↑ / ↓ / ← / → While grabbed, emit a synthetic move of keyboardStep px (locked-axis arrows are consumed but emit nothing).
Esc Cancel the grab — and an in-flight pointer drag.