DWVv0.37.0

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): DragBehavior

Parameters


Instance Methods

setDragThreshold(threshold: Scalar2D)

Parameters

isActive(): boolean

Returns

  • boolean — True after onStart until onEnd.

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

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

onEnd()

End the drag session and reset.

Instance Fields

startPoint

Returns

  • Point2D | undefined — The start point.

prevPoint

Returns