Home Reference Source Test
public class | source

Region

Allows the user to specify a region to capture all events to feed ZingTouch into. This can be as narrow as the element itself, or as big as the document itself. The more specific an area, the better performant the overall application will perform. Contains API methods to bind/unbind specific elements to corresponding gestures. Also contains the ability to register/unregister new gestures.

Test:

Constructor Summary

Public Constructor
public

constructor(element: Element, capture: boolean, preventDefault: boolean, id: Number)

Constructor function for the Region class.

Member Summary

Public Members
public

Whether the region listens for captures or bubbles.

public

The element being bound to.

public

The identifier for the Region.

public

Boolean to disable browser functionality such as scrolling and zooming over the region

public

The internal state object for a Region.

Method Summary

Public Methods
public

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

Bind an element to a registered/unregistered gesture with multiple function signatures.

public

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

Bind an element and sets up actions to remove the binding once it has been emitted for the first time.

public

register(key: String, gesture: Gesture)

Registers a new gesture with an assigned key

public

unbind(element: Element, gesture: String | Object): Array

Unbinds an element from either the specified gesture or all if no element is specified.

public

Un-registers a gesture from the Region's state such that it is no longer emittable. Unbinds all events that were registered with the type.

Public Constructors

public constructor(element: Element, capture: boolean, preventDefault: boolean, id: Number) source

Constructor function for the Region class.

Params:

NameTypeAttributeDescription
element Element

The element to capture all window events in that region to feed into ZingTouch.

capture boolean
  • optional
  • default: false

Whether the region listens for captures or bubbles.

preventDefault boolean
  • optional
  • default: true

Whether the default browser functionality should be disabled;

id Number

The id of the region, assigned by the ZingTouch object.

Public Members

public capture: boolean source

Whether the region listens for captures or bubbles.

public element: Element source

The element being bound to.

public id: Number source

The identifier for the Region. This is assigned by the ZingTouch object and is used to hash gesture ids for uniqueness.

public preventDefault: boolean source

Boolean to disable browser functionality such as scrolling and zooming over the region

public state: State source

The internal state object for a Region. Keeps track of registered gestures, inputs, and events.

Public Methods

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

Bind an element to a registered/unregistered gesture with multiple function signatures.

Params:

NameTypeAttributeDescription
element Element

The element object.

gesture String | Object
  • optional

Gesture key, or a Gesture object.

handler Function
  • optional

The function to execute when an event is emitted.

capture Boolean
  • optional

capture/bubble

bindOnce Boolean
  • optional

= false] - Option to bind once and only emit the event once.

Return:

Object

a chainable object that has the same function as bind.

Example:

bind(element) - chainable
bind(element, gesture, handler, [capture])

Test:

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

Bind an element and sets up actions to remove the binding once it has been emitted for the first time.

  1. bind(element) - chainable
  2. bind(element, gesture, handler, [capture])

Params:

NameTypeAttributeDescription
element Element

The element object.

gesture String | Object

Gesture key, or a Gesture object.

handler Function

The function to execute when an event is emitted.

capture Boolean

capture/bubble

Return:

Object

a chainable object that has the same function as bind.

public register(key: String, gesture: Gesture) source

Registers a new gesture with an assigned key

Params:

NameTypeAttributeDescription
key String

The key used to register an element to that gesture

gesture Gesture

A gesture object

public unbind(element: Element, gesture: String | Object): Array source

Unbinds an element from either the specified gesture or all if no element is specified.

Params:

NameTypeAttributeDescription
element Element

The element to remove.

gesture String | Object
  • optional

A String representing the gesture, or the actual object being used.

Return:

Array

An array of Bindings that were unbound to the element;

public unregister(key: String | Object): Object source

Un-registers a gesture from the Region's state such that it is no longer emittable. Unbinds all events that were registered with the type.

Params:

NameTypeAttributeDescription
key String | Object

Gesture key that was used to register the object

Return:

Object

The Gesture object that was unregistered or null if it could not be found.