react-native-draggable-grid icon indicating copy to clipboard operation
react-native-draggable-grid copied to clipboard

Swap Positions on Drop

Open jonnyreeves opened this issue 4 years ago • 3 comments

Hi There,

Thank you for providing this library and sorry for asking a question which may be a feature request.

I need the ability to swap two items positions without affecting the positions of other items in the grid. Does the library currently support this, or would this be new functionality?

Thank you.

jonnyreeves avatar Sep 04 '21 17:09 jonnyreeves

You can set disabledReSorted of the item

may like this

this.state = {
      data:[
        {name:'1',key:'one'},
        {name:'2',key:'two'},
        {name:'3',key:'three',disabledReSorted:true},
        {name:'4',key:'four',disabledReSorted:true}
      ],
    };

SHISME avatar Sep 05 '21 14:09 SHISME

Hi @SHISME, thanks for coming back to me so quickly.

Using the disabledReSorted property does not meet my use-case, I need the ability to allow any grid item to be dragged to any position on the grid, however the other grid items should not move/re-order themselves, instead only the "drop target" should switch places with the item being dragged. I've hacked up a video to demonstrate this behavior.

https://user-images.githubusercontent.com/200185/132636451-c98ca7d6-d559-435a-862f-65a18531d700.mp4

Do you have any suggestions as to how I could implement this behavior? Thank you.

jonnyreeves avatar Sep 09 '21 06:09 jonnyreeves

Hi @SHISME, thanks for coming back to me so quickly.

Using the disabledReSorted property does not meet my use-case, I need the ability to allow any grid item to be dragged to any position on the grid, however the other grid items should not move/re-order themselves, instead only the "drop target" should switch places with the item being dragged. I've hacked up a video to demonstrate this behavior.

swap-places.mp4 Do you have any suggestions as to how I could implement this behavior? Thank you.

https://github.com/ollija/react-native-sortable-grid i think this repository may help you

SHISME avatar Sep 09 '21 16:09 SHISME