FitBox dst with AnimatedProp? #1501
-
Hey 👋 I'm trying to render an array of paths with const rects = useComputedValue(() => xPositions.current.map((v, i) => rect(v, 0, 12, 12)), [xPositions])
{array.map((index) => (
<FitBox src={rect(0, 0, 12, 12)} dst={Select(rects, (v) => v[index])}>
<Path
path="M6.709 11.71A.967.967 0 0..."
color={Select(...)}
opacity={Select(...)}
/>
</FitBox>
)} I'm trying to render the arrows in this image: Any chance FitBox |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
This looks good 😇😎 Based on this snippet, I assume that you will be able to refactor your code accordingly? |
Beta Was this translation helpful? Give feedback.
-
Hey all, I'm having a similar issue animating the dst prop of Fitbox and hoping for some advice. A useDerivedValue() as mentioned by William above doesn't seem to be triggering a re-render of the component and I'm not seeing any animation. Here is a simple example: a RRect container and a plus icon (with a gesture handler overlay). A tap extends the height of the container but I want the plus sign to always remain at the bottom. The gesture handler animates down with the container, but the plus icon only moves on a re-render. Things I have tried:
Thanks so much for any help! |
Beta Was this translation helpful? Give feedback.
This looks good 😇😎
behind the scene, FitBox is simply using a function that you can wrap into a useComputedValue (or useDerivedValue is you use Reanimated): https://github.com/Shopify/react-native-skia/blob/main/package/src/renderer/components/shapes/FitBox.tsx#L22
Based on this snippet, I assume that you will be able to refactor your code accordingly?