Skip to content

Instantly share code, notes, and snippets.

@leandrowd
Last active January 29, 2017 08:27
Show Gist options
  • Save leandrowd/e9074b19b8dc23a8b471 to your computer and use it in GitHub Desktop.
Save leandrowd/e9074b19b8dc23a8b471 to your computer and use it in GitHub Desktop.
Demo React Easy Swipe
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import Swipe from './react-swipe';
class MyComponent extends Component {
onSwipeStart(event) {
console.log('Start swiping...', event);
}
onSwipeMove(position, event) {
console.log(`Moved ${position.x} pixels horizontally`, event);
console.log(`Moved ${position.y} pixels vertically`, event);
}
onSwipeEnd(event) {
console.log('End swiping...', event);
}
render() {
const boxStyle = {
width: '100%',
height: '300px',
border: '1px solid black',
background: '#ccc',
padding: '20px',
fontSize: '3em'
};
return (
<Swipe
onSwipeStart={this.onSwipeStart}
onSwipeMove={this.onSwipeMove}
onSwipeEnd={this.onSwipeEnd}>
<div style={boxStyle}>Open the console and swipe me</div>
</Swipe>
);
}
}
ReactDOM.render(<MyComponent/>, document.getElementById('root'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment