Socket
Socket
Sign inDemoInstall

react-native-gesture-responder

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-gesture-responder

A more convenient and powerful gesture responder than the official PanResponder.


Version published
Maintainers
1
Created
Source

react-native-gesture-responder

A more convenient and powerful gesture responder than the official PanResponder.

Install

npm install --save react-native-gesture-responder@latest

Documentation

Have a glance of how to use it:

componentWillMount() {
  this.gestureResponder = createResponder({
    onStartShouldSetResponder: (evt, gestureState) => true,
    onStartShouldSetResponderCapture: (evt, gestureState) => true,
    onMoveShouldSetResponder: (evt, gestureState) => true,
    onMoveShouldSetResponderCapture: (evt, gestureState) => true,
    onResponderGrant: (evt, gestureState) => {},
    onResponderMove: (evt, gestureState) => {},
    onResponderTerminationRequest: (evt, gestureState) => true,
    onResponderRelease: (evt, gestureState) => {},
    onResponderTerminate: (evt, gestureState) => {},
    //moveThreshold: 5
  });
}

render() {
  
  return (
    <View
      {...this.gestureResponder}>
		...
    </View>
  );
}

The API is quite same of the official one. Differences are:

  1. Every lifecycle callback is called with an additional argument gestureState, which is also quite same as the PanResponder but contains more info.
  2. The config object can provide another value named moveThreshold (defaults to 2 if not provided), which is used to avoid too sensitive move events when simply tap the screen(mainly on Android).

The gesture object has the following(a super set of PanResponder):

  • stateId
  • moveX and moveY
  • x0 and y0
  • dx and dy: accumulated distance of the gesture since the touch started(confusing names)
  • vx and vy: per millisec(PanResponder is inconsistant with different react-native version, as this issue mentioned)
  • numberActiveTouches
  • previousMoveX and previousMoveY: you can use moveX - previousMoveX to calculate latest move distance
  • pinch and previousPinch: useful number values when implementing zoom feature. Will be undefined if no pinch occured
  • singleTapUp: a bool value indicating if a single tap up occured
  • doubleTapUp: a bool value indicating if a double tap up occured

FAQs

Package last updated on 30 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc