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:
;
- Config swipe events ('left', 'right', 'up', 'down'), at least one of them, in your component constructor, or in render function:
SwipeReact;
- Integrate with your React component:
<YourComponent ...SwipeReactevents />
Example
;; { superprops; thisstate = content: 'Swipe here!' ; SwipeReact; } { let styles = height: '400px' fontSize: '34px' textAlign: 'center' ; return <div ...SwipeReactevents tabIndex="1" style=styles> thisstatecontent </div> ; } ;
Remarks
- You need to test it on a touch screen device, or open Smartphone/Tablet mode on Chrome Developer Tools.