Interface: ShapeAnnotations
Groups all the API actions related to the shape annotations.
Properties
addEventListener()
addEventListener: (
eventName,callback) =>void
Adds an event listener for the shape annotations.
Parameters
• eventName: "toggled" | "opacityChanged" | "deleteCompleted" | "deleteFailed" | "lockChanged" | "lineColorChanged" | "lineThicknessChanged" | "fillColorChanged" | "shapeTypeChanged"
The name of the event to listen for.
• callback: (active) => void | (color) => void | (color) => void | (opacity) => void | (thickness) => void | (shapeType) => void | (annotation) => void | (annotation, error) => void | (annotation, locked) => void
The callback function to execute when the event is triggered.
Returns
void
emitDeleteCompleted()
emitDeleteCompleted: (
annotation) =>void
Triggers an event indicating that a shape annotation has been successfully deleted.
Parameters
• annotation: Annotation
The shape annotation that was deleted.
Returns
void
emitDeleteFailed()
emitDeleteFailed: (
annotation,error) =>void
Triggers an event indicating that a shape annotation deletion has failed.
Parameters
• annotation: Annotation
The shape annotation that failed to delete.
• error: Error
The error that occurred during deletion.
Returns
void
emitFillColorChanged()
emitFillColorChanged: (
color) =>void
Emits a fill color changed event for the shape annotations.
Parameters
• color: `#${string}`
The new color value.
Returns
void
emitLineColorChanged()
emitLineColorChanged: (
color) =>void
Emits a line color changed event for the shape annotations.
Parameters
• color: `#${string}`
The new color value.
Returns
void
emitLineThicknessChanged()
emitLineThicknessChanged: (
thickness) =>void
Emits a line thickness changed event for the shape annotations.
Parameters
• thickness: number
The new thickness value.
Returns
void
emitLockChanged()
emitLockChanged: (
annotation,locked) =>void
Triggers an event indicating that a shape annotation’s lock state has been changed.
Parameters
• annotation: Annotation
The shape annotation whose lock state was changed.
• locked: boolean
true if the annotation was locked, false if unlocked.
Returns
void
emitOpacityChanged()
emitOpacityChanged: (
opacity) =>void
Emits an opacity changed event for the shape annotations.
Parameters
• opacity: number
The new opacity value.
Returns
void
emitShapeTypeChanged()
emitShapeTypeChanged: (
shapeType) =>void
Emits a shape type changed event for the shape annotations.
Parameters
• shapeType: ShapeType
The new shape type value.
Returns
void
emitToggled()
emitToggled: (
active) =>void
Triggers an event indicating that the shape annotations panel has been toggled (opened or closed).
Parameters
• active: boolean
true if the shape annotations panel has been opened, false otherwise.
Returns
void
Example
viewer.shapeAnnotations.emitToggled(true);
removeEventListener()
removeEventListener: (
eventName,callback) =>void
Removes an event listener for the shape annotations.
Parameters
• eventName: "toggled" | "opacityChanged" | "deleteCompleted" | "deleteFailed" | "lockChanged" | "lineColorChanged" | "lineThicknessChanged" | "fillColorChanged" | "shapeTypeChanged"
The name of the event to stop listening for.
• callback: (active) => void | (color) => void | (color) => void | (opacity) => void | (thickness) => void | (shapeType) => void | (annotation) => void | (annotation, error) => void | (annotation, locked) => void
The callback function to remove.
Returns
void