Search code examples
react-nativerotationgesturemulti-touch

Rotating Multitouch Gesture in React Native


Are there any limitations/drawbacks to multitouch gestures, when using React Native?

For example, I want to rotate an item on the screen by holding+dragging two fingers on it in opposing directions:

enter image description here


Solution

  • Check this out react-native-easy-gestures

    import Gestures from 'react-native-easy-gestures';
    
    /**
     * Another example:
     * Drag only on x axis;
     * Scale from 0.1 to 7;
     * Do not rotate;
     * On release callback;
     */
    <Gestures
      draggable={{
        y: false,
      }}
      scalable={{
        min: 0.1,
        max: 7,
      }}
      rotatable={false}
      onEnd={(event, styles) => {
        console.log(styles);
      }}
    >
      <Image
        source={photo}
        style={{
          width,
          height,
        }}
      />
    </Gestures>