Overview
TheAnnotationTransform type represents an active transformation operation (move or resize) on an annotation. It captures the state needed to compute the new position or dimensions as the user drags the mouse.
Type Definition
types.ts
Properties
The unique identifier of the annotation being transformed
The type of transformation being performed:
"move"- Dragging the annotation to a new position"resize"- Resizing the annotation by dragging a corner handle
The resize handle being dragged (only used when
type is "resize"). Can be "nw", "ne", "sw", or "se".The initial pointer coordinates when the transformation began (in image space)
A snapshot of the annotation’s state before the transformation began. Used to calculate the new position/size based on the pointer delta.
Usage
Starting a Move Operation
App.tsx
Starting a Resize Operation
App.tsx
Computing Transformations
The transform state is used in amousemove event handler to compute the new annotation state:
State Management
The active transformation is stored in React state:- Set to
nullwhen no transformation is active - Set to an
AnnotationTransformobject when dragging - Cleared on
mouseupor when the transformation completes
Related Types
- AnnotationBox - The annotation being transformed
- Point - Used for pointer coordinates
- ResizeHandle - Specifies which corner is being dragged