EventManager Class

Module: Utils

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

()

Item Index

Attributes

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 Element

    Event target element.

  • event String

    Event name.

  • callback Function

    Callback 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 Element

    Event target element.

  • event String

    Event name.

  • callback Function

    Callback function.

addScrollEvent

(
  • target
  • callback
)

Add a scroll event to a target element.

Parameters:

  • target Element

    Event target element.

  • callback Function

    Callback 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 Element

    Event target element to remove elements from.

  • event String

    Event name to be removed.

Attributes

events

Array

Stores all events in the manager, their target and callback.

Format [target, event, callback, active]