Constructor
new Swipe(element, handler, optionsopt)
- Source:
- See:
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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> |
Gesture customization options.
Properties
|
Extends
Members
element :Element
- Description:
- The element to which to associate the gesture.
- Source:
- Overrides:
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:
- Overrides:
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:
- Overrides:
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
moves :Array.<object>
- Description:
- Moves list.
- Source:
Moves list.
Type:
- Array.<object>
options :object
- Description:
- The options. Can usually be adjusted live, though be careful doing this.
- Source:
- Overrides:
The options. Can usually be adjusted live, though be careful doing this.
Type:
- object
saved :ReturnTypes.SwipeData
- Description:
- Data to emit when all points have ended.
- Source:
Data to emit when all points have ended.
Type:
type :string
- Description:
- The name of the gesture. (e.g. 'pan' or 'tap' or 'pinch').
- Source:
- Overrides:
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:
- Overrides:
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:
- Overrides:
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:
- Overrides:
Parameters:
Name | Type | Description |
---|---|---|
hook |
string | Must be one of 'start', 'move', 'end', or 'cancel'. |
state |
westures-core.State | The current State instance. |
getResult() → (nullable) {ReturnTypes.SwipeData}
- Description:
- Get the swipe result.
- Source:
Returns:
isEnabled(state) → {boolean}
- Description:
- Determines whether this gesture is enabled.
- Source:
- Overrides:
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:
- Overrides:
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:
- Overrides:
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. |
restart()
- Description:
- Restart the swipe state for a new numper of inputs.
- Source:
start(state) → (nullable) {Object}
- Description:
- Event hook for the start phase of a gesture.
- Source:
- Overrides:
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
(static) calc_angle(moves, vlim) → {number}
- Description:
- Calculates the angle of movement along a series of moves.
- Source:
- See:
Parameters:
Name | Type | Description |
---|---|---|
moves |
Object | The moves list to process. |
vlim |
number | The number of moves to process. |
Returns:
The angle of the movement.
- Type
- number
(static) calc_velocity(moves, vlim) → {number}
- Description:
- Calculates the veloctiy of movement through a series of moves.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
moves |
Object | The moves list to process. |
vlim |
number | The number of moves to process. |
Returns:
The velocity of the moves.
- Type
- number
(static) validate(datanullable) → (nullable) {ReturnTypes.SwipeData}
- Description:
- Validates that an emit should occur with the given data.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
ReturnTypes.SwipeData |
<nullable> |
Returns:
(static) velocity(start, end) → {number}
- Description:
- Local helper function for calculating the velocity between two timestamped points.
- Source:
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
start |
object |
Properties
|
|||||||||
end |
object |
Properties
|
Returns:
velocity from start to end point.
- Type
- number