Skip to main content

DnD State Manager

Overview​

The DndStateManager is a small internal helper that keeps track of drag state for a single drag interaction context. Each drag context (such as a BaseDropZone or DragListComponent) owns its own instance of the state manager, allowing them to operate independently.

It provides observable streams for the current drop state, instruction feedback, and closest edge, and exposes simple update methods used internally by drag and drop zones.

import { DndStateManager } from 'ngx-builder-dnd';

API Reference​

Properties​

NameDescription
dropTarget: DragStateReturns the current drop state value.
instruction: Instruction | nullReturns the current instruction.
closestEdge: Edge | nullReturns the current closest edge.

Observables​

NameDescription
dropTarget$: Observable<DragState>Emits the current drag state for the drop target.
instruction$: Observable<Instruction | null>Emits the current drag Instruction, or null when no instruction exists.
closestEdge$: Observable<Edge | null>Emits the closest edge during dragging, or null otherwise.

Methods​

DropZone overrides some of the default behaviors defined in BaseDropZone. These changes tailor the class for drop-only tree items:

MethodDescription
updateInstruction(instruction: Instruction | null): voidUpdates the current instruction emitted during a drag interaction.
updateDropTarget(state: DragState): voidUpdates the drop target state.
updateClosestEdge(Edge | null): voidUpdates the closest hovered edge.
destroy(): voidCompletes all internal subjects and cleans up resources.

See Also​