Jump to content
GreenSock

llan

Cloning + Snapping to Target

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

Hello!

 

See my pen here: 

 

I'm building a configurator, where certain elements can be drag-and-dropped into different slots. I have implemented the cloning mechanism mentioned here: https://greensock.com/forums/topic/10466-draggable-cloning-option/

This part of working fine.

 

In addition, I want the new elements to snap to their respective slots. For this, I have used the code from:

See the Pen IaAfl by antpearson (@antpearson) on CodePen

 

Snapping works for the first element I drop onto a slot. For each additional element, though, snapping doesn't work. I suppose it has something to do with the JS code in line 45.

 

I've been trying to figure this out, yet without success.

I would really appreciate your help. Thanks!

 

Laurent

See the Pen NdwYJb by llan (@llan) on CodePen

Link to comment
Share on other sites

I've posted numerous examples on how to do this if you search around the forum, but some of them are complicated. Here's an example that is close to what you are doing.

See the Pen qRpNWX?editors=0010 by osublake (@osublake) on CodePen

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