Skip to content

Triggers

These are the available callbacks that the map will trigger and can be subscribed with subscribe method:

Input triggers

  • click: Will be called when click event is triggered on the map.
  • dblclick: Will be called when dblclick event is triggered on the map.
  • contextmenu: Will be called when contextmenu event is triggered on the map.
  • up: Will be called when mouseup or touchstart events are triggered on the map.
  • down: Will be called when mousedown or touchend events are triggered on the map.
  • move: Will be called when mousemove or touchmove events are triggered on the map.
  • hover: Will be called when hovering a node.
  • enter: Will be called when the cursor enters the node.
  • leave: Will be called when the cursor leaves the node.
  • wheel: Will be called when wheel event is triggered on the map.

State triggers

  • select: Will be called when a node is selected (interacting with it or using the select method).
  • unselect: Will be called when a node is unselected (interacting with it or using the unselect method).
  • state_change: Will be called when a node change its state.

Camera triggers

  • zooming: Will be called when scaling_factor changes.
  • panning: Will be called when there is map navigation without changing the zoom level.

Load triggers

  • pre_load_start: Triggered just after loadMap has been called, before the reset trigger.
  • load_start: Will be called when a map starts the load process, after the reset trigger.
  • load_success: Will be called when a map finishes the load process successfully.
  • load_error: Will be called when a map load process finishes with an error.
  • reset: Will be called when a map is reset. Loading a map or calling reset() implies triggering reset.

pre_load_start -> reset -> load_start -> (load_success or load_error)

Misc triggers

  • update: Will be called in every frame.
  • first_seen: Will be called when a section is first seen on the Viewer when the scaling_factor is enough to show its seats. This callback is useful to feed the availability of the map on demand.
  • layer_level_changed: Will be called when a map change its level.

To standardize and allow the content extension, all these callbacks will receive the following Object as first parameter:

  • action (string): Action ID that triggered the call (from the list above).
  • instance (MapViewer): Map Viewer Instance that triggered the call.
  • nodes (MapViewerNode[]): MapViewerNode array with the nodes that triggered the call. This array can be empty, for example if a click is triggered from an empty part of the map, or in case of zooming or panning callbacks. It can also contain multiple nodes, for example clicking on a seat with a section below.
  • original_event (Event) [optional]: Original event (click, mousemove, etc) object triggered (if any).
  • point (Object) [optional]: If the action has been triggered in a specific location this object will have two properties:
    • dom (number[]): Array with the DOM coordinates [x,y] in pixels relatives to the dom element representing the map. The top left corner of the map element n the dom will be coordinate [0,0], and the bottom right corner will be [width,height]. Useful to create popups over the map.
    • scene (number[]): Array with the scene coordinates [x,y] in pixels relatives to the internal coordinate system. All nodes have a fixed position in the scene, independently of the scaling factor or translation of the viewport. Useful to be used with methods that accepts scene coordinates like focusOn, goTo or getNodesAt.
  • limits (Object) limits object.