Jump to content
Search Community

Position SVGs on an ellipse

SJH test
Moderator Tag

Recommended Posts

Is there any easy GSAP equation to loop through a collection of SVG groups and place them on an ellipse or possibly other shapes? I'm trying to resize my parent SVG to any mobile device screen and then position the SVG icons based on the new screen width and height. In the codepen example I've hard coded them into place but I'd like to do that programmatically.

See the Pen JjmKOLo by sandalwoodsh (@sandalwoodsh) on CodePen

Link to comment
Share on other sites

For circles/ovals there's relatively simple math stuff you can do with Math.cos()/Math.sin() and radius.

 

If you've got a <path> that you want to put things on, you could probably use a motionPath and then simply adjust the progress() of the animation to place them along it appropriately (you don't actually have to animate anything). Give it a shot and if you get stuck, feel free to post back here with your attempt in a CodePen. 

 

Good luck! 

  • Like 1
Link to comment
Share on other sites

Hi,

 

I commented out all your JS code and there is absolutely no change 🤷‍♂️ I played with the values of the code and didn't make a lot of difference. Take a deeper look into it in order to find out where this is not working properly. Honestly I think you're overcomplicating this quite a bit. Just use 4 points on an svg and make a bezier curve with them, something like this:

EEVgNZL.png

Then you can play around in your JS with the points and control points to change it as you need.

 

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

I know the JS code makes little difference in its current state. I matched it to what I had previously. I plan to make the shape dynamic by binding the ellipse in Nuxt and stretching it to various screen sizes.

Link to comment
Share on other sites

Whispers to PointC, "But the motion path examples listed here are way beyond what I need to do. I need something drop dead simple...then maybe I could stretch the path to fill different mobile screens."

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