Jump to content
Search Community

Updating a Tween position(x) after its initial completion

SammyC123 test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

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

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