Jump to content
Search Community

how to make 2 box with different speed?

ajnglagla test
Moderator Tag

Go to solution Solved by GreenSock,

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

Hello,

 

I am new on GSAP, I have 2 boxes, They have spesific different starting point. Basicly I want them marquee on the screen.

 

But my problem is this 2 boxes always arrive the "final point" at the same time :/ I want them have their own constant speed.

They shouldnt move together, 1st box should be front of the 2nd one.

 

How can I make this right, any suggestion please?

See the Pen YqLaQM by ajnglagla (@ajnglagla) on CodePen

  • Like 1
Link to comment
Share on other sites

  • Solution

If I understood your goal properly, I think you could simplify things a lot by doing it this way: 

https://codepen.io/anon/pen/aNGaZx?editors=0110

 

It just creates a tween for each that goes from the right to the left (all the way), and then simply adjusts the progress of that tween according to where it's supposed to start on the screen. 

 

By the way, I would strongly recommend animating the "x" instead of "left" because in most cases it'll perform much better. Transforms require less CPU and they can do sub-pixel rendering, so it won't look as jerky as it moves ("left" always snaps to whole pixels...that has nothing to do with GSAP - it's just a browser thing). 

  • Like 2
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...