DeDX Posted May 15, 2022 Share Posted May 15, 2022 Hello! I want to move the purple block along the path I've draw in the SVG. This is one section of my website which uses gsap all over the page. Rest of the page can be easily selected using the ref but when I use MotionPath, It throws Invalid scope and Target not found error. Here's the codesandbox: https://codesandbox.io/s/gsap-motionpath-react-bkscsf?file=/src/App.js Thank You! Link to comment Share on other sites More sharing options...
Cassie Posted May 15, 2022 Share Posted May 15, 2022 Seems like this is working without the scoped selector but not with...https://codesandbox.io/s/gsap-motionpath-react-forked-miy8hl?file=/src/App.js Not sure why. Maybe @OSUblake will be able to give some insight? Link to comment Share on other sites More sharing options...
Solution GreenSock Posted May 16, 2022 Solution Share Posted May 16, 2022 I'm definitely not a React guy, but I think the problem may be that you're trying to reference ".App" before it even exists. You could use the ref instead because GSAP's selector is smart enough to check for .current on the object you pass in: // BAD const appRef = useRef(null); const el = gsap.utils.selector(".App"); // GOOD const appRef = useRef(null); const el = gsap.utils.selector(appRef); Does that help? 1 Link to comment Share on other sites More sharing options...
Cassie Posted May 16, 2022 Share Posted May 16, 2022 I tried that and it wasn't working. 🙃 Paging @OSUblake for his shift in the React mines 1 Link to comment Share on other sites More sharing options...
DeDX Posted May 28, 2022 Author Share Posted May 28, 2022 The solution was to initialize gsap.selector inside useLayoutEffect and to use a completely different timeline for motionpath instead of chaining it with tweens. Thank you cassie and greensock for help! 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