Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface InteractionHandler

An InteractionHandler provides a mechanism for customizing the mouse and touch handling in the viewer.

When an interaction handler is registered with the viewer, it'll call the initialize() method and pass it the internal canvas element and an instance of an InteractionApi that can be used to modify the internal interaction state.

example
class CustomInteractionHandler extends InteractionHandler {
private element: HTMLElement;
private api: InteractionApi;

public dispose(): void {
this.element.removeEventListener('click', this.handleElementClick);
}

public initialize(element: HTMLElement, api: InteractionApi): void {
this.api = api;
this.element = element;
this.element.addEventListener('click', this.handleElementClick);
}

private handleElementClick = (event: MouseEvent) => {
api.pick({ x: event.clientX, y: event.clientY });
}
}

const viewer = document.querySelector("vertex-viewer");
viewer.registerInteractionHandler(new CustomInteractionHandler);

Hierarchy

  • Disposable
    • InteractionHandler

Index

Methods

  • dispose(): void
  • Disposes any resources associated with the object.

    Returns void

  • initialize(element: HTMLElement, api: InteractionApi<Camera>): void
  • Called by the viewer when the interaction handler is registered with the viewer. Used to setup any necessary event listeners to handle user interactions.

    Parameters

    • element: HTMLElement

      The internal viewer element to add event listeners to.

    • api: InteractionApi<Camera>

      The API to modify internal interaction state.

    Returns void