MouseState

new MouseState()

Poll system (https://en.wikipedia.org/wiki/Polling_(computer_science)) Listen to the MOUSE_STATE_EVENTS and store the mouse state to then be access synchronously

Classes

MouseState

Members

dragging :boolean

true if the mouse is dragging

Type:
  • boolean

listeners :Array.<{element:HTMLElement, listener:EventCallback, id:string}>

register all listeners to well dispose them on dipose

Type:
  • Array.<{element:HTMLElement, listener:EventCallback, id:string}>

mouseEvent :Object.<string, Event>

register event native js to pass it later synchronously

Type:
  • Object.<string, Event>

mouseMap :Object.<string, boolean>

register if a mouse event is trigger or not

Type:
  • Object.<string, boolean>

Methods

addEvent(element, idEvent) → {EventCallback}

Add a listener for a particular event on element

Parameters:
NameTypeDescription
elementHTMLElement

element to listen to

idEventstring

mouse events

Returns:
  • Callback call for this event
Type: 
EventCallback

dispose()

Remove listeners and reset variables

event(eventID) → {Event}

Access the last Event stored for eventID

Parameters:
NameTypeDescription
eventIDstring

id of the mouse event

Returns:
  • The last event store for this event
Type: 
Event

isDragging() → {boolean}

Returns:
  • true if the mouse is dragging, false otherwise
Type: 
boolean

isTrigger(eventID) → {boolean}

Return true if this event has been triggered on the last poll

Parameters:
NameTypeDescription
eventIDstring

event id

Returns:
  • true if the eventID has been triggered
Type: 
boolean

reset()

Reset Event triggered

startListening(element)

Start listening MOUSE_STATE_EVENTS on the element

Parameters:
NameTypeDescription
elementHTMLElement

html catching events