DomEventListeners

How to get DomEventListeners

ES2015+:

import DomEventListeners from 'fontoxml-dom-utils/DomEventListeners'

ES5:

define([
	'fontoxml-dom-utils/DomEventListeners'
], function (
	DomEventListeners
) {
});

Type: Class

Implements a wrapper around the browser's native event handling, which can register any number of events on any number of elements and remove these in one call.

This avoids code using events to have to manually keep references to bound functions, and is recommended for all event registration within the Fonto base packages.

Methods

Name Description
add

Add an event listener.


  Arguments
# Name Type Description
1. source Node | Object

The source of the events (i.e., the object implementing the DOM EventTarget interface)

2. event String

The type of event to respond to

3. listener Function

The function receiving the events, called with the Event object as its single argument.


  Arguments
# Name Type Description
1. Event
4. useCapture Boolean

Whether to invoke the listener in the capturing (if true) or bubbling (if false) phase of event propagation. Some events do not bubble and need this to be set to true in order to catch them on an ancestor node.


  Default value
false
removeAll

Remove all listeners registered through this object from the DOM.