Emits a custom event with the given name and properties.
The event will be dispatched on the document
or on the given element.
You can listen to events of that type using
addEventListener()
or up.on()
.
up.on('my:event', function(event) {
console.log(event.foo)
})
up.emit('my:event', { foo: 'bar' })
// Prints "bar" to the console
The event type, e.g. my:event
.
A list of properties to become part of the event object that will be passed to listeners.
The layer on which to emit this event.
If this property is set, the event will be emitted on the layer's outmost element. Also up.layer.current will be set to the given layer while event listeners are running.
The emitted event object.