James0r Posted September 29, 2023 Share Posted September 29, 2023 I see the MotionPathPlugin is for animating along a fixed path (I think). So maybe I'm looking for something different. I'm animating some text between points on the viewport using fromTo() and instead of taking a direct path, I want it to travel along a curve. To be clear, I'm not talking about easing/timing. Any help much appreciated. Link to comment Share on other sites More sharing options...
GSAP Helper Posted September 29, 2023 Share Posted September 29, 2023 It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or Stackblitz that demonstrates the issue? Please don't include your whole project. Just some colored <div> elements and the GSAP code is best. See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer. Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo: See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen Using a framework/library like React, Vue, Next, etc.? CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import the gsap-trial NPM package for using any of the bonus plugins: React (please read this article!) Next Svelte Sveltekit Vue Nuxt Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. Link to comment Share on other sites More sharing options...
mvaneijgen Posted September 29, 2023 Share Posted September 29, 2023 Hi @James0r welcome to the forum! maybe you're looking for the textPath SVG property? Check out this post If you need any further help, please provide a minimal demo demonstrating your issue, so we can take a look for you. Hope it helps and happy tweening! 2 Link to comment Share on other sites More sharing options...
James0r Posted October 1, 2023 Author Share Posted October 1, 2023 It might be super basic and perhaps textPath is the way to go, but just thought there might be some helpers that auto-magically help with this. Here's my minimal reproduction: See the Pen mdajqeO by James0r (@James0r) on CodePen I'm working with words transitioning from their place in a paragraph up to their final location. Because of this they will be at different X coordinates within the paragraph. I want them to follow a smooth curved path to their final destination. Something like the images below: Link to comment Share on other sites More sharing options...
GreenSock Posted October 1, 2023 Share Posted October 1, 2023 I wouldn't recommend animating top and left - it's much cheaper to animate x and y (transforms). As for animating along a curved path, you can use MotionPathPlugin for that. You can pass in an Array of coordinates. Sorta like: // plot a curve through these coordinates. The target's current coordinates will automatically be added to the start: motionPath: [{x:100, y:50}, {x:200, y:0}, {x:300, y:100}] Pro tip: you can fake a curved path by using a different ease for x and y. For example, "none" for y and "power3.in" for x would give you something like that 2nd image. Good luck! Link to comment Share on other sites More sharing options...
James0r Posted October 2, 2023 Author Share Posted October 2, 2023 On 10/1/2023 at 2:50 PM, GreenSock said: I wouldn't recommend animating top and left - it's much cheaper to animate x and y (transforms). As for animating along a curved path, you can use MotionPathPlugin for that. You can pass in an Array of coordinates. Sorta like: // plot a curve through these coordinates. The target's current coordinates will automatically be added to the start: motionPath: [{x:100, y:50}, {x:200, y:0}, {x:300, y:100}] Pro tip: you can fake a curved path by using a different ease for x and y. For example, "none" for y and "power3.in" for x would give you something like that 2nd image. Good luck! Thanks. I changed my fromTo() to use translate instead of fixed positioning, but I'm not sure how I would achieve the faked curved path with x and y if I'm using them already for my from and to coordinates. Can you provide an example? Link to comment Share on other sites More sharing options...
mvaneijgen Posted October 2, 2023 Share Posted October 2, 2023 Hi @James0r, something like this? If you have further questions please post a demo with the code you've tried, that way we can see where you are in the process. Forking your pens is a great idea, so that you can fall back on earlier ideas if something is not working. Hope it helps and happy tweening! See the Pen BavPgZw?editors=1010 by mvaneijgen (@mvaneijgen) on CodePen 2 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