Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. componentWillMount() {
  2. this.panGesture = PanResponder.create({
  3. onMoveShouldSetPanResponder: (evt, gestureState) => {
  4. return (
  5. this.isValid(gestureState.dx, gestureState.dy) &&
  6. this.state.isTouched
  7. );
  8. },
  9. onPanResponderMove: (evt, gestureState) => {
  10. this.moveView(gestureState);
  11. },
  12. onPanResponderRelease: (evt, gestureState) => {
  13. this.moveFinished(gestureState);
  14. }
  15. });
  16. }
  17.  
  18. ...
  19.  
  20. moveFinished(gestureState) {
  21. const position = new Animated.Value(gestureState.moveY);
  22. Animated.spring(position, {
  23. toValue: this.state.endPosition,
  24. useNativeDriver: true,
  25. velocity: gestureState.vy
  26. }).start();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement