Skip to main content

Function: triggerEvent()

triggerEvent(el, type, detail): boolean

Small utility to trigger a custom event for a given EventTarget.

Parameters

el: EventTarget = eventTarget

The element or EventTarget to trigger the event upon

type: string

The event type name

detail: unknown = null

The event detail to be sent

Returns

boolean

false if event is cancelable and at least one of the event handlers which received event called Event.preventDefault(). Otherwise it returns true.

Example

triggerEvent(element, Events.IMAGE_RENDERED, { element })

or it can trigger event on the eventTarget itself

triggerEvent(eventTarget, CSTOOLS_EVENTS.ANNOTATION_MODIFIED, { viewportId, annotationUID })

Defined in

packages/core/src/utilities/triggerEvent.ts:23