kutlugsahin / smooth-dnd

drag and drop library for javascript
MIT License
598 stars 146 forks source link

Target area is off based on dragstart position #65

Closed ghost closed 4 years ago

ghost commented 4 years ago

I noticed a weird issue which I'm gonna try to describe in the following.

When user starts dragging in the middle of a card, everything seems fine:

Normal behavior

works

The issue

However, if I start dragging at the very left or right edge of a card suddenly the drop area is very off, see:

works-not

You can see that after entering the right half of the target area smooth-dnd suddenly doesn't recognise it any more. Also, if I keep moving further to the right the cards in the next lange already start moving even if I haven't entered the lane yet.

Any way to fix this?

ghost commented 4 years ago

I was able to fix this bug by changing the following line 214 in container.ts:

let hitElement = document.elementFromPoint(draggableInfo.position.x, draggableInfo.position.y);

to this:

let hitElement = document.elementFromPoint(draggableInfo.mousePosition.x, draggableInfo.mousePosition.y);