Jump to content
Search Community

Draggable swap items

Kerox test
Moderator Tag

Recommended Posts

Hi! I'm trying to adapt this codepen to my needs.   

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

I have only one row with 5 elements, so 5 columns. My items are 90px x 90px so I've changed rowSize to 90, colSize to 5 so it fits my container, totalRows to 1, and totalCols to 5, but it acts weird. If I hold click on an item and then I slightly move the cursor, it passes through all the items really fast.

Also If you can provide me another pen I'd be grateful!

See the Pen mdEbWEd by keroxen (@keroxen) on CodePen

Edited by Kerox
added my own codepen
Link to comment
Share on other sites

Just now, ZachSaucier said:

Hey @Kerox and welcome to the GreenSock forums.

 

Please provide your CodePen so that we can see where you're going wrong, not the pen that you're basing things off of :) That way we'll be able to help you with your actual issue.

I've just edited the post and added my codepen.

Link to comment
Share on other sites

The issue is that your elements that you're sorting are not positioned like the ones in Blake's demo. All of his have position: absolute, yours do not.

 

Furthermore, your variables declaring how big each item in are incorrect. They should match the values set in your CSS (you could get them from your CSS using GSAP's .getProperty() method if you'd like). 

See the Pen LYZPWyv?editors=0010 by GreenSock (@GreenSock) on CodePen

 

Side note: We highly recommend upgrading to the GSAP 3 syntax. It's sleeker and allows you to use new features like defaults :) 

  • Thanks 1
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.
×
×
  • Create New...