Skip to content

Instantly share code, notes, and snippets.

@chirag04
Created May 13, 2015 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chirag04/d0da460e13eabacce6ee to your computer and use it in GitHub Desktop.
Save chirag04/d0da460e13eabacce6ee to your computer and use it in GitHub Desktop.
panResponder gist
var WithLabel = React.createClass({
responder: PanResponder.create({
onStartShouldSetResponderCapture: (evt) => true,
onStartShouldSetPanResponder: (evt) => true,
onMoveShouldSetPanResponder: (evt) => true,
onPanResponderGrant: this.handlePress,
onPanResponderMove: this.handlePress,
onPanResponderRelease: this.handlePress,
onPanResponderTerminate: this.handlePress,
}),
handlePress: function() {
console.log('press');
},
render: function() {
return (
<View style={styles.labelContainer}>
<View style={styles.label}>
<Text>{this.props.label}</Text>
</View>
<View {...this.responder.panHandlers} style={styles.labelContainer}>
{this.props.children}
</View>
</View>
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment