briangonzalez / jquery.pep.js

👟 Pep, a lightweight plugin for kinetic drag on mobile/desktop
http://pep.briangonzalez.org
1.3k stars 177 forks source link

Draggable elements are offset at random values #191

Open pixelplant opened 8 years ago

pixelplant commented 8 years ago

Hello Brian

First of all I want to thank you for this awesome plugin. I am experiencing a strange issue and I hope you have an idea of what I can do as I tried all the possible parameters and I still can't seem to be able to have the desired effect. I prepared a codepen page so that you can see what I am talking about (Try dragging around the elements that have Bold titles; you will see the drag cursor show up once you hover them)

https://codepen.io/nekosan/pen/qaXkRL

I am developing an application that allows you to drag elements around, and move them from container to container. Once you start dragging, some small divs are created before and after existing content elements (shown with a dashed border) and once you drop the dragged element onto one of this dashed divs, your element will become a child of this div's parent. Everything works fine and elements are moved as they should, the problem that I have is that most of the times the dragged div is offset from the mouse cursor (sometimes below the mouse, sometimes to the right, or the left, sometimes above the mouse, at either 20px or 200px or more, so it's like random) What I'm trying to do is to have the dragged div to always follow the mouse, and be under it once it is being dragged.

I really tried everything I could think of, reset the positions manually, reset the styles added by pep, trying both with cssTransforms enabled or not, reverting the values or not, no change, I always get the same random offset.

Can you please have a look and let me know if you have any idea how I could handle this situation? I am aware that my dropping zones are created dynamically (once you "initiate" drag) and this might screw the position of the div but in this case I would expect to get a fixed offset, not a random one.

Thank you, Radu