Jump to content
Search Community

end tween at progress number

geedix test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I know how to start a tween from a certain point in its progress:

tween1.progress(0.33);

But likewise, is there a simple way of stopping a tween at a specified progress point?

My codepen does roughly what I want, but it seems like there should be a more elegant way to finish each tween somewhere in the middle without making a new tween.

 

See the Pen jOpRmqO?editors=1111 by geedix (@geedix) on CodePen

Link to comment
Share on other sites

  • Solution

I had a hard time following your demo based on your question.

 

If you want to make the playhead of a particular tween go from one spot to another (not from the beginning to the end), you can just pause() that tween and then tween its playhead. Here's a simple function that shows how it could be done in a reusable way: 

 

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

tweenFromTo(tween, 0.33, 0.66);

function tweenFromTo(tween, fromProgress, toProgress) {
  tween.pause();
  gsap.fromTo(tween, {progress: fromProgress}, {progress: toProgress, duration: Math.abs(tween.duration() * (toProgress - fromProgress)), ease: "none"});
}

Does that help? There are several other ways you could accomplish this, but I didn't want to overwhelm you :)

 

If you still need assistance, can you please greatly simplify things to just one tween maybe and make the demo illustrate exactly what you're aiming for? 

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