DragDropManager
is the central orchestrator of the drag and drop system. It coordinates all interactions between draggable and droppable elements.
Usage
Create a manager instance to coordinate drag and drop interactions:Configuration
The manager comes with sensible defaults, but you can customize its behavior:Default configuration
Default configuration
The manager includes these defaults out of the box:Sensors
PointerSensor
: Handles mouse and touch interactions- Mouse: Activates immediately on drag handle
- Touch: 250ms delay with 5px movement tolerance
- Other pointers: 200ms delay with 5px distance threshold
KeyboardSensor
: Enables keyboard navigation with arrow keys
Accessibility
: Manages ARIA attributes and announcementsAutoScroller
: Scrolls containers when dragging near edgesCursor
: Updates cursor appearance during dragFeedback
: Controls visual feedback during dragPreventSelection
: Prevents text selection while draggingScrollListener
: Monitors scroll events during dragScroller
: Handles programmatic scrolling
Events
The manager’smonitor
lets you observe drag and drop events:
Available Events
Fires before drag begins. Can be prevented.
Fires when drag starts.
Fires during movement. Can be prevented.
Fires when over a droppable. Can be prevented.
Fires on droppable collision. Can be prevented.
Fires when drag ends.
Registration
The manager’sregistry
tracks draggable and droppable elements:
Elements automatically register when created with a manager reference. Only use manual registration for advanced use cases.
API Reference
Properties
-
registry
: Tracks active elements and extensionsdraggables
: Map of registered draggable elementsdroppables
: Map of registered droppable elementsplugins
: Registry of active pluginssensors
: Registry of active sensorsmodifiers
: Registry of active modifiers
-
dragOperation
: Current drag operation statesource
: Currently dragged elementtarget
: Current drop targetposition
: Current drag coordinatesstatus
: Current operation statuscanceled
: Whether operation was canceled
-
monitor
: Event systemaddEventListener
: Add event listenerremoveEventListener
: Remove listener
-
renderer
: Integration with asynchronous renderers such as React
Methods
Clean up the manager and all registered elements:
- Unregisters all draggables and droppables
- Cleans up all plugins, sensors, and modifiers
- Removes all event listeners
Lifecycle
-
Initialization
- Manager created
- Default plugins and sensors registered
- Custom configuration applied
-
Registration
- Draggable and droppable elements register
- Plugins initialize
- Event listeners bound
-
Operation
- Drag operations tracked
- Events dispatched
- Collisions detected
-
Cleanup
- Elements unregister
- Event listeners removed
- Resources released