Jump to content
Search Community

Invalidate delays in a TimelineMax object

Pinto test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hello. In the beginning on my code I declare a new TimelineMax object, and I add a new tween that has a delay using the to() method (this is a simplified version, i do add more tweens to this Timeline). The delay is defined by a previously declared variable (var).

var tl = new TimelineMax()
 .to("#answerTextarea", 1, {
  someProp: "value",
  delay: delayVariable
 })

After this, delayVariable changes. When i replay the tl though, the delay is not equal to the new value. I tried invalidating tl using the invalidate() method, but this doesn't invalidate the delay.

How should I proceed so that the delay is updated everytime I restart the tl?

Link to comment
Share on other sites

That's not related to GSAP - that's just how JavaScript works. The value is swapped in immediately for that variable, thus it doesn't somehow know to updated it later on when you change the variable. If your goal is to change where that tween sits on the timeline, you could update it manually whenever you update your variable:

var tween = TweenLite.to("#answerTextarea", 1, {someProp:"value"});
var delayVariable = 1; //or whatever
var tl = new TimelineMax();
tl.add(tween, delayVariable);

function updateDelayVariable(value) {
    delayVariable = value;
    tween.startTime(value); 
}
  • Like 1
Link to comment
Share on other sites

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...