Events
Events (Vue component)
| Event | Description |
|---|---|
| update:zoomLevel | update zoom level |
| update:selectedNodes | update selected nodes |
| update:selectedEdges | update selected edges |
| update:selectedPaths | update selected paths |
| update:layouts | update layouts |
TIP
Set the update:layouts listener (or v-model:layouts) when the graph is created. The graph checks for the listener only once, at creation, and does not track node positions for this event when there is none. A listener added later, for example by a v-on object that changes after mounting, does not receive the event.
Events (with event-handlers)
The following is a list of events that can be specified for event-handlers prop.
| Event type | Description | Event value |
|---|---|---|
| "view:load" | component loaded | undefined |
| "view:unload" | component unloaded | undefined |
| "view:mode" | mouse mode changed | "default" / "node" / "edge" |
| "view:click" | background clicked | { event: MouseEvent }When a double click occurs, the "view:click" event is fired twice. If you want to determine the second click that is judged to be a double click, you can use the value of event.detail. (When it is a double click, the value will be 2.)By default, double-clicking the background will zoom it. To disable this behavior, set view.doubleClickZoomEnabled to false in Configuration. |
| "view:dblclick" | background double clicked | |
| "view:zoom" | zoom level changed | number (new zoom level) |
| "view:pan" | panned | { x: number, y: number } |
| "view:fit" | fitted | undefined |
| "view:resize" | container resized | { x: number, y: number, width: number, height: number } |
| "view:contextmenu" | background right-clicked | { event: MouseEvent }(To disable the browser's standard context menu, you have to call event.preventDefault() in the handler.) |
| "node:click" | node clicked | { node: string, event: MouseEvent }When a double click occurs, the "node:click" event is fired twice. If you want to determine the second click that is judged to be a double click, you can use the value of event.detail. (When it is a double click, the value will be 2.) |
| "node:dblclick" | node double clicked | |
| "node:pointerover" | pointer over on node | { node: string, event: PointerEvent } |
| "node:pointerout" | pointer out on node | |
| "node:pointerdown" | pointer down on node | |
| "node:pointerup" | pointer up on node | |
| "node:contextmenu" | node right-clicked | { node: string, event: MouseEvent }(To disable the browser's standard context menu, you have to call event.preventDefault() in the handler.) |
| "node:dragstart" | node drag started | { NODE_ID: { x: number; y: number }, ... } |
| "node:pointermove" | node dragged | { NODE_ID: { x: number; y: number }, ... }The nodes removed during the drag are left out. Once the pressed node is removed, the event is no longer fired for its drag. |
| "node:dragend" | node drag ended | { NODE_ID: { x: number; y: number }, ... }The nodes removed during the drag are left out, so the value is {} when all the dragged nodes are removed. |
| "node:select" | node selected | [ NODE_ID, ...] |
| "edge:click" | edge clicked | not summarized edge:{ edge: EDGE_ID, edges: [EDGE_ID], event: MouseEvent, summarized: false }summarized edge: { edges: [EDGE_ID, ...], event: MouseEvent, summarized: true }When a double click occurs, the "edge:click" event is fired twice. If you want to determine the second click that is judged to be a double click, you can use the value of event.detail. (When it is a double click, the value will be 2.) |
| "edge:dblclick" | edge double clicked | |
| "edge:pointerover" | pointer over on edge | not summarized edge:{ edge: EDGE_ID, edges: [EDGE_ID], event: PointerEvent, summarized: false }summarized edge: { edges: [EDGE_ID, ...], event: PointerEvent, summarized: true } |
| "edge:pointerout" | pointer out on edge | |
| "edge:pointerdown" | pointer down on edge | |
| "edge:pointerup" | pointer up on edge | |
| "edge:contextmenu" | edge right-clicked | not summarized edge:{ edge: EDGE_ID, edges: [EDGE_ID], event: MouseEvent, summarized: false }summarized edge: { edges: [EDGE_ID, ...], event: MouseEvent, summarized: true } |
| "edge:select" | edge selected | [ EDGE_ID, ... ] |
| "path:click" | path clicked | { path: PATH_ID, event: MouseEvent }When a double click occurs, the "path:click" event is fired twice. If you want to determine the second click that is judged to be a double click, you can use the value of event.detail. |
| "path:dblclick" | path double clicked | |
| "path:pointerover" | pointer over on path | { path: PATH_ID, event: PointerEvent } |
| "path:pointerout" | pointer out on path | |
| "path:pointerdown" | pointer down on path | |
| "path:pointerup" | pointer up on path | |
| "path:contextmenu" | path right-clicked | { path: PATH_ID, event: MouseEvent } |
| "path:select" | path selected | [ PATH_ID, ... ] |
TIP
node:dragstart and node:dragend come in pairs for each node: a node named in node:dragstart is named again in a later node:dragend. The selected nodes follow the dragged one, and a node that starts or stops following during the drag gets its own event at that moment. This happens when it is selected or deselected, or when another pointer presses it. A node:dragend can therefore come before the pointer is released.
To tell which nodes are being dragged, add the nodes of node:dragstart to a set and delete those of node:dragend. A node removed during its drag is left out of node:dragend, so delete it from the set when you remove it from the nodes.
