Jump to content
GreenSock

one2gov

transform in timeline relative to previous position

Go to solution Solved by OSUblake,

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

If i repeat timeline comand

tl.from(head, 0.5, {left:100});

it will repeat objects movement stating from position defined in css.

 

Is it possible to move same object several times from previous position?

 

So instead of 

tl.from(head, 0.5, {left:100}); - 100px

tl.from(head, 0.5, {left:200}); - 100px

tl.from(head, 0.5, {left:300}); - 100px

 

it would be 

tl.from(head, 0.5, {left:100}); - 100px

tl.from(head, 0.5, {left:100}); - 100px

tl.from(head, 0.5, {left:100}); - 100px

See the Pen WoGdLQ by one2gov (@one2gov) on CodePen

Link to comment
Share on other sites

  • Solution

It's better to use x/y instead of left/top, but you can do relative movements like this...

tl.set(head, { x: 300 }) // 300
  .to(head, 0.5, { x: "-=100" }) // 200
  .to(head, 0.5, { x: "-=100" }) // 100
  .to(head, 0.5, { x: "-=100" }) // 0
  • Like 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.
×