Pointer Sensor
Detect pointer events to initiate drag and drop operations.
Overview
The Pointer sensor responds to Pointer events for mouse, touch, and pen input. It is enabled by default in the DragDropManager.
Usage
Activation Constraints
The Pointer sensor supports two types of activation constraints that can be used together:
Distance Constraint
Activates dragging after the pointer moves a certain distance:
Delay Constraint
Activates dragging after holding the pointer for a duration:
Default Behavior
By default, the Pointer sensor uses different activation constraints based on the pointer type:
- Mouse: Immediate activation on drag handle
- Touch: 250ms delay with 5px tolerance
- Other pointers: 200ms delay with 5px distance threshold
You can customize this behavior:
API Reference
Options
Configure when dragging should start:
Can be a fixed configuration or a function that returns constraints based on the event and source.
Events
The Pointer sensor handles these events:
pointerdown
: Initial pointer contactpointermove
: Pointer movementpointerup
: Pointer releaselostpointercapture
: Lost pointer tracking
Coordinates
The sensor provides pointer coordinates relative to the viewport:
These coordinates are automatically adjusted for scroll position and zoom level.
Best Practices
-
Use appropriate constraints for different input types:
- Shorter delays for mouse
- Longer delays with tolerance for touch
- Distance constraints for precision
-
Consider accessibility:
- Don’t rely solely on hover
- Provide clear activation feedback
- Support keyboard input via KeyboardSensor