Jump to content
Search Community

MotionPathPlugin + Draggable + React to create a Knob - Question

p0lm0n3ys test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Codesandbox here. I've been able to build this thanks to some threads on the forum, new to gsap...

I think the issue is easier to explain playing with the demo than with words, the goal is to avoid the outer blue circle to rotate the way it does. I've been playing with different values for `transformOrigin` but no luck. What am I missing ? 

TIA

Link to comment
Share on other sites

  • Solution

Yeah, that's because you set the transformOrigin incorrectly - the bounding box of the group includes all the stuff in it, so the center is offset due to the stuff leaking outside the circle. 

 

You can just set the exact coordinates with svgOrigin: 

https://codesandbox.io/s/modest-lewin-mbeyi5?file=/src/Knob.tsx

 

Also, it's a good idea to get in the habit of using gsap.context() for easy cleanup in React. Please read this: 

Happy dragging!

 

 

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

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