Skip to main content

Module pointer

Module pointer 

Source
Expand description

Instant, consistent touch (and pen) support. Some mobile browsers can fire native HTML5 drag events from a touch long-press on draggable elements (Safari on iOS/iPadOS 15+; reports for Chrome on Android conflict), but the hold delay is browser-controlled and support is inconsistent across the mobile landscape. This module drives the same shared crate::core::DndContext from pointer events instead: the drag starts after a small movement threshold with no hold, behaves the same in every browser, and uses your DragOverlay as the ghost. Where native long-press exists, it keeps working as a fallback on plain Draggables.

PointerDraggable composes the core Draggable: mouse users get the native HTML5 drag path, while touch/pen input is handled with pointerdownpointermovepointerup, hit-testing the registered drop zones’ cached client rects to decide where the drop lands. Touch pointers have implicit pointer capture, so the originating element keeps receiving moves for the whole gesture.

Two things to know:

  • The wrapper sets touch-action: none so the browser doesn’t hijack the gesture for scrolling. If your list must also scroll by touch, consider a drag handle: put PointerDraggable on the handle only.
  • A small movement threshold (default 8 px) distinguishes drags from taps.

Re-exports§

pub use PointerDraggable_completions::Component::PointerDraggable;

Structs§

PointerDraggableProps
Properties for the PointerDraggable component.

Functions§

PointerDraggable
A draggable that works for mouse and touch/pen.