Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- componentWillMount() {
- this.panGesture = PanResponder.create({
- onMoveShouldSetPanResponder: (evt, gestureState) => {
- return (
- this.isValid(gestureState.dx, gestureState.dy) &&
- this.state.isTouched
- );
- },
- onPanResponderMove: (evt, gestureState) => {
- this.moveView(gestureState);
- },
- onPanResponderRelease: (evt, gestureState) => {
- this.moveFinished(gestureState);
- }
- });
- }
- ...
- moveFinished(gestureState) {
- const position = new Animated.Value(gestureState.moveY);
- Animated.spring(position, {
- toValue: this.state.endPosition,
- useNativeDriver: true,
- velocity: gestureState.vy
- }).start();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement