Skip to main content
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()

Creates a new PanResponder instance with the provided configuration.
object
required
Configuration object containing responder callbacks
function
Called to determine whether to become the responder on the start of a touchSignature: (event, gestureState) => boolean
function
Called during the capture phase to determine whether to become the responderSignature: (event, gestureState) => boolean
function
Called when a touch moves to determine whether to become the responderSignature: (event, gestureState) => boolean
function
Called during the capture phase when a touch movesSignature: (event, gestureState) => boolean
function
Called when the view becomes the responder. Show visual feedback.Signature: (event, gestureState) => void
function
Called when another component has become the responderSignature: (event, gestureState) => void
function
Called when a touch startsSignature: (event, gestureState) => void
function
Called when the touch movesSignature: (event, gestureState) => void
function
Called when a touch endsSignature: (event, gestureState) => void
function
Called when the user has released all touches. This typically means a gesture has succeeded.Signature: (event, gestureState) => void
function
Called when another component has become the responder, so this gesture should be cancelledSignature: (event, gestureState) => void
function
Called to determine whether this responder should be terminatedSignature: (event, gestureState) => boolean
function
Returns whether this component should block native components from becoming the JS responder. Currently only supported on Android.Signature: (event, gestureState) => boolean
Returns: An object containing:
  • panHandlers - Props to spread on the View component
  • getInteractionHandle() - Returns interaction handle (deprecated)

GestureState Object

The gestureState 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 event
  • nativeEvent.identifier - The ID of the touch
  • nativeEvent.locationX - The X position of the touch, relative to the element
  • nativeEvent.locationY - The Y position of the touch, relative to the element
  • nativeEvent.pageX - The X position of the touch, relative to the root element
  • nativeEvent.pageY - The Y position of the touch, relative to the root element
  • nativeEvent.target - The node id of the element receiving the touch event
  • nativeEvent.timestamp - A time identifier for the touch, useful for velocity calculation
  • nativeEvent.touches - Array of all current touches on the screen

Example

Multi-Touch Example