-
Notifications
You must be signed in to change notification settings - Fork 32
Description
I have defined my timeline as such:
const Component = () => {
const [playState, setPlayState] = useState(PlayState.pause);
return (
<Timeline
playState={playState}
labels={[{ label: 'start', position: 0 }]}
target={<Content />}
>
<Tweens />
</Timeline>
);where <Content /> is a component using react-gsap targets.set to set targets similarly to what is done in the examples.
I want to control my timeline playState using useState inside my <Component /> which contains the <Timeline />.
But every time I change state <Content /> is re-rendered of course. The thing is my playState depends depends on <Content /> (I wait for some elements inside <Content /> to load, then I inform <Component /> that animation can begin and setPlayState(PlayState.play). Because of the re-rendering it is not possible because <Content /> stuff are reloaded, the animation begins before it has fully loaded.
I don't think this is currently possible due how react-gsap is structured because content is a rendered prop of <Timeline />. I understand this was done this way in order to be able to set the targets but IMO we should be able to separate content and animation in the React tree.
I tried to make it clear and I hope I am not doing anything too weird.