Jump to content



Go to solution Solved by GreenSock,

Recommended Posts

Is there a bool value somewhere to determine if a draggable is snapped?

I want to use that data elsewhere.

Link to comment
Share on other sites

I don't quite understand your question - are you asking if there's a way to find out of any "snap" value was passed into the vars (config) object? If so, draggableInstance.vars.snap. Otherwise, no, but of course you could use a function-based snap value so that inside that function you can record a variable or whatever you want. 

Link to comment
Share on other sites


I'm using liveSnap to move a draggable. When the draggable gets snapped (due to being within the radius I set), I want to set a variable to true. That variable would indicate that the draggable has been live snapped. Since I'm using liveSnap, would I need to look for another property instead of "draggableInstance.vars.snap". I ask because I don't see such a property when printing the object to console.

If there isn't a property already made I'll just manage my own, as you suggested.

Link to comment
Share on other sites

  • Solution

No, there's no such property that toggles only when something has snapped (or live-snapped). You'll need to manage that on your own. If you just want to know if a liveSnap value was defined at all on the Draggable, yourInstance.vars.liveSnap

Link to comment
Share on other sites

This little piece of code is working for me, but if there is a property that already exists called something like draggableInstance.vars.points.isSnapped, that'd be even better.


: {
     points: function(point) {
          // Some logic to determine the closest snap point
          let closestSnapPoint = {x: someNumber, y: someNumber};
          if (closestSnapPoint.x == this.x && closestSnapPoint.y == this.y) self.isSnappedTogether = true;
          else self.isSnappedTogether = false;


Thanks for responding so quickly.

Edit: Okay, no property like that, thanks!

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.