useDragDropManager
Access theDragDropManager instance from anywhere within a DragDropProvider.
Usage
Return Value
DragDropManager | null
The
DragDropManager instance, or null if called outside a DragDropProvider.The manager provides access to:dragOperation— Current drag operation stateregistry— Registry of draggables and droppablesmonitor— Event monitor for subscribing to eventsplugins— Active pluginssensors— Active sensorsmodifiers— Active modifiers
Example
Type Parameters
useDragDropMonitor
Monitor drag and drop events from anywhere within aDragDropProvider. This hook subscribes to events and automatically cleans up listeners when the component unmounts.
Usage
Parameters
Partial<EventHandlers>
required
Object containing event handlers for drag and drop events. All handlers are optional.Available handlers:
onBeforeDragStartonDragStartonDragMoveonDragOveronDragEndonCollision
Event Handlers
(event: BeforeDragStartEvent, manager: DragDropManager) => void
Called before a drag operation starts.
(event: DragStartEvent, manager: DragDropManager) => void
Called when a drag operation starts.
(event: DragMoveEvent, manager: DragDropManager) => void
Called continuously while dragging. Use sparingly as this fires frequently.
(event: DragOverEvent, manager: DragDropManager) => void
Called when dragging over a droppable element.
(event: DragEndEvent, manager: DragDropManager) => void
Called when a drag operation ends.
(event: CollisionEvent, manager: DragDropManager) => void
Called when collision detection identifies potential drop targets.
Examples
Event Logger
State Synchronization
Analytics Tracking
useDragOperation
Access the current drag operation state, including the drag source and target.Usage
Return Value
Draggable | null
The draggable element currently being dragged, or
null if no drag is active.Droppable | null
The current drop target, or
null if not over any droppable.Examples
Drag Preview
Conditional Rendering
Global Drag Indicator
Type Parameters
Type Safety
All hooks support TypeScript generics for type-safe data:Related
- DragDropProvider — Context provider for drag and drop
- useDraggable — Make elements draggable
- useDroppable — Create drop targets