Jump to content
GreenSock

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

Updating a Tween position(x) after its initial completion

Recommended Posts

I've read through the docs, and I understand invalidate() and updateTo(), but I'm unclear on proper implementation (or if they're even a good idea here).

 

My goal is relatively simple: I want an element to continually move from left to right across the viewport (e.g. .fromTo(element, 3, {x:'0%'}, {x:'100%', repeat:-1})).

 

The thing is, for the very first tween, I want the element to start at left: 50%. So on the first pass, it starts in the middle and goes right. Subsequent passes go fully from left to right.

 

Is this a job for updateTo()?  Is there a better implementation?

Link to comment
Share on other sites

Hi you can use a timeline to control that effect. Note, that progress is from 0 to 1. So if you having easing effect, you need to find the exact time where the thing is center. Alternatively, you can do also do a double TweenMax.to on a timeline and add labels in between.

 

Note, you can also use x instead of left but I'm just showing the concept. If you need to use x, you can make changes to how your css is styled
 

See the Pen owEpjV by nickngqs (@nickngqs) on CodePen

 

  • Like 3
Link to comment
Share on other sites

Wow, how have I never used .progress() before?!? Amazing. Thanks, man!

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