Created
August 29, 2017 19:10
-
-
Save dk0r/c31dde993d602cfe39695feba287ff87 to your computer and use it in GitHub Desktop.
Attempting to capture responder-lock from a child on line-13/14
This file contains 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
export default class Schedule extends Component { | |
constructor(props) { | |
super(props) | |
const position = new Animated.ValueXY() | |
const panResponder = PanResponder.create({ | |
//Ask to be the responder: | |
onStartShouldSetPanResponder: () => true, | |
//This is how you capture 'Responder Lock' from a nested view (note: the most nested view receives responder lock by default) | |
//https://facebook.github.io/react-native/docs/gesture-responder-system.html#capture-shouldset-handlers | |
onStartShouldSetResponderCapture: () => true, | |
onMoveShouldSetResponderCapture: () => true, | |
// The most recent move distance is gestureState.move{X,Y}. | |
// The accumulated gesture distance since becoming responder is | |
// gestureState.d{x,y} | |
onPanResponderMove: (event, gestureState) => { | |
//console.log(gesture) | |
position.setValue({ x: gestureState.dx, y: gestureState.dy }) | |
}, | |
// The user has released all touches while this view is the | |
// responder. This typically means a gesture has succeeded | |
onPanResponderRelease: () => { | |
//position.flattenOffset() | |
} | |
}) | |
this.state = { panResponder, position } | |
} | |
render() { | |
return ( | |
<Animated.View | |
{...this.state.panResponder.panHandlers} | |
style={ this.state.position.getLayout()} | |
> | |
<View> | |
<DrawerButton {...this.props} /> | |
</View> | |
</Animated.View> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment