Gesture

westures-core. Gesture

The Gesture class that all gestures inherit from. A custom gesture class will need to override some or all of the four phase "hooks": start, move, end, and cancel.

Constructor

new Gesture(type, element, handler, optionsopt)

Source:
Parameters:
Name Type Attributes Description
type string The name of the gesture.
element Element The element to which to associate the gesture.
handler function The function handler to execute when a gesture is recognized on the associated element.
options object <optional>
Generic gesture options
Properties
Name Type Attributes Default Description
enableKeys Array.<westures-core.STATE_KEYS> <optional>
[] List of keys which will enable the gesture. The gesture will not be recognized unless one of these keys is pressed while the interaction occurs. If not specified or an empty list, the gesture is treated as though the enable key is always down.
disableKeys Array.<westures-core.STATE_KEYS> <optional>
[] List of keys which will disable the gesture. The gesture will not be recognized if one of these keys is pressed while the interaction occurs. If not specified or an empty list, the gesture is treated as though the disable key is never down.
minInputs number <optional>
1 The minimum number of pointers that must be active for the gesture to be recognized. Uses >=.
maxInputs number <optional>
Number.MAX_VALUE The maximum number of pointers that may be active for the gesture to be recognized. Uses <=.

Members

element :Element

Description:
  • The element to which to associate the gesture.
Source:
The element to which to associate the gesture.
Type:
  • Element

handler :function

Description:
  • The function handler to execute when the gesture is recognized on the associated element.
Source:
The function handler to execute when the gesture is recognized on the associated element.
Type:
  • function

id :string

Description:
  • The unique identifier for each gesture. This allows for distinctions across instances of Gestures that are created on the fly (e.g. gesture-tap-1, gesture-tap-2).
Source:
The unique identifier for each gesture. This allows for distinctions across instances of Gestures that are created on the fly (e.g. gesture-tap-1, gesture-tap-2).
Type:
  • string

options :object

Description:
  • The options. Can usually be adjusted live, though be careful doing this.
Source:
The options. Can usually be adjusted live, though be careful doing this.
Type:
  • object

type :string

Description:
  • The name of the gesture. (e.g. 'pan' or 'tap' or 'pinch').
Source:
The name of the gesture. (e.g. 'pan' or 'tap' or 'pinch').
Type:
  • string

Methods

cancel(state) → (nullable) {Object}

Description:
  • Event hook for when an input is cancelled.
Source:
Parameters:
Name Type Description
state westures-core.State The input state object of the current region.
Returns:
Gesture is considered recognized if an Object is returned.
Type
Object

end(state) → (nullable) {Object}

Description:
  • Event hook for the end phase of a gesture.
Source:
Parameters:
Name Type Description
state westures-core.State The input state object of the current region.
Returns:
Gesture is considered recognized if an Object is returned.
Type
Object

evaluateHook(hook, state)

Description:
  • Evalutes the given gesture hook, and dispatches any data that is produced by calling recognize.
Source:
Parameters:
Name Type Description
hook string Must be one of 'start', 'move', 'end', or 'cancel'.
state westures-core.State The current State instance.

isEnabled(state) → {boolean}

Description:
  • Determines whether this gesture is enabled.
Source:
Parameters:
Name Type Description
state westures-core.State The input state object of the current region.
Returns:
true if enabled, false otherwise.
Type
boolean

move(state) → (nullable) {Object}

Description:
  • Event hook for the move phase of a gesture.
Source:
Parameters:
Name Type Description
state westures-core.State The input state object of the current region.
Returns:
Gesture is considered recognized if an Object is returned.
Type
Object

recognize(hook, state, data)

Description:
  • Recognize a Gesture by calling the handler. Standardizes the way the handler is called so that classes extending Gesture can circumvent the evaluateHook approach but still provide results that have a common format. Note that the properties in the "data" object will receive priority when constructing the results. This can be used to override standard results such as the phase or the centroid.
Source:
Parameters:
Name Type Description
hook string Must be one of 'start', 'move', 'end', or 'cancel'.
state westures-core.State current input state.
data Object Results data specific to the recognized gesture.

start(state) → (nullable) {Object}

Description:
  • Event hook for the start phase of a gesture.
Source:
Parameters:
Name Type Description
state westures-core.State The input state object of the current region.
Returns:
Gesture is considered recognized if an Object is returned.
Type
Object