Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
AustinNotAustin

Is there a property defining a draggables center value?

Go to solution Solved by PointC,

Recommended Posts

Hello again,

 

When dragging a div, I was expecting the x and y coord of the draggable obj to be the center of the div.

It doesn't seem to be the case. Is there a centerX property? I didn't see one in the docs.

If not, I can calculate it.

See the code pen example to understand why the center point is valuable to me. Red background color is representative of the closest element to my currently held draggable element. (Using the center point to determine which element is closer.

 

Thanks!

See the Pen XWgZqpG by AustinNotAustin (@AustinNotAustin) on CodePen

Link to comment
Share on other sites

  • Solution

Maybe this would work for you.

 

gsap.set(".drag", {
  xPercent: -50,
  yPercent: -50
});

Happy tweening.

:)

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

Thanks,

 

Does this set the x and y draggable property value, or something else?

After playing with it, it's working great. Thanks again!

  • Like 2
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.
×