aprsworld / wsWebDisplay

0 stars 0 forks source link

When dragging an element, it jumps 90px to the right initially. #87

Closed Cdetviler closed 8 years ago

Cdetviler commented 8 years ago

This is probably an unintended side-effect of the multi drag I just implemented.

Cdetviler commented 8 years ago

The jqueryui ui object was getting incorrect positioning. Oddly enough, as soon as I had it log the object in the console, it corrected itself. I'll leave this issue open in case my observations are coincidental and the issue is simply intermittent

Cdetviler commented 8 years ago

This bug happens when the original window position has moved (i.e. the user scrolls the page downward or to the left) since the drag has been initialized.

Cdetviler commented 8 years ago

I fixed it by having the javascript listen for a scroll event and set a global scroll offset variable. This is now figured into dragging. However, this ushered in a new issue with multidragging where other elements will not follow the same rules if the user has scrolled. Dragging one element at a time should work now, however.

Cdetviler commented 8 years ago

This is because I am using .offset() which only calculates offset from the top of the viewport; not the top of the document. I will have to implement a way to calculate the distance to the top of the document.

Cdetviler commented 8 years ago

If worst comes to worst, it could be calculated by finding the offset to the top of the parent element, and then finding that parent element's offset to the top of the document, then adding those two numbers together to find the sum. Though that is pretty ugly and a different method would be preferable.