clauderic / react-sortable-hoc

A set of higher-order components to turn any list into an animated, accessible and touch-friendly sortable list✌️
https://clauderic.github.io/react-sortable-hoc/
MIT License
10.8k stars 980 forks source link

Connected lists #3

Open slmgc opened 8 years ago

slmgc commented 8 years ago

Is there a way to drag items from one list to another?

clauderic commented 8 years ago

Not currently. I may look into implementing a DropTarget higher order component, but that's a bit out of scope at the moment. If that's the kind of functionality you're looking for, you should perhaps try react-dnd

slmgc commented 8 years ago

@clauderic I was thinking about functionality similar to https://github.com/RubaXa/Sortable It allows to have connected lists. React-dnd is not the best option.

oyeanuj commented 8 years ago

@slmgc One way I wonder if this would work is if you fake the two separate lists as one list with a divider but I imagine that would work only for very limited cases.. Sortable library does look cool!

nperichSYKES commented 8 years ago

This library seems great! We use react dnd largely for firing actions when dragging between and over lists. For example, imagine dragging a school activity up and down to sort within the activity's list, or further down to drop into a different activity group, or across the screen to drop onto a group of students to assign them that activity. But a few of our lists would really benefit from react-virtualized and, from a quick glance, integrating dnd with virtualized seems like it might get ugly. I know this case is sort of what react-dnd is designed for, but I wonder how much of it can be handled with a lighter weight drop target HOC for react-sortable-hoc.

oyeanuj commented 7 years ago

@slmgc @nperichSYKES I'm curious where did you guys end up here? Did you end up with a solution for connected lists using this library or another?

slmgc commented 7 years ago

@oyeanuj I used https://github.com/RubaXa/Sortable. My implementation with connected lists is about 100 LoC.

oyeanuj commented 7 years ago

@slmgc Thanks! Possible to share a gist of that implementation to get a sense of how it works?

slmgc commented 7 years ago

@oyeanuj I'm currently working on another project, but I'll try to find my implementation

jasonhargrove commented 7 years ago

So close, but without this feature, so far. Great job all around though, thanks!

oyeanuj commented 7 years ago

@slmgc Any luck/update on finding that implementation? Appreciate you looking!

slmgc commented 7 years ago

@oyeanuj sorry, had no spare time at work. I'll try to do it this weekend.

ghost commented 7 years ago

This would be a great feature. Currently our app requires this and is using this module at present. Any update on this? Great work so far!

jdbence commented 7 years ago

I have a basic working version that uses two vertical lists. It has one additional class to handle the swap logic and zero code changes to the current react-sortable-hoc classes.

dragdemo

oyeanuj commented 7 years ago

@jdbence That looks smooth, I am very curious about your approach. I have a somewhat working version as well which requires using two different collections and then returns the new collection as well as index at the drop place.

Do you have a branch/fork where I can look at your implementation? And/or a PR coming up for this?

jdbence commented 7 years ago

@oyeanuj It will come as a PR in the next week or so. This implementation uses a callback returning old and new list information (index & list) of the dragged item. Events are handled on move and on drop.

jdbence commented 7 years ago

You can checkout the PR #138 I haven't tested on touch devices.

romellogoodman commented 7 years ago

For those waiting on this, you should also check out react-beautiful-dnd. They seem pretty close to implementing this feature

romellogoodman commented 7 years ago

This just landed in react-beautiful-dnd

sbrichardson commented 6 years ago

I put together some code from a few users that I started working on, and adding some other features:

https://github.com/reactual/react-multi-sortable-hoc-demo

preview

c0d3-ninja commented 6 years ago

@clauderic is this feature in progress?

marcomelilli commented 4 years ago

Any news?