[Feature] Add drag reorder index information to OnAccept #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is kind of related to #2, though I didn't fully understand what they were trying to do.
I've added an AcceptDetails class that contains the old index, and the new index, of the reordered data on OnWillAccept and OnAccept. This lets users allow their own list to track changes, for example:
The core of this is the
AcceptDetailsclass:A field of this type is added to the
_DragContainerState, which keeps track of where this item is being pulled and pushed to:This field is reset at the same time as
endWillAccept(), and is set duringsetWillAccept()in the non-null moveData case.Additionally, an
originalIndexfield is added, which helps keep track of final moves, otherwise I found I was unintentionally tracking all potential accepts as well, which wasn't what I wanted. OriginalIndex is updated in thesetDragStartmethod.I'd be happy to talk about better implementations, this is just what I'm working with in my own fork, I tried to keep the changes minimal, especially with modifying the public API, but if you were willing to change it a bit, then I think we could probably get better function signatures if you wanted.