Skip to main content

Events

You can map a number of events to nodes and groups in a view, and when the event fires, VisuallyJs will supply the event from the browser, the DOM element on which the event occurred, and the model object related to the event.

You can bind a listener to anything listed as a BindableViewEvent:

Mapping events​

To map an event, provide an events object inside a node or group definition:

import { newInstance, NodeEventCallbackPayload, GroupEventCallbackPayload, DEFAULT, EVENT_TAP, EVENT_MOUSEOVER } from "@visuallyjs/browser-ui"

const model = newInstance()

const surface = model.render({})

Event Payload​

The payload for events mapped in a view depends on the vertex type:

Nodes​

NodeEventCallbackPayload
The payload passed to a NodeEventCallback
NameTypeDescription
eMouseEventThe pointer event that caused the event handler to be invoked
elELElement that represents the vertex in the UI
modelVisuallyJsModelThe underlying VisuallyJs model
objNodeThe model object for the vertex
uiUICore<EL>The UI that rendered this vertex

Groups​

GroupEventCallbackPayload
The payload passed to a GroupEventCallback
NameTypeDescription
eMouseEventThe pointer event that caused the event handler to be invoked
elELElement that represents the vertex in the UI
modelVisuallyJsModelThe underlying VisuallyJs model
objGroupThe group in the model
uiUICore<EL>The UI that rendered this vertex