DragContext
@whittakertech/mosaic / DragContext
Interface: DragContext
Defined in: drag/context.ts:20
Immutable context object describing the current drag operation.
A DragContext provides a stable, serializable view of MosaicJS’s
internal drag state at a specific moment in time.
It is passed to lifecycle hooks and emitted with relevant events to allow external systems to observe drag behavior safely.
Remarks
- A DragContext is read-only and frozen at creation time.
- It represents a snapshot of state, not a live reference.
- Consumers must not attempt to mutate or persist this object.
The shape of DragContext is considered part of MosaicJS’s stable public API.
Properties
activeNodeId
readonly activeNodeId: string | null;Defined in: drag/context.ts:25
Currently dragged node ID, or null when idle
dropTargetId
readonly dropTargetId: string | null;Defined in: drag/context.ts:28
Resolved drop target node ID, or null when none
groupId
readonly groupId: string | null;Defined in: drag/context.ts:66
The active node’s group container id (#13’s convention), or null
when ungrouped or selectors.group isn’t configured (#18).
Remarks
Sourced from the same value Mosaic.setState already forwards
as its groupId argument — this field threads that same value into
the DragContext seen by lifecycle hooks, which previously had no
access to it.
hasSnapshot
readonly hasSnapshot: boolean;Defined in: drag/context.ts:40
Whether a drag snapshot currently exists
mosaicInstanceId
readonly mosaicInstanceId: string;Defined in: drag/context.ts:54
Uniquely identifies the originating Mosaic instance (#18).
Remarks
Unlike DragContext.mosaicRootId — which is derived from the
root element’s DOM id and is not guaranteed unique (multiple pages,
SPA route re-renders, or simple author oversight can collide) —
mosaicInstanceId is generated once at Mosaic construction time and
is guaranteed distinct across instances on the same page. Consumers
observing multiple Mosaic instances should filter by this field, not
mosaicRootId.
mosaicRootId
readonly mosaicRootId: string;Defined in: drag/context.ts:22
Root Mosaic instance identifier
pointer
readonly pointer: object;Defined in: drag/context.ts:31
Pointer position at time of emission
x
readonly x: number;y
readonly y: number;state
readonly state: MosaicState;Defined in: drag/context.ts:37
Current Mosaic drag lifecycle state