I need some clarification about the PanResponder API in React native. This is the simplest implementation (found in the Animated Docs):
class DraggableView extends React.Component {
constructor(props) {
super(props);
this.state = {
pan: new Animated.ValueXY(), // inits to zero
};
this.state.panResponder = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onPanResponderMove: Animated.event([null, {
dx: this.state.pan.x, // x,y are Animated.Value
dy: this.state.pan.y,
}]),
onPanResponderRelease: () => {
Animated.spring(
this.state.pan, // Auto-multiplexed
{toValue: {x: 0, y: 0}} // Back to zero
).start();
},
});
}
render() {
return (
<Animated.View
{...this.state.panResponder.panHandlers}
style={this.state.pan.getLayout()}>
{this.props.children}
</Animated.View>
);
}
}
focusing only on the onPanResponderMove function, I want to do something like this (following this docs:
onPanResponderMove: (e, gestureState) => {...}
because I need to execute multiple functions within this handler. if I mix the two solutions:
onPanResponderMove: (evt, gestureState) => {
console.log(evt);
console.log(gestureState);
Animated.event([null, {
dx : this.state.pan.x,
dy : this.state.pan.y
}]);
},
it doesn't work. How can I execute multiple functions in this handler? thanks.