Jump to content
GreenSock

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

Draggable "snap" to target spot

Go to solution Solved by OSUblake,

Recommended Posts

Currently I'm trying to use draggable to be able to move blocks onto target spots, and if the spot isn't "exact" it would adjust them to be exactly on top of the element. I've attached a minimal example

 

The part I'm getting stuck on is here:

 

                // move onto target
                gsap.to(e.target0.1, {
                  left: p.left,
                  top: p.top,
                  x: 0,
                  y: 0,
                });

 

My blocks seem to disregard this, I don't fully understand how to make one element "tween" ontop of another one. the values my console log provide seem accurate but it does nothing in draggable/gsap, it only remains on the spot I left it.

 

 

Any advice?

 

Thanks,

 

See the Pen PoWLJJQ by lsencabaugh (@lsencabaugh) on CodePen

Edited by cpkn_dev
New codepen
Link to comment
Share on other sites

  • Solution

Here's an pen using an older version of gsap, but the logic is still relevant.

 

See the Pen rZOGZy by osublake (@osublake) on CodePen

 

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