Home Reference Source Test
public class | source

State

Creates an object related to a Region's state, and contains helper methods to update and clean up different states.

Test:

Constructor Summary

Public Constructor
public

constructor(regionId: *)

Constructor for the State class.

Member Summary

Public Members
public

An array of Binding objects; The list of relations between elements, their gestures, and the handlers.

public

An array of current and recently inactive Input objects related to a gesture.

public

The number of gestures that have been registered with this state

public

The id for the region this state is bound to.

public

A key/value map all the registered gestures for the listener.

Method Summary

Public Methods
public

addBinding(element: Element, gesture: String | Object, handler: Function, capture: Boolean, bindOnce: Boolean)

Creates a new binding with the given element and gesture object.

public

Tracks the gesture to this state object to become uniquely identifiable.

public

Counts the number of active inputs at any given time.

public

registerGesture(gesture: Object, key: String)

Register the gesture to the current region.

public

Removes all inputs from the state, allowing for a new gesture.

public

Retrieves the Binding by which an element is associated to.

public

Retrieves all bindings based upon the initial X/Y position of the inputs.

public

updateInputs(event: Event, regionElement: Element): boolean

Updates the inputs with new information based upon a new event being fired.

Public Constructors

public constructor(regionId: *) source

Constructor for the State class.

Params:

NameTypeAttributeDescription
regionId *

Public Members

public bindings: Binding source

An array of Binding objects; The list of relations between elements, their gestures, and the handlers.

public inputs: Input source

An array of current and recently inactive Input objects related to a gesture.

public numGestures: Number source

The number of gestures that have been registered with this state

public regionId: String source

The id for the region this state is bound to.

public registeredGestures: Object source

A key/value map all the registered gestures for the listener. Note: Can only have one gesture registered to one key.

Public Methods

public addBinding(element: Element, gesture: String | Object, handler: Function, capture: Boolean, bindOnce: Boolean) source

Creates a new binding with the given element and gesture object. If the gesture object provided is unregistered, it's reference will be saved in as a binding to be later referenced.

Params:

NameTypeAttributeDescription
element Element

The element the gesture is bound to.

gesture String | Object

Either a name of a registered gesture, or an unregistered Gesture object.

handler Function

The function handler to be called when the event is emitted. Used to bind/unbind.

capture Boolean

Whether the gesture is to be detected in the capture of bubble phase. Used to bind/unbind.

bindOnce Boolean

Option to bind once and only emit the event once.

Test:

public assignGestureId(gesture: Gesture) source

Tracks the gesture to this state object to become uniquely identifiable. Useful for nested Regions.

Params:

NameTypeAttributeDescription
gesture Gesture

The gesture to track

public numActiveInputs(): Number source

Counts the number of active inputs at any given time.

Return:

Number

The number of active inputs.

public registerGesture(gesture: Object, key: String) source

Register the gesture to the current region.

Params:

NameTypeAttributeDescription
gesture Object

The gesture to register

key String

The key to define the new gesture as.

public resetInputs() source

Removes all inputs from the state, allowing for a new gesture.

public retrieveBindingsByElement(element: Element): Array source

Retrieves the Binding by which an element is associated to.

Params:

NameTypeAttributeDescription
element Element

The element to find bindings to.

Return:

Array

An array of Bindings to which that element is bound

public retrieveBindingsByInitialPos(): Array source

Retrieves all bindings based upon the initial X/Y position of the inputs. e.g. if gesture started on the correct target element, but diverted away into the correct region, this would still be valid.

Return:

Array

An array of Bindings to which that element is bound

public updateInputs(event: Event, regionElement: Element): boolean source

Updates the inputs with new information based upon a new event being fired.

Params:

NameTypeAttributeDescription
event Event

The event being captured

regionElement Element

The element where this current Region is bound to.

Return:

boolean

returns true for a successful update, false if the event is invalid.