Jump to content
Search Community

TweenMax.to doesn't working

Yaaaaar
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

Posted

So, hello everyone. I'm new to all this and i don't know why ball with class "first" isn't moving to left on 2nd click of my button. Would you help me with that, please?

See the Pen JOaoQZ by Yaaaaar (@Yaaaaar) on CodePen.

Posted

I call a function when im clicking on button, that's correct. On first click everything is working correct, but when i'm clicking second time ball that moved to the end does not move to the left. So question is why it isn't moving at second click?

Posted

Hi and welcome to the forums.

 

Thanks for the demo.

 

Open up dev tools when your animations runs and inspect the ball.

 

-xhTK3-2QCKUZQkbNgWDmQ.png

 

You will see that the right value is being animated but you are not seeing any motion.

This is because your first tween is animating the css right value and your bezier tween is animating the css left value.

 

When you run the sequence the second time your ball has left and right styles applied. Animating the right does not affect the position because left is already set.

 

Please see this reduced test case with no javascript

 

Notice in the css I set right:300px; and left:300px; In this case the browser will only honor the left:300px;

See the Pen ZaMGxo by GreenSock (@GreenSock) on CodePen.

 

 

 

 

  • Like 4
Posted

Try using x and y instead of top, left, right.

x and y use css transforms and you won't have to worry about using 2 properties (left, right) fighting for control of position on the same axis.

Something like:

 

See the Pen NwLqov?editors=0010 by GreenSock (@GreenSock) on CodePen.

 

  • Like 4
  • Thanks 1
Posted

I didn't even think about it, thank you very much for the quick response. Problem solved, you guys are awesome!

  • Thanks 1

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