deanmcpherson / react-native-sortable-listview

Drag drop capable wrapper of ListView for React Native
MIT License
918 stars 235 forks source link

SortableListView inside ScrollView #23

Closed superandrew213 closed 8 years ago

superandrew213 commented 8 years ago

Is the there a way to get this to work? Currently it does not allow sorting. You can select the cell but it doesn't move. Just scrolls the parent ScrollView instead.

superandrew213 commented 8 years ago

onRowMoved is not being triggered

superandrew213 commented 8 years ago

Related to this #1046

deanmcpherson commented 8 years ago

Hey @superandrew213, do you have an example of how to reproduce this?

superandrew213 commented 8 years ago

@deanmcpherson I changed my approach and am not using the parent ScrollView anymore but it was basically like this:

<ScrollView>
  <SortableListView />
</ScrollView>
deanmcpherson commented 8 years ago

Hey @superandrew213, I don't think this is possible. I think you would need to disable the scroll of the scroll view for the sortable to be able to capture the move responder. You could try adding onMoveShouldSetPanResponder={true} to the PanResponder, but my suspicion is that on moving the parent scrollview will capture the event regardless.

superandrew213 commented 8 years ago

@deanmcpherson I found a workaround by disabling the parent ScrollView onPanResponderGrant then enable onPanResponderRelease

deanmcpherson commented 8 years ago

Just out of curiosity, why are you nesting it inside a ScrollView?

superandrew213 commented 8 years ago

My sortable list will only have 4 items and I have other content underneath it.

deanmcpherson commented 8 years ago

Ah ok, and you need it all to scroll. The content below is pretty big? Otherwise you could just render it in renderFooter.

superandrew213 commented 8 years ago

Yeah it's quite big and includes other non sortable lists. I might try and see how it performs if I include it in renderFooter. It might rerender every time SortableListView updates

deanmcpherson commented 8 years ago

Yep, by default it will try and rerender every time the SortableListView updates, you can wrap it in a StaticRenderer or return false to shouldComponentUpdate to fix that though.

deanmcpherson commented 8 years ago

Closing issue.

vTrip commented 6 years ago

Found rendering elements in the header an footer very useful when wanting all content to scroll with the list and not trigger the drag. Thanks @deanmcpherson