As described in "About Gesture Handlers", gesture handlers can be treated as "state machines". At any given time, each handler instance has an assigned state that can change when new touch events occur or can be forced to change by the touch system in certain circumstances.
A gesture handler can be in one of the six possible states:
Each state has its own description below.
We can monitor a handler's state changes by using the
onHandlerStateChange callback and the destructured
nativeEvent argument passed to it.
This can be done by comparing the
state attribute to one of the constants exported under the
State object (see example below).
The most typical flow of state is when a gesture handler picks up on an initial touch event then recognizes it then acknowledges its ending then resets itself back to the initial state.
The flow looks as follows (longer arrows represent that there are possibly more touch events received before the state changes):
Another possible flow is when a handler receives touches that cause a recognition failure:
At last, when a handler does properly recognize the gesture but then is interrupted by the touch system. In that case, the gesture recognition is canceled and the flow looks as follows:
The section below describes all possible handler states:
This is the initial state of each handler and it goes into this state after it's done recognizing a gesture.
A handler received some touches but for some reason didn't recognize them. For example, if a finger travels more distance than a defined
maxDist property allows, then the handler won't become active but will fail instead. Afterwards, it's state will be reset to
The gesture recognizer has received a signal (possibly new touches or a command from the touch system controller) resulting in the cancellation of a continuous gesture. The gesture's state will become
CANCELLED until it is finally reset to the initial state,
Handler has recognized a gesture. It will become and stay in the
ACTIVE state until the gesture finishes (e.g. when user lifts the finger) or gets cancelled by the touch system. Under normal circumstances the state will then turn into
END. In the case that a gesture is cancelled by the touch system, its state would then become
Learn about discrete and continuous handlers here to understand how long a handler can be kept in the
The gesture recognizer has received touches signalling the end of a gesture. Its state will become
END until it is reset to