react-swipe-event-component
Extend this component and swipe events are well-handled.
Demo
- Open demo site
- Open browser's Developer Tools, and change device to mobile
- Play~ play~ play~
How to run example locally
npm install -g webpack webpack-dev-server
npm install
npm start
- Open http://localhost:8080 in browser
- Open browser's Developer Tools, and change device to mobile
- Have fun with it =)
How to use it in your project
npm install react-swipe-event-component --save
- Extend ReactSwipeEventComponent instead of Component (import from React). For example:
;; { superprops; // Set tolerance in constructor if you want to customize it this; } // Implement functions you need in your component { /* Do something while swipe left is detected */ } { /* Do something while swipe right is detected */ } { /* Do something while swipe up is detected */ } { /* Do something while swipe down is detected */ } { /* Do something while wheel left is detected */ } { /* Do something while wheel right is detected */ } { /* Do something while wheel up is detected */ } { /* Do something while wheel down is detected */ } // Add {...this.touchEventProperties} to the element which need to detect swipe events { return <div ...thistouchEventProperties > <p>Add the touchEventProperties to the element which need to detect swipe events</p> </div> ; } ;
Others
- Let me know if there's any issue.
- Welcome for submitting PRssss ;)
- Don't hesitate to contribute!
Changelog
[0.2.3] - 2017-08-29
Changed
- README.
- The name of this component in example.
[0.2.2] - 2017-08-29
Added
- Changelog in README.
[0.2.1] - 2017-08-29
Added
- Wheel events.
Changed
- Exchange swipe left and swipe right events to each other.
[0.1.2] - 2017-08-23
Changed
- Fix some inheritance issues.
[0.1.1] - 2017-08-22
Added
- This project.