Jump to content
Search Community

Reverse until a certain point

serotoninene test
Moderator Tag

Recommended Posts

Hi ! 

I'd like to know if it's possible to reverse a timeline until let's say half of it ? I've tried seek() and progress() but it restart the timeline every time instead of playing back til halfway. There must be a super easy way of doing this, plz share it with me ! 

Good day from France :) 

Link to comment
Share on other sites

Hi @serotoninene a minimal demo would have been nice, I now had to create one from scratch.

 

But here is an example that uses `.tweenTo()` too animate to a label I've defined in a timeline. I've placed the label in the middle of the timeline, but you can put it anywhere you want. 

 

See the Pen Exorxoy by mvaneijgen (@mvaneijgen) on CodePen

  • Like 5
Link to comment
Share on other sites

Edit: Snap, @mvaneijgen was seconds faster than me 🙃

 

Unless I'm missing something obvious, I don't think that would be possible with the .reverse() method, as you can only pass from where to reverse but not to where.

 

What you might need for this is either to tween the progress of the timeline (note that the explanation on that linked page still uses old syntax, but it is still possible with GSAP3) or to use tweenTo / tweenFromTo and base things of on something like the timeline's .totalDuration()/2 e.g.

 

https://www.snorkl.tv/gsap-tweento-and-tweenfromto/

 

Depending on your exact expected outcome / scenario, one might be more suited than the other, but I think the latter might be what could be most helpful here.

 

See the Pen xxpMKaK by akapowl (@akapowl) on CodePen

 

 

 

Click anywhere in this example to toggle changes:

 

See the Pen WNdPNbg by akapowl (@akapowl) on CodePen

 

  • Like 4
  • Haha 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...