Jump to content


Move Draggable to closest non-overlapping position on positive hit

Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I have set up 2 draggable objects and would like to ensure that they do not overlap. How can I move the dragged element to the nearest available position?


PS: Also notice the blue box does not want to go to left:0; when it starts at left:20%;

See the Pen zogpeb by anon (@anon) on CodePen

Link to comment
Share on other sites

Hi mikemhz :)


Welcome to the GreenSock forums.


It sounds like you may be looking for the hitTest() method. Here's a GreenSock demo:


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


More info in the docs:




Hopefully that helps a little bit.


Happy tweening.


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