Triggers¶
These are the available callbacks that the map will trigger and can be subscribed
with subscribe
method:
Input triggers¶
click
: Will be called whenclick
event is triggered on the map.dblclick
: Will be called whendblclick
event is triggered on the map.contextmenu
: Will be called whencontextmenu
event is triggered on the map.up
: Will be called whenmouseup
ortouchstart
events are triggered on the map.down
: Will be called whenmousedown
ortouchend
events are triggered on the map.move
: Will be called whenmousemove
ortouchmove
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 whenwheel
event is triggered on the map.
State triggers¶
select
: Will be called when a node is selected (interacting with it or using theselect
method).unselect
: Will be called when a node is unselected (interacting with it or using theunselect
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 afterloadMap
has been called, before thereset
trigger.load_start
: Will be called when a map starts the load process, after thereset
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 callingreset()
implies triggeringreset
.
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 asection
is first seen on the Viewer when the scaling_factor is enough to show itsseats
. 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 aclick
is triggered from an empty part of the map, or in case ofzooming
orpanning
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.