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 |
assignGestureId(gesture: Gesture) 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 |
retrieveBindingsByElement(element: Element): Array 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:
Name | Type | Attribute | Description |
regionId | * |
Public Members
public bindings: Binding source
An array of Binding objects; The list of relations between elements, their gestures, and the handlers.
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:
Name | Type | Attribute | Description |
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:
Name | Type | Attribute | Description |
gesture | Gesture | The gesture to track |
public registerGesture(gesture: Object, key: String) source
Register the gesture to the current region.
public retrieveBindingsByElement(element: Element): Array source
Retrieves the Binding by which an element is associated to.
Params:
Name | Type | Attribute | Description |
element | Element | The element to find bindings to. |
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.