SJH Posted April 17, 2023 Share Posted April 17, 2023 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 More sharing options...
GreenSock Posted April 17, 2023 Share Posted April 17, 2023 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! 1 Link to comment Share on other sites More sharing options...
Rodrigo Posted April 17, 2023 Share Posted April 17, 2023 Hi, Here are a couple of examples using the MotionPath plugin: See the Pen PoBMBXM by GreenSock (@GreenSock) on CodePen See the Pen ExeRygq by GreenSock (@GreenSock) on CodePen Happy Tweening! 1 Link to comment Share on other sites More sharing options...
PointC Posted April 17, 2023 Share Posted April 17, 2023 A couple similar demos from my archive that may be helpful. See the Pen ExVzqdm by PointC (@PointC) on CodePen See the Pen pojmBKJ by PointC (@PointC) on CodePen Happy tweening. 2 Link to comment Share on other sites More sharing options...
SJH Posted April 17, 2023 Author Share Posted April 17, 2023 Your examples are awesome. Thanks for the replies. I went pure JavaScript. Question though: how to flatten the ellipse? It's too tall. See the Pen eYPzVYv by sandalwoodsh (@sandalwoodsh) on CodePen Link to comment Share on other sites More sharing options...
Rodrigo Posted April 17, 2023 Share Posted April 17, 2023 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: 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 More sharing options...
SJH Posted April 17, 2023 Author Share Posted April 17, 2023 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 More sharing options...
Rodrigo Posted April 17, 2023 Share Posted April 17, 2023 Ah, Ok. Well the JS has an ry parameter which I guess stands for radius Y, a smaller value in that parameter should give you a flatter elipse as far as I can tell. Happy Tweening! Link to comment Share on other sites More sharing options...
PointC Posted April 17, 2023 Share Posted April 17, 2023 Stops by again and whispers *be lazy. use the MotionPath plugin*. Get your work done quickly and go for pizza. 🍕. YMMV. 2 Link to comment Share on other sites More sharing options...
SJH Posted April 18, 2023 Author Share Posted April 18, 2023 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 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