React-sortable-hoc: Support for drop targets instead of default sorting behavior

Created on 3 Feb 2017  路  8Comments  路  Source: clauderic/react-sortable-hoc

Hi @clauderic! I am wondering if in your upcoming feature/collision-detection branch, there is going to be support for optionally overriding the sorting behavior?

In my use case, if a user drops an item in between others, it sorts the list but if the item is dropped on top of another, I can perform a different operation. So, to do this, I would need to know if an item is dropped on top of another (and not calculate new position in this case), or above or below the other (calculate new position in this case).

Let me know your thoughts!

Most helpful comment

I am too looking for something like this. @clauderic do you have any plans for supporting this feature? I can even try helping in PR for this change, I have very minimal POC working for this in my forked repo. Does collision_detection branch plan to handle this use case or is it something entirely different?

All 8 comments

Hey @oyeanuj, perhaps I'm misunderstanding your question, but isn't this something you can already do by looking at the oldIndex and newIndex values and conditionally performing a different action if the newIndex matches your target (instead of updating the state)?

@clauderic not exactly, let me clarify my question.

i am looking to differentiate between when an item has been dropped on top of another one and when one has been dropped in between two items? currently, newIndex represents relative placement/position but not that distinction.

@clauderic Just checking in to see if you have any thoughts based on the last comment? Thank you!

Hey @oyeanuj,

Sorry for the delay. Currently this isn't something that's possible, unfortunately. It might be in the future if I ever have time to keep working on the collision_detection branch

@clauderic thanks for the response! i'd be hapoy to attempt a PR If you could just provide a little guidance on the starting points - especially if I should choose between the master and the collision_detection branch, and if the latter, then what are the next steps to do on that branch?

Hey @clauderic, pinging for the above question (I know you are busy with things but just wanted to put it on your radar).

I'd love to see if I can help out with the collision_detection branch!

Thanks!

I am too looking for something like this. @clauderic do you have any plans for supporting this feature? I can even try helping in PR for this change, I have very minimal POC working for this in my forked repo. Does collision_detection branch plan to handle this use case or is it something entirely different?

@clauderic @oyeanuj Guys, I have worked on something similar for my use case. It allows users to detect overlaps and act based on overlap detection. Now it passes three arguments to onSortEnd handler, oldIndex, newIndex and merge. merge would be true if there is a an overlap (configurable via mergeThreshold and swapThreshold). I have added few demos as well to the story book. Here are my changes, https://github.com/champeng/react-sortable-hoc/tree/feature/overlap-detection. Please let me know if you guys want me send a PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ricokahler picture ricokahler  路  3Comments

zaygraveyard picture zaygraveyard  路  3Comments

Jessidhia picture Jessidhia  路  4Comments

dlee picture dlee  路  4Comments

zaygraveyard picture zaygraveyard  路  3Comments