PanResponder reconciles several touches into a single gesture. It makes single-touch gestures resilient to extra touches, and can be used to recognize simple multi-touch gestures.
It provides a predictable wrapper of the responder handlers provided by the gesture responder system. For each handler, it provides a new gestureState object alongside the native event object.
Methods
create()
object
required
Configuration object containing responder callbacks
function
Called to determine whether to become the responder on the start of a touchSignature:
(event, gestureState) => booleanfunction
Called during the capture phase to determine whether to become the responderSignature:
(event, gestureState) => booleanfunction
Called when a touch moves to determine whether to become the responderSignature:
(event, gestureState) => booleanfunction
Called during the capture phase when a touch movesSignature:
(event, gestureState) => booleanfunction
Called when the view becomes the responder. Show visual feedback.Signature:
(event, gestureState) => voidfunction
Called when another component has become the responderSignature:
(event, gestureState) => voidfunction
Called when a touch startsSignature:
(event, gestureState) => voidfunction
Called when the touch movesSignature:
(event, gestureState) => voidfunction
Called when a touch endsSignature:
(event, gestureState) => voidfunction
Called when the user has released all touches. This typically means a gesture has succeeded.Signature:
(event, gestureState) => voidfunction
Called when another component has become the responder, so this gesture should be cancelledSignature:
(event, gestureState) => voidfunction
Called to determine whether this responder should be terminatedSignature:
(event, gestureState) => booleanfunction
Returns whether this component should block native components from becoming the JS responder. Currently only supported on Android.Signature:
(event, gestureState) => booleanpanHandlers- Props to spread on the View componentgetInteractionHandle()- Returns interaction handle (deprecated)
GestureState Object
ThegestureState object passed to handlers has the following properties:
number
ID of the gestureState - persisted as long as there is at least one touch on screen
number
The latest screen coordinates of the recently-moved touch
number
The latest screen coordinates of the recently-moved touch
number
The screen coordinates of the responder grant
number
The screen coordinates of the responder grant
number
Accumulated distance of the gesture since the touch started
number
Accumulated distance of the gesture since the touch started
number
Current velocity of the gesture
number
Current velocity of the gesture
number
Number of touches currently on screen
Native Event Properties
The native event object contains:nativeEvent.changedTouches- Array of all touch events that have changed since the last eventnativeEvent.identifier- The ID of the touchnativeEvent.locationX- The X position of the touch, relative to the elementnativeEvent.locationY- The Y position of the touch, relative to the elementnativeEvent.pageX- The X position of the touch, relative to the root elementnativeEvent.pageY- The Y position of the touch, relative to the root elementnativeEvent.target- The node id of the element receiving the touch eventnativeEvent.timestamp- A time identifier for the touch, useful for velocity calculationnativeEvent.touches- Array of all current touches on the screen