Entity base class
BothDraggable and Droppable extend a common Entity base class:
Unique identifier
Every entity has a unique identifier that can be a string or number:id is used to:
- Register/unregister entities in the manager’s registry
- Identify entities during drag operations
- Look up entities by ID
- Track entity relationships
Data property
Thedata property stores custom data associated with the entity:
Disabled state
You can disable entities to prevent interaction:- Won’t respond to sensor input (draggables)
- Won’t participate in collision detection (droppables)
- Remain in the registry but are skipped during operations
Draggable
ADraggable represents an element that can be dragged.
Creating a draggable
Type signature
Element and handle
Theelement is the DOM element that represents the draggable:
handle to restrict where dragging can start:
- Dragging only starts when interacting with the handle
- The rest of the element remains interactive
- Useful for complex UI elements with buttons, links, etc.
Status tracking
Draggables track their current status:Type categorization
Thetype property categorizes draggables:
Per-entity configuration
You can override manager settings for individual draggables:Droppable
ADroppable represents an element that can receive dragged items.
Creating a droppable
Type signature
Collision detection
Every droppable requires a collision detector:Acceptance rules
Control which draggables can be dropped: Accept a specific type:Collision priority
When multiple droppables collide, priority determines the winner:Shape tracking
Droppables track their bounding rectangle:Drop target status
Check if a droppable is the current drop target:Registration
Entities automatically register with the manager when created:Manual registration
You can disable automatic registration:Registration lifecycle
Entities can register effects that run when registered:Reactive properties
Many entity properties are reactive:disableddatatypestatus(draggables)accept(droppables)shape(droppables)modifiers(draggables)
Type safety
You can type the data property:Framework integration
Framework adapters provide idiomatic APIs:Related
Draggable API
Draggable API reference
Droppable API
Droppable API reference
Collision detection
How collisions work
Data flow
Working with entity data