API Docs for: 0.1.1
Show:

flatworld.eventListeners Class

This keeps all the event listeners and detectors in one class. You add detectors / event listener types with addDetector and you add event listeners with on.

Methods

_createEventListenerWrapper

(
  • type
  • cb
)
private static

This creates a wrapper for callback. The idea is to send map events from this wrapper for all events.

Parameters:

clearDetector

(
  • type
)

Clear event detector. We also remove all possible eventlisteners set on this event type.

Parameters:

getActivityState

(
  • type
)
Boolean

get activity state of the event

Parameters:

Returns:

isOn

(
  • type
  • cb
)

Activates the eventListener. Callback is optional. If is not provided will check if the eventlistener type has any listeners active.

Parameters:

  • type String

    REQUIRED. The type of event. This type has been created with setDetector.

  • cb Boolean

    Callback to do it's eventlistener magic.

off

(
  • type
  • cb
)

Deactivates the eventListener. Callback is optional. If is not provided will remove all this types eventListeners

Parameters:

  • type String

    REQUIRED. The type of event. This type has been created with setDetector.

  • cb Boolean

    Callback to do it's eventlistener magic.

on

(
  • type
  • cb
)

Activates the eventListener.

Parameters:

  • type String

    REQUIRED. The type of event. This type has been created with setDetector.

  • cb Boolean

    REQUIRED. Callback to do it's eventlistener magic.

Throws:

Error:

General error, if detector for this event type has not been set.

setActivityState

(
  • type
  • newState
)

Sets the state of the event. State is very important e.g. for fluent dragging and selecting. When we start to drag, we avoid selecting units and vice versa, when we keep an event state tracking through this.

Parameters:

setDetector

(
  • type
  • cbOn
  • cbOff
)

Set event detector. If there is already detector of this type, we overwrite it.

Parameters:

  • type String

    Event type

  • cbOn Function

    Callback which sets activates the detector

  • cbOff Function

    Callback which sets deactivates the detector

Events

Event gets fired when the specific eventListener trigger. The name consists of "Map" + the given event type, like such: "MapDrag"