react-native-sortable-listview icon indicating copy to clipboard operation
react-native-sortable-listview copied to clipboard

Constrain dragging bounds

Open vTrip opened this issue 7 years ago • 3 comments

Is there a way we can specify the bounds of dragging?

i.e only allow dragging between position 1 and list.length-2

vTrip avatar Mar 07 '17 02:03 vTrip

@vTrip could you say more about your use case?

chetstone avatar Mar 08 '17 23:03 chetstone

@chetstone

Given a SortableListView with data [ {title: "Object 1"}, {title: "Object 2"}, {title: "Object 3"}, {title: "Object 4"}, ]

It would be great to constrain the bounds with which we drag an element. For example:

boundsOfDrag={1, 3} (inclusive)

whereby the SortableListView would not animate and/or move the first element in the list while dragging, Effectively not allow the user to drag an element above or below the bounds specified.

P.S - sorry for the initial vague comment

vTrip avatar Mar 08 '17 23:03 vTrip

Ah thanks. That makes sense.

I was thinking about a more limited constraint. The performance of this component still leaves a little to be desired when dragging an item to the bottom of the list. Things bounce around quite a bit. I thought to add a prop preventDragToLastPosition. Then the user would not be able to drag something to the very end of the list all in one go --- she would have to drag it to the penultimate position, then drag the last item up over it. But overall it might be a better UX than the current bouncing around, until we figure out how to fix that.

I've experimented with it a bit and it should be fairly easy to do by disabling the code that allows scrolling past the end of the list.

Your idea would be harder to implement, but happy to accept a PR.

chetstone avatar Mar 09 '17 00:03 chetstone