Jump to content
Search Community

Radius behavior for 'rotation' type liveSnap

Nameless415 test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hey guys, hope you all are having a great week!

 

Is there any way I can achieve the 'radius' functionality using the 'rotation' type Draggable? I tried hacking my way into it but no good

 

My problem is that when defining the liveSnap property on a 'rotation' Draggable, the grabbed element just instantly jumps from snap to snap instead of smoothly rotating around and then locking position once it is close enough to a given snap point (like what happens when using a 'x,y' type Draggable:

See the Pen wgapaY by GreenSock (@GreenSock) on CodePen

)

 

This codepen is the closest I've found to the result that I want, it works fine the way it is, but as soon as you add liveSnap: true, the dragging just becomes truncated ⬇️

 

Thanks in advance! :D

See the Pen BabLjzN by GreenSock (@GreenSock) on CodePen

Link to comment
Share on other sites

  • Solution

As far as I can tell, it's doing exactly what it's supposed to do there. Are you saying that you want it to only snap when it's within a certain range of one of the target rotation values, but the rest of the time it just freely moves? You'd have to build that into your liveSnap function logic, like so: 

See the Pen Babvqww?editors=1010 by GreenSock (@GreenSock) on CodePen

 

That snaps whenever it's within 5 degrees of a snapping spot.

  • Thanks 1
Link to comment
Share on other sites

Oh wow that was simpler than I thought HAHAHAHAHAHA

 

That's exactly what I want, you are an absolute BEAST Jack!

 

I was doing the utmost dreadful shenanigans to try and get this behavior... Guess I just don't have enough experience with the tool yet

 

Thank you so much!

tenor.gif

Link to comment
Share on other sites

No problem! Glad it helped. Yeah, I've been in your shoes where I spent massive amounts of time crafting complicated code, only to later see a far simpler, more elegant solution and I was like "okay, I feel dumb now". (Not that you're dumb!) 

 

Onward and upward. 🙌

  • Like 1
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...