Skip to main content

Function: getEnabledElement()

getEnabledElement(element): IEnabledElement | undefined

A convenience method to find an EnabledElement given a reference to its associated element. Commonly used in code that's handling a custom event emitted by this library.

Parameters

element: HTMLDivElement

a reference to an EnabledElement/Viewport's div element

Returns

IEnabledElement | undefined

the associated EnabledElement, or undefined if no matching EnabledElement can be found

Examples

Using the renderingEngine to find the enabled element:

const element = getRenderingEngine(renderingEngineId)
.getViewport(viewportId)
.element

const enabledElement = getEnabledElement(element)

Using a cornerstone event's "element"

// Our "cornerstone events" contain the source element, which is
// raised on the viewport's div element
const { element } = evt.detail
const enabledElement = getEnabledElement(element)

Defined in

packages/core/src/getEnabledElement.ts:34