ijati Posted December 8, 2022 Posted December 8, 2022 Hi there! I have a question about how to update variable value on timeline repeat. I'm trying to update position value when the timeline is repeat, but it seems the timeline not reflecting the new value of variable when the timeline repeat. How can I achieve this? Sorry for the broken English. Thanks. See the Pen zYaboJK by potator (@potator) on CodePen.
Solution mvaneijgen Posted December 8, 2022 Solution Posted December 8, 2022 Hi @ijati welcome to the forum! I've tweaked your pen a bit and placed comments at certain lines were I thought and explanation would be useful. Mainly I've moved to function based values and I've set repeatRefresh: true to your timeline, this will invalidate the previous values and uses the new ones. I think there is something missing with the logic, but I can't figure out what you want them to do, but maybe in this case a .fromTo() tween would be more useful, then you can tell it where to start from and where to go to each time. I also would recommend taking a look at the he utils functions from GSAP https://greensock.com/docs/v3/GSAP/gsap.utils there are some really handy once that would apply to your problem. Hope it helps and happy tweening! See the Pen xxzBqyK?editors=0011 by mvaneijgen (@mvaneijgen) on CodePen. 2 1
ijati Posted December 8, 2022 Author Posted December 8, 2022 Hi @mvaneijgen thanks for your guide and pointer. I achieved what I want to do by changing your code a bit. many thanks! See the Pen abKMqdO by potator (@potator) on CodePen. 1
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