This project is read-only.

CSS margins causing vertical movement onclick

Dec 19, 2009 at 1:55 AM

I am encountering an issue I'm not sure how to work around.

The problem occurs when I add a margin between the list items. Specifically, I am adding a margin-top of 10px to the "li + li" element. When an item is clicked (not dragged) it moves downward by the exact amount of the item's margin. I'm not sure what to do to solve this. I don't believe the script is taking the margins into account when calculating the height of the list items. But I'm really not sure exactly what the fix is.

Any help whatsoever would be awesome. I love the script and look forward to getting any possible feedback!

Dec 19, 2009 at 3:52 AM

Thanks for reporting this, it should be fixed in this version:
http://dragsort.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=37479

The problem is that the dragged item is being positioned with CSS top and left with the x,y coordinates of the mouse and of course margin moves the item in relation to that specified position. So now marginTop is taken off the y coordinate and marginLeft off the x coordinate.

Dec 19, 2009 at 4:49 AM

Thanks a lot! That should do the trick.