EventManager Class
EventManager is used to manager DOM events creationg and destruction in a single function call.
It is used by objects to make it easier to add, manager and remove events from DOM elements.
Constructor
EventManager
()
Methods
add
-
target
-
event
-
callback
Add new event to the manager, the event is not created immediatly the create() method had to be called to create the event.
Parameters:
-
target
ElementEvent target element.
-
event
StringEvent name.
-
callback
FunctionCallback function.
addCreate
-
target
-
event
-
callback
Add and create and event to the event manager.
Creates the event and attaches it to the DOM element immediatly.
Parameters:
-
target
ElementEvent target element.
-
event
StringEvent name.
-
callback
FunctionCallback function.
addScrollEvent
-
target
-
callback
Add a scroll event to a target element.
Parameters:
-
target
ElementEvent target element.
-
callback
FunctionCallback function.
clear
()
Destroys this manager by stopping all event handlers and remove them from the manager.
create
()
Creates the events in this manager by attaching them to the DOM elements.
Uses the element.addEventListener() method to attach the event handlers.
destroy
()
Destroy all events in this manager, stop the events.
Uses the element.removeEventListener() method to destroy the event handlers.
Does not remove the events from the manager.
remove
-
target
-
event
Remove and destroy event(s) from a DOM element and from the manager.
Parameters:
-
target
ElementEvent target element to remove elements from.
-
event
StringEvent name to be removed.