-
-
Save arnoldsandoval/fb7cd33138649fc1cb0ac12eb7a1729a to your computer and use it in GitHub Desktop.
React Native - Detect Double Tap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Index = React.createClass({ | |
| getInitialState: function () { | |
| return { | |
| lastPress: 0 | |
| } | |
| }, | |
| onPress: function () { | |
| var delta = new Date().getTime() - this.state.lastPress; | |
| if(delta < 200) { | |
| // double tap happend | |
| } | |
| this.setState({ | |
| lastPress: new Date().getTime() | |
| }) | |
| }, | |
| render: function() { | |
| return ( | |
| <TouchableHighlight onPress={this.onPress}></TouchableHighlight> | |
| ) | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment