Set up shared values for a collection of elements #1733
Unanswered
matthiasferch
asked this question in
Q&A
Replies: 1 comment
-
One simple way to do this would be to create a separate component out of your circle, and hook into animated props from within it. Rough example: function MyCircle(circle) {
const animatedProps = useAnimatedProps(() => {
return { r: radius.value };
});
return <AnimatedCircle cx={circle.cx + 10} cy={circle.cy} animatedProps={animatedProps} fill={'black'} />
} // ...
return (
<Svg>
{
circles.map((circle, index) => {
return <MyCircle key={index} circle={circle} />
})
}
</Svg>
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using
react-native-svg
to draw a collection of shapes. I want to animate those shapes in succession with a short delay between them. I know I can set up the animations with a combination ofwithDelay
andwithSpring
but I'm not sure how to set up the shared values.The following component draws ten circles but so far, only the last one's radius will be animated, presumably because one set of animated props can only be used by one element. So how would I set up the shared values so I can track one animation per circle and start them independently?
Beta Was this translation helpful? Give feedback.
All reactions