Amnesicat Posted August 7, 2023 Share Posted August 7, 2023 Hi, I'm trying to emulate something like this - I tried doing a forEach to dynamically capture all item elements, create fromTo tweens into separate child timelines and then add them to a main timeline to enable expand all items etc. (see codepen), but it's not working as intended. The item animations work fine on there own but when I add them to the main timeline they mess everything up. Can you control nested GSAP timelines individually like this, or is there a better way to do it? Any guidance or examples on how to do this properly would be greatly appreciated. Thanks a lot, Alan See the Pen gOQygvm by Amnesicat (@Amnesicat) on CodePen Link to comment Share on other sites More sharing options...
Solution mvaneijgen Posted August 7, 2023 Solution Share Posted August 7, 2023 Hi @Amnesicat I would just collect all the timelines in an array and then just play the timelines or reverse them. This is just a quick example, you could certainly build it to always reverse first if any timeline has already played. And check if all timelines are played then set the played value to true and then it will reverse them all, but I'll leave that to you. Hope it helps and happy tweening! See the Pen JjeVyXK?editors=0010 by mvaneijgen (@mvaneijgen) on CodePen 4 Link to comment Share on other sites More sharing options...
Carl Posted August 7, 2023 Share Posted August 7, 2023 wow, @mvaneijgen came in hot 🔥 with a super solution! I was working slower on something very similar so I'll just share it also See the Pen gOQyxMv?editors=0110 by snorkltv (@snorkltv) on CodePen Also, there are times when you want to open one thing and close whatever other this currently open. I have video lesson on this in my GSAP video training, but here's the demo if you want to study the technique. See the Pen YzGpXWO by snorkltv (@snorkltv) on CodePen 3 1 Link to comment Share on other sites More sharing options...
Amnesicat Posted August 7, 2023 Author Share Posted August 7, 2023 Hi, mvaneijgen and Carl, These are two fantastic solutions, thank you so much for your quick responses. Carl, thanks for the other technique too, I'll definitely check that out as well as your videos. Regards, Alan 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now