Events
The Events class. Creates a single global event listener per type and target.
Usually, you want to use only one instance of this class. (Use the default export which is a singleton instance)
Static Member Summary
Static Public Members | ||
public static |
knownTargets: {"window": *, "document": *, "body": *} An object containing "known targets" that are supported by default and for which shortcuts are added to the |
Constructor Summary
Public Constructor | ||
public |
Creates new instance. |
Method Summary
Public Methods | ||
public |
addEventListener(type: *, listener: *, options: *): * |
|
public |
Removes an event listener callback. |
|
public |
Adds an event listener callback. |
|
public |
removeEventListener(type: *, listener: *, options: *): * |
Static Public Members
public static knownTargets: {"window": *, "document": *, "body": *} source
An object containing "known targets" that are supported by default and for which shortcuts are added to the on
nad off
methods.
Public Constructors
public constructor() source
Creates new instance.
Adds shortcuts to the on
and off
methods for all known targets.
Public Methods
public addEventListener(type: *, listener: *, options: *): * source
Params:
Name | Type | Attribute | Description |
type | * | ||
listener | * | ||
options | * |
Return:
* |
public off(type: String, listener: Function, options: Object | Boolean) source
Removes an event listener callback. Removes the global event listener as well if the callback was the only one.
Params:
Name | Type | Attribute | Description |
type | String | A case-sensitive string representing the event type to listen for. |
|
listener | Function | The event listener callback |
|
options | Object | Boolean |
|
An options object or a boolean |
options.capture | Boolean |
|
Whether to listen during the capturing phase |
options.passive | Boolean |
|
Whether to use a passive event listener |
options.target | Object | String |
|
The target element on which to add the event listener. |
public on(type: String, listener: Function, options: Object | Boolean): Object source
Adds an event listener callback. Creates a global event listener if necessary. Returns an object with a dispose function that can be called without arguments to remove the event listener callback.
Params:
Name | Type | Attribute | Description |
type | String | A case-sensitive string representing the event type to listen for. |
|
listener | Function | The event listener callback |
|
options | Object | Boolean |
|
|
options.capture | Boolean |
|
Whether to listen during the capturing phase |
options.passive | Boolean |
|
Whether to use a passive event listener |
options.target | Object | String |
|
The target element on which to add the event listener. |
public removeEventListener(type: *, listener: *, options: *): * source
Params:
Name | Type | Attribute | Description |
type | * | ||
listener | * | ||
options | * |
Return:
* |