Module drag
Expand description
Reusable drag-to-reorder interaction model — the single source of truth for live-reflow list reordering (weather’s saved cities today; notes, playlists, contacts next).
Like Scrollbar, this is a pure state
machine, not a widget: it turns (list geometry, cursor) into the live
insertion index, per-item reflow shift, and floating ghost rect.
DragController::cancel just forgets the session, so cancel is a no-op
by construction. A generic Id payload lets a caller key
selection/presence to the moving item without the controller
understanding it.
The reflow math assumes a uniform list (one extent + fixed gap per
item) — true of every current adopter. A non-uniform list can still drive
the insertion index via its own ListMetrics, but the whole-slot
reflow shift only makes sense for uniform slots.
Structs§
- Drag
Controller - A single-axis drag-to-reorder controller. Construct one per reorderable
list (
DragController::vertical/DragController::horizontal) and drive it from the owner’s event handler: - List
Metrics - Uniform geometry of a reorderable list along the drag axis, in the same (logical, scroll-adjusted) coordinate space as the cursor.
Enums§
- Axis
- Which way a reorderable list runs. The controller pins the cross axis while dragging so the ghost slides only along the list.
Constants§
- REORDER_
THRESHOLD_ PX - Pixels of pointer travel before a press is promoted to a reorder drag, so a plain click never jitters into a move.