Jump to content
Search Community

Repeat timeline with new variable value

ijati

Go to solution Solved by mvaneijgen,

Recommended Posts

Posted

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
Posted

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.

  • Like 2
  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...