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 element on which the event is triggered.
If omitted, the event will be emitted on the document
.
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.
A message to print to the log when the event is emitted.
Pass false
to not log this event emission.
The element on which the event is triggered.
Alternatively the target element may be passed as the first argument.
The emitted event object.