Bounds for item drag zone are not always correct
Closed this issue · 4 comments
Hi, I found another slightly odd bug with the library. I've noticed that in certain circumstances it is possible to drag the tiles outside of the bounds of the container. I've used a very simple sample app to demonstrate - https://github.com/avertin/reorder-sample
If you rotate to landscape, scroll a little, then try to drag an item. You will notice that it is possible to drag the item far above the top of the container so it almost disappears from the view.
I found the section of code that I think is causing the problem - https://github.com/mochixuan/react-native-drag-sort/blob/master/lib/AutoDragSortableView.js#L266
if (!this.isStartupAuto()) {
if (this.touchCurItem.originTop + dy < 0) {
dy = -this.touchCurItem.originTop
} else if (this.touchCurItem.originTop + dy > maxHeight) {
dy = maxHeight - this.touchCurItem.originTop
}
}
I think the bug is that the vertical bound checks don't apply if this.isStartupAuto()
is true. Hence why the bug only reproduces after the component has been scrolled.
I still haven't figured out a fix, but I'd be curious to hear if you have any ideas.
After reading my Demo, it can't be drawn out. You can see if there is a problem with your width setting. Or you can run Example to see the effect
Yes, this one can be dragged up to start the automatic sliding function, but it will automatically reset to the normal position when you let go