swipe-react
Easy integration!!! Easily add touch devices support (smartphones, tablets) to your react components, with swipe direction detection.
Usage
- Install the npm package:
npm install --save swipe-react
- Import it:
import SwipeReact from 'swipe-react';
- Config swipe events ('left', 'right', 'up', 'down'), at least one of them, in your component constructor, or in render function:
SwipeReact.config({
left: () => {
console.log('Swipe left detected.');
},
right: () => {
console.log('Swipe right detected.');
},
up: () => {
console.log('Swipe up detected.');
},
down: () => {
console.log('Swipe down detected.');
}
});
- Integrate with your React component:
<YourComponent {...SwipeReact.events} />