Skip to content

Commit

Permalink
Added onTap prop. (#61)
Browse files Browse the repository at this point in the history
This is fired after the onTouchEnd when the movement
is less the the specified delta.
  • Loading branch information
anicke authored and hartzis committed Jan 24, 2017
1 parent c3bdfad commit 357c38e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const DIRECTIONS = ['Left', 'Right', 'Up', 'Down'];
const initialState = {
swiping: false,
swiped: false,
tap: false,
swipingDirection: '',
swipedDirection: '',
};
Expand All @@ -28,6 +29,7 @@ const initialStateApplied = {
onSwipedRightApplied: true,
onSwipedUpApplied: true,
onSwipedDownApplied: true,
onTapApplied: true,
};

export default class Main extends Component {
Expand Down Expand Up @@ -72,6 +74,14 @@ export default class Main extends Component {
});
}

onTap(...args) {
console.log('onTap args: ', args)
this.setState({
tap: true,
});
}


updateValue(type, value) {
this.setState({
[type]: value,
Expand Down Expand Up @@ -101,10 +111,12 @@ export default class Main extends Component {
swiped,
swipingDirection,
swipedDirection,
tap,
flickThreshold,
delta,
onSwipingApplied,
onSwipedApplied,
onTapApplied,
preventDefaultTouchmoveEvent,
stopPropagation,
nodeName,
Expand All @@ -124,6 +136,9 @@ export default class Main extends Component {
if (onSwipedApplied) {
swipeableDirProps.onSwiped = (...args)=>this.onSwiped(...args);
}
if (onTapApplied) {
swipeableDirProps.onTap = (...args)=>this.onTap(...args);
}

return (
<div className="row">
Expand Down Expand Up @@ -164,6 +179,13 @@ export default class Main extends Component {
</td>
<td>onSwiped</td><td>{swiped ? 'True' : 'False'}</td>
</tr>
<tr style={{color: onTapApplied ? '#000000' : '#cccccc'}}>
<td className="text-center">
<input type="checkbox" checked={onTapApplied}
onChange={(e)=>this.updateValue('onTapApplied', e.target.checked)} />
</td>
<td>onTap</td><td>{tap ? 'True' : 'False'}</td>
</tr>
<tr>
<td className="text-center"><a href="#appliedDirs">↓&nbsp;Below&nbsp;↓</a></td>
<td>onSwiping[Direction]</td><td>{swipingDirection}</td>
Expand Down

0 comments on commit 357c38e

Please sign in to comment.