Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
JoelC

Set a duration for Timeline.tweenTo()

Recommended Posts

Hi ?

 

I'm using one long timeline for various React states, and the plan is to tween quickly to the correct label when my state changes.

The problem is I can't figure out how to set a static duration (say, 0.5) for the tween in GSAP 3. Is there a way to do this?

 

Also, I'd like the tween to ignore pauses I've added between each state (w/ tl.addPause()). Is this the expected behavior?

 

Thanks!

Link to comment
Share on other sites

Hey Joel, welcome to the forums!

 

You can use tweenTo for this:

const tl = gsap.timeline();
// add to tl, including pauses

// later
tl.tweenTo("someLabel").duration(0.5);

// alternatively make a tween yourself
gsap.to(tl, {duration: 0.5, time: tl.labels["someLabel"], ease: "none"});

Though I believe the default tween duration is 0.5s, so you could leave it out in this case.

 

14 hours ago, JoelC said:

Is this the expected behavior?

What do you mean? 

  • Like 2
Link to comment
Share on other sites

The tweenTo.duration(0.5) version didn't work, but the second one did.

 

Thanks so much!

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