Gesture Handler
State flow
State
Every gesture can be treated as a state machine. That is, each handler instance has its own assigned state that can change when new touch events occur.
A gesture can be in one of 6 possible states
undetermined
failed
began
cancelled
active
end
Events
There are three types of events:
StateChangeEvent
- sent every time a gesture moves to a different stateGestureEvent
- sent every time a gesture is updatedPointerEvent
- carries information about raw touch events, like touching the screen or moving the finger.
Composing Gestures
Composing gestures means determining how multiple gestures interact with each other.
The Gesture
object provides 3 methods to do this:
Race
- The first gesture to have an active state will cancel the rest of the gestures on deck
- ex. in Tinder, you can swipe left or right on a picture, but if you long press then you'll 'Heart' the profile.
Simultaneous
- All of the gestures can be active at the same timeExclusive
- Only one of the gestures can be active, with the first one having higher priority than the second.