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()
Configuration object containing responder callbacks
Called to determine whether to become the responder on the start of a touchSignature:
(event, gestureState) => booleanCalled during the capture phase to determine whether to become the responderSignature:
(event, gestureState) => booleanCalled when a touch moves to determine whether to become the responderSignature:
(event, gestureState) => booleanCalled during the capture phase when a touch movesSignature:
(event, gestureState) => booleanCalled when the view becomes the responder. Show visual feedback.Signature:
(event, gestureState) => voidCalled when another component has become the responderSignature:
(event, gestureState) => voidCalled when a touch startsSignature:
(event, gestureState) => voidCalled when the touch movesSignature:
(event, gestureState) => voidCalled when a touch endsSignature:
(event, gestureState) => voidCalled when the user has released all touches. This typically means a gesture has succeeded.Signature:
(event, gestureState) => voidCalled when another component has become the responder, so this gesture should be cancelledSignature:
(event, gestureState) => voidCalled to determine whether this responder should be terminatedSignature:
(event, gestureState) => booleanReturns 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:
ID of the gestureState - persisted as long as there is at least one touch on screen
The latest screen coordinates of the recently-moved touch
The latest screen coordinates of the recently-moved touch
The screen coordinates of the responder grant
The screen coordinates of the responder grant
Accumulated distance of the gesture since the touch started
Accumulated distance of the gesture since the touch started
Current velocity of the gesture
Current velocity of the gesture
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