React component to detect touch gestures
npm install react-gesture-handler
npm i react-gesture-handler hammerjs --save
npm i @types/hammerjs --save-dev
`
$3
Example with pan
`
import * as React from "react";
import { Gestures } from "react-gesture-handler";
const MyComponent = () => {
const [eventType, setEventType] = React.useState("");
const handleGesture = (event: HammerInput) => setEventType(event.type);
return (
recognizers={{
Pan: {
events: {
panleft: handleGesture,
panright: handleGesture,
panup: handleGesture,
pandown: handleGesture
}
}
}}
>
Gesture Section {eventType && - This is ${eventType}}
);
};
``