react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

Swipeable: How to convert RN Animated.AnimatedInterpolation<number> to Reanimated Adaptable<number>

Open MikePodgorniy opened this issue 6 years ago • 5 comments

How to convert RN Animated.AnimatedInterpolation to Reanimated Adaptable It is possible to use Swipeable with react-native-reanimated?

https://software-mansion.github.io/react-native-gesture-handler/docs/component-swipeable.html#renderleftactions https://github.com/software-mansion/react-native-gesture-handler/blob/master/Swipeable.js

react-native-gesture-handler/Swipeable.js

 /**
     *
     * This map describes the values to use as inputRange for extra interpolation:
     * AnimatedValue: [startValue, endValue]
     *
     * progressAnimatedValue: [0, 1]
     * dragAnimatedValue: [0, +]
     *
     * To support `rtl` flexbox layouts use `flexDirection` styling.
     * */
    renderLeftActions?: (
      progressAnimatedValue: Animated.AnimatedInterpolation,
      dragAnimatedValue: Animated.AnimatedInterpolation
    ) => React.ReactNode;

Reanimated:

 export type Adaptable<T> =
      | T
      | AnimatedNode<T>
      | ReadonlyArray<T | AnimatedNode<T> | ReadonlyArray<T | AnimatedNode<T>>>;

MikePodgorniy avatar May 13 '20 14:05 MikePodgorniy

Solution: https://github.com/iyegoroff/react-native-reanimated-swipeable-views

MikePodgorniy avatar May 15 '20 12:05 MikePodgorniy

@MikePodgorniy Could you share with me what is the solution? I checked your repo and raw you rebuild the swipeable component instead of converting Animated.AnimatedInterpolation to AnimatedNode.

tuanmai avatar Jul 10 '20 08:07 tuanmai

https://gist.github.com/MikePodgorniy/5ffeba5c08879de0eb82978d0cf3fac3

you need to use translation from render callback https://github.com/iyegoroff/react-native-reanimated-swipeable-views/blob/master/src/swipeable.tsx

MikePodgorniy avatar Jul 10 '20 09:07 MikePodgorniy

@MikePodgorniy Could you share with me what is the solution? I checked your repo and raw you rebuild the swipeable component instead of converting Animated.AnimatedInterpolation to AnimatedNode.

I can't see the line where the conversion takes place, can you please help me out here @tuanmai?

maxfahl avatar Sep 27 '21 09:09 maxfahl

Is possible?

ser-emejia avatar Sep 06 '24 18:09 ser-emejia