Sig Posted September 21, 2022 Share Posted September 21, 2022 Hey, I'm trying to animate 3 circles from the center of an SVG to a specific position, to do so i'm animating the cx and cy properties but the animation seems wrong. Instead of starting from the center and animating to the specified position, the circles start from the right. Can anyone help me understand the issue? I've tried changing the transform-origin of the circles but with no results. The codepen link is: See the Pen KKRvyBX by signoo (@signoo) on CodePen Link to comment Share on other sites More sharing options...
Solution GreenSock Posted September 22, 2022 Solution Share Posted September 22, 2022 Welcome to the forums, @Sig! I noticed several problems: You're trying to animate "cx" and "cy" attributes but you're treating them as regular CSS properties. Some browsers recognize that, others don't. I definitely would not recommend animating those that way. You should use the attr:{...} wrapper to tell GSAP you want to animate the actual attributes (not inline CSS properties). However... You're animating between two completely different units ("%" and "px"). That won't work with attributes - you should stay consistent. That's easy enough for you to convert. For example, you could change cx="50%" to cx="257.46" because your viewBox has a width of 514.919. However... I personally think it'd be much cleaner to leave the cx/cy as-is and instead, animate the "x" and "y" transforms like this: See the Pen QWrMaXY?editors=1010 by GreenSock (@GreenSock) on CodePen Minor notes: You don't have to explicitly set the durations to 0.5 because that's the default anyway You don't need to wrap everything in a setTimout() to get it to wait 2 seconds. Just add a delay: 2 to your timeline. You don't need to pause the timeline initially and then seek(0).play() on the same tick. It's fine to do, but it's totally unnecessary. Animations play immediately from their beginning by default. "out" is the default kind of ease, so you can do "power4" instead of "power4.out". It's not "wrong" either way. I'm just looking for ways to simplify your code. Does that help? 1 Link to comment Share on other sites More sharing options...
Sig Posted September 22, 2022 Author Share Posted September 22, 2022 @GreenSock Yes that works perfectly, thank you very much for the explanation and the minor notes Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now