DragBehavior
Source: dragBehavior.js:125
Base drag behaviour: optional start gate and drag lifecycle hooks. Concrete tools extend this (e.g. WindowLevelDragBehavior).
Pointer tracking for incremental DragStep deltas lives here (DragBehavior#onUpdate); LayerGroupPointer only forwards positions during an active drag.
Constructor
new DragBehavior(options?: DragBehaviorOptions): DragBehaviorParameters
options(DragBehaviorOptions, optional) — Constructor options.
Instance Methods
setDragThreshold(threshold: Scalar2D)
Parameters
threshold(Scalar2D) — New per-axis minimum move in display pixels before DragBehavior#onDrag runs.
isActive(): boolean
Returns
boolean— True afteronStartuntilonEnd.
canStart(_point: Point2D, _layerGroup: LayerGroup): boolean
Whether a drag may start at the given pointer (tool-specific gate).
Parameters
_point(Point2D) — The pointer position._layerGroup(LayerGroup) — The layer group under the pointer.
Returns
boolean— Whether a drag may begin.
reset()
Clear drag anchors (DragBehavior#startPoint, DragBehavior#prevPoint).
onStart(
point: Point2D,
_layerGroup: LayerGroup,
_pointerStart?: DragPointerStartContext | undefined,
)
Begin tracking: records start and previous pointer for DragBehavior#onUpdate.
Parameters
point(Point2D) — The pointer position at drag start._layerGroup(LayerGroup) — The layer group under the pointer._pointerStart(DragPointerStartContext | undefined, optional) — Mouse/touch context from LayerGroupPointer.
onUpdate(point: Point2D, layerGroup: LayerGroup)
Advance the drag with a new pointer position. Builds a DragStep with point0 = previous position, point1 = current, and this behavior's threshold; when DragStep#passesThreshold is true, assigns the current point as DragBehavior#prevPoint, then calls onDrag.
Parameters
point(Point2D) — Current pointer position in display space.layerGroup(LayerGroup) — The layer group under the pointer.
onDrag(_drag: DragStep, _layerGroup: LayerGroup)
Qualifying move step after threshold checks; override in subclasses.
Parameters
_drag(DragStep) — Step with DragStep#delta._layerGroup(LayerGroup) — The layer group under the pointer.
onEnd()
End the drag session and reset.
Instance Fields
startPoint
Returns
Point2D| undefined— The start point.
prevPoint
Returns
Point2D| undefined— Last accepted pointer for the next step. When DragBehavior#onDrag runs, already updated to this move's endpoint (thepointpassed to DragBehavior#onUpdate).