supraniti/Lean-Mean-Drag-and-Drop

Reordering elements is too precise

Opened this issue · 4 comments

When trying to reorder elements, it feels a little difficult / the space I need to drag the element to is too small. I could be wrong but it seems like it won't reorder until the middle of the element being dragged passes the end of the sibling, whereas alternative libraries seem to reorder when the middle of the element being dragged passes the middle of the sibling.

I guess this would be particularly annoying with longer elements.

The logic implemented in the positioning algorithm is as follows:
If cursor location is above or left the element top-left point, the dragged element will be placed before it.
I am wondering what do you think should happen on the following example -
when you drag the blue item over points 1-12,
when you drag the black item over points 1-12
lmdd

If cursor location is above or left the element top-left point, the dragged element will be placed before it.

If I understand this correctly, I think it should be:

- If cursor location is above or left the element top-left point, the dragged element will be placed before it.
+ If cursor location is above or left the element center point, the dragged element will be placed before it.

I am wondering what do you think should happen on the following example -
when you drag the blue item over points 1-12,

Hmmmm, when I created this issue, I was thinking of vertical reordering. I find it a bit hard to think about dragging in this grid-like layout but hmmm... I think:

  • If the cursor is over the rectangle marked by 2, 3, 11, 12, then it would be placed after Teal.
  • If the cursor is over the rectangle marked by 1, 2, 10, 11, then it would be placed before Teal.

when you drag the black item over points 1-12

Same as above;

  • If the cursor is over the rectangle marked by 2, 3, 11, 12, then it would be placed after Teal.
  • If the cursor is over the rectangle marked by 1, 2, 10, 11, then it would be placed before Teal.

@supraniti

If cursor location is above or left the element top-left point, the dragged element will be placed
before it.

This makes sense when we drag an element downward. But shouldn't we consider bottom left while dragging upward.

When movement is

  1. Top to bottom - top left
  2. Bottom to top - bottom left
  3. Left to right - top left
  4. Right to left - bottom right

that's an interesting direction... and can be implemented with a little effort...
i will dig into it