SHISME / react-native-draggable-grid

A draggable and sortable grid of react-native
308 stars 96 forks source link

Swap Positions on Drop #61

Open jonnyreeves opened 3 years ago

jonnyreeves commented 3 years ago

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.

SHISME commented 3 years ago

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}
      ],
    };
jonnyreeves commented 3 years ago

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.

SHISME commented 3 years ago

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