From 29bf52a70b4525ab4791cd2f5a382075b8d6b613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C3=B1igo=20Medina?= Date: Thu, 12 Apr 2018 13:04:45 +0200 Subject: [PATCH] Create 09-events.md --- docs/reference/09-events.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docs/reference/09-events.md diff --git a/docs/reference/09-events.md b/docs/reference/09-events.md new file mode 100644 index 0000000..f49d496 --- /dev/null +++ b/docs/reference/09-events.md @@ -0,0 +1,28 @@ +### Events + +Events in Torque follow the format: + +```js +torqueLayer.on('event-type', function([callback_obj]) { + // do something +}); +``` + +Events | Callback Object | Description +---|---|--- +`change:steps` | current step | When a map changes steps, this event is triggered +`change:time` | current time, step number | When a map changes time, this event is triggered +`play` | none | Triggered when the Torque layer is played +`pause` | none | Triggered when the Torque layer is paused +`stop` | none | Triggered when the Torque layer is stopped +`load` | none | Triggered when the Torque layer is loaded + +**Example:** +```js +// An event example to print the current step to the console log. + +torqueLayer.on('change:steps', function(step) { + // do something with step + console.log('Current step is ' + step); +}); +```