Jump to content
Search Community

timeScale as creation parameter

Thomas James Thorstensson test
Moderator Tag

Recommended Posts

Hello, 

 

It seems to set timeScale I can not set it as creation parameter. Maybe I forgotten something here as I think I've done that before:

 

  this.tl = gsap.timeline({
    repeat: defaultValues.customVariable3,
    repeatDelay: 2,
    
    // THIS DOESNT WORK
    timeScale: defaultValues.customVariable5 || 1   // * this will later be defaultValues.animationSpeed
  });

  // THIS WORKS!
  this.tl.timeScale(defaultValues.customVariable5 || 1)

Not a biggie as the second works but just checking if any fellow GSAP Mphil could advise me on why the first does not.

 

Stay green, stay alive

 

Thomas

Link to comment
Share on other sites

Yep, this is all very intentional. The problem is that it's relatively common for people to want to animate the timeScale of other animations, so what would you expect this to do?: 

let animation = gsap.to(...);

// umm...should this tween's timeScale be 0.5 to start or should we animate animation.timeScale() to 0.5???
gsap.to(animation, {timeScale:0.5, duration:2});

See the problem? It's inherently ambiguous. 

 

So to set the initial timeScale of a tween, you can just use the timeScale() method which is quite easy with chaining:

gsap.to(...).timeScale(0.5)

Does that clear things up? 

  • Like 2
Link to comment
Share on other sites

25 minutes ago, GreenSock said:

Yep, this is all very intentional. The problem is that it's relatively common for people to want to animate the timeScale of other animations, so what would you expect this to do?: 


let animation = gsap.to(...);

// umm...should this tween's timeScale be 0.5 to start or should we animate animation.timeScale() to 0.5???
gsap.to(animation, {timeScale:0.5, duration:2});

See the problem? It's inherently ambiguous. 

 

So to set the initial timeScale of a tween, you can just use the timeScale() method which is quite easy with chaining:


gsap.to(...).timeScale(0.5)

Does that clear things up? 

 

Ahaaaa. Thanks for clarifying. Yes I can see the point now and it makes sense to me.

 

Thanks for taking time!

 

Thomas, over a cup of coffe!

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