Skip to main content
Version: Version 5 beta

Interface: LineAnnotations

Groups all the API actions related to the line annotations.

Properties

addEventListener()

addEventListener: (eventName, callback) => void

Adds an event listener for the line annotations.

Parameters

eventName: "toggled" | "colorChanged" | "opacityChanged" | "thicknessChanged" | "lineEndingChanged" | "deleteCompleted" | "deleteFailed" | "lockChanged"

The name of the event to listen for.

callback: (active) => void | (color) => void | (opacity) => void | (thickness) => void | (lineEnding, direction) => void | (annotation) => void | (annotation, error) => void | (annotation, locked) => void

The callback function to execute when the event is triggered.

Returns

void


emitColorChanged()

emitColorChanged: (color) => void

Emits a color changed event for the line annotations.

Parameters

color: `#${string}`

The new color value.

Returns

void


emitDeleteCompleted()

emitDeleteCompleted: (annotation) => void

Emits a delete completed event for the line annotations.

Parameters

annotation: LineAnnotation

The annotation that was deleted.

Returns

void


emitDeleteFailed()

emitDeleteFailed: (annotation, error) => void

Emits a delete failed event for the line annotations.

Parameters

annotation: LineAnnotation

The annotation that failed to delete.

error: Error

The error that occurred.

Returns

void


emitLineEndingChanged()

emitLineEndingChanged: (lineEnding, direction) => void

Emits a line ending changed event for the line annotations.

Parameters

lineEnding: number

The new line ending value.

direction: string

The direction of the line ending.

Returns

void


emitLockChanged()

emitLockChanged: (annotation, locked) => void

Emits a lock changed event for the line annotations.

Parameters

annotation: LineAnnotation

The annotation whose lock state changed.

locked: boolean

Whether the annotation is locked.

Returns

void


emitOpacityChanged()

emitOpacityChanged: (opacity) => void

Emits an opacity changed event for the line annotations.

Parameters

opacity: number

The new opacity value.

Returns

void


emitThicknessChanged()

emitThicknessChanged: (thickness) => void

Emits a thickness changed event for the line annotations.

Parameters

thickness: number

The new thickness value.

Returns

void


emitToggled()

emitToggled: (active) => void

Triggers an event indicating that the line annotations panel has been toggled (opened or closed).

Parameters

active: boolean

true if the line annotations panel has been opened, false otherwise.

Returns

void

Example

viewer.lineAnnotations.emitToggled(true);


removeEventListener()

removeEventListener: (eventName, callback) => void

Removes an event listener for the line annotations.

Parameters

eventName: "toggled" | "colorChanged" | "opacityChanged" | "thicknessChanged" | "lineEndingChanged" | "deleteCompleted" | "deleteFailed" | "lockChanged"

The name of the event to stop listening for.

callback: (active) => void | (color) => void | (opacity) => void | (thickness) => void | (lineEnding, direction) => void | (annotation) => void | (annotation, error) => void | (annotation, locked) => void

The callback function to remove.

Returns

void