DragDrop
Defined in: src/modules/drag-drop/drag-drop.ts:84
One drag-and-drop interaction at a time: grab a payload, follow the pointer, find the target under it that accepts the payload, drop there or snap back.
It takes plain points and returns a result. It binds no input listener,
captures no pointer and draws nothing, so the same session drives a DOM UI
and a canvas board alike: feed it from DOM events, from modules/input, or
from a tick system, and draw the dragged item at session.position.
Type Parameters
Section titled “Type Parameters”TPayload
Section titled “TPayload”TPayload
TTarget
Section titled “TTarget”TTarget
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DragDrop<
TPayload,TTarget>(options):DragDrop<TPayload,TTarget>
Defined in: src/modules/drag-drop/drag-drop.ts:90
Parameters
Section titled “Parameters”options
Section titled “options”DragDropOptions<TPayload, TTarget>
Returns
Section titled “Returns”DragDrop<TPayload, TTarget>
Accessors
Section titled “Accessors”hovered
Section titled “hovered”Get Signature
Section titled “Get Signature”get hovered():
TTarget|null
Defined in: src/modules/drag-drop/drag-drop.ts:128
The target the item would land on if released now, or null. Use it to highlight a drop zone.
Returns
Section titled “Returns”TTarget | null
session
Section titled “session”Get Signature
Section titled “Get Signature”get session():
DragSession<TPayload> |null
Defined in: src/modules/drag-drop/drag-drop.ts:160
The drag in progress, or null.
Returns
Section titled “Returns”DragSession<TPayload> | null
Methods
Section titled “Methods”begin()
Section titled “begin()”begin(
payload,pointer,origin?):void
Defined in: src/modules/drag-drop/drag-drop.ts:101
Press on payload with the pointer at pointer. origin is the dragged
item’s own origin (its top-left, usually), so the item keeps the grab offset
instead of jumping to the pointer. Replaces any drag in progress.
Parameters
Section titled “Parameters”payload
Section titled “payload”TPayload
pointer
Section titled “pointer”origin?
Section titled “origin?”Vec2 = pointer
Returns
Section titled “Returns”void
cancel()
Section titled “cancel()”cancel():
void
Defined in: src/modules/drag-drop/drag-drop.ts:108
Abandon the drag in progress without a drop.
Returns
Section titled “Returns”void
end(
pointer?):DropResult<TPayload,TTarget> |null
Defined in: src/modules/drag-drop/drag-drop.ts:117
Release, optionally at a final pointer, and close the session. Returns
the drop result, or null when no drag was in progress or the pointer
never crossed the threshold (a click, not a drag).
Parameters
Section titled “Parameters”pointer?
Section titled “pointer?”Returns
Section titled “Returns”DropResult<TPayload, TTarget> | null
move()
Section titled “move()”move(
pointer):void
Defined in: src/modules/drag-drop/drag-drop.ts:133
Update the pointer. Does nothing without a drag in progress.
Parameters
Section titled “Parameters”pointer
Section titled “pointer”Returns
Section titled “Returns”void