EventListener envisions an object that controls the event listener properties, such as the target, type, listener, and whether or not it is registered.
Creating an event listener is similar to addEventListener with object parameters.
EventListener({ target: window, type: "click", listener: function () { /* Do Something */ } });
A method to dispatch the listener, independent of other events, accepting an optional parameter as the event.
The listener to execute on dispatch. If the listener is changed while the EventListener object is registered, the old listener will no longer be registered.
The boolean indicating whether or not the event listener is registered. Setting it to true or false will register or unregister the event listener.
The target node to listen to. If the target is changed while the EventListener object is registered, the old target will no longer be registered.
The type of event to listen for. If the type is changed while the EventListener object is registered, the old type will no longer be registered.
var eo = EventListener({ target: window, type: "click", listener: function () { /* Do Something */ } }); // creates an EventListener object.
eo.registered = true; // registers the listener, now the listener will fire when somewhere within the window is clicked.
// eo.registered = false; // would have unregistered the listener.
eo.type = "mousedown"; // registers the listener for "mousedown", unregistering it from "click".
eo.dispatch({ pageX: 320, pageY: 480 }); // dispatches the listener independent of other events, accepting an optional parameter as the event.
The IE8 compatible version does not give you the ability to change the target, type, or listener once they have been set.