Components
← All components

Pointer Drag

stimeo--pointer-drag

The groundwork for dragging: start, move, end and cancel, with the keyboard able to do the same.

  • Core

The groundwork under everything you grab and move: reordering, swiping, a sheet you pull up. Mouse, finger and pen become one stream. A press that barely moves stays a plain click. The movement can be locked to one axis. The drag keeps following even when the finger leaves the element, and the page never pans out from under it. Interruptions and Esc cancel it cleanly. What a drag means is deliberately left open, so by default nothing is moved or drawn. If the element should simply follow the pointer, one setting turns that on. The keyboard can do the same: Space grabs, the arrow keys move, Space again drops, and Esc puts it back.

running

Drag the card, or focus it and press Space to grab, the arrow keys to move, and Space again to drop. Esc snaps it back. The following is handled by a setting; this demo's JavaScript 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.