Samaritan Posted May 6, 2021 Share Posted May 6, 2021 Hi, I've got a main timeline and a number of child timelines, each of the child timelines controls a lottie animation and some html elements and moves them around in sync. All of it is working well however as we load the animations in and create the timelines for them, which can take a few seconds, some of the child timelines towards the end of the main timeline are affecting the html elements as they get created and I'd really like them not to, as it makes a bunch of things jump around during that loading process. You can see a cut down version of the problem in the attached codepen, if we add the tl2 directly to the main timeline without the setTimeout then it acts as we would expect, but with the setTimeout you can see that the item gets positioned to the start of the second child ani on load, but once the ani starts it acts as expected. Any help appreciated. See the Pen OJpJObN by SamaritanAU (@SamaritanAU) on CodePen Link to comment Share on other sites More sharing options...
Solution GreenSock Posted May 6, 2021 Solution Share Posted May 6, 2021 Yeah, you definitely shouldn't be creating your ScrollTrigger and attaching that timeline when it's not done populating. It's actually empty at that point, so it causes logic issues if you're trying to scrub something that has zero time. I'd recommend structuring your code so that's your last step (attaching it to the ScrollTrigger). Move your ScrollTrigger.create() inside your setTimeout() to see what I mean. Does that help? 1 Link to comment Share on other sites More sharing options...
Samaritan Posted May 6, 2021 Author Share Posted May 6, 2021 Thanks Jack - based on your response I've separated the the Lottie loading and the timeline creations, in effect moving the creation of the child timeline into the setTimeout function. See the Pen rNyNdvq by SamaritanAU (@SamaritanAU) on CodePen 1 Link to comment Share on other sites More sharing options...
GreenSock Posted May 6, 2021 Share Posted May 6, 2021 13 hours ago, Samaritan said: Thanks Jack - based on your response I've separated the the Lottie loading and the timeline creations, in effect moving the creation of the child timeline into the setTimeout function. Great. And it's working well for you, right? Looks good to me. 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