software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
6.12k stars 981 forks source link

Required auto closing for open Swipeable element when press anywhere on screen #411

Closed St1maSphere closed 4 years ago

St1maSphere commented 5 years ago

Hi to everyone

Need to have ability to select only one Swipable component or close already swiped element on move through navigation, press outside element range, etc

Thanks in advance

deepankarsandy commented 5 years ago

Use ref to get swipeable instance and then call close on that to close. For navigation use navigation lifecycle methods like onWillBlur.

https://kmagiera.github.io/react-native-gesture-handler/docs/component-swipeable.html#close

St1maSphere commented 5 years ago

@deepankarsandy Thank you for your answer But it will not work for me, cause of dinamic list of options and absence of reason to manage status of component using my state

Is it possible to, somehow, move this handling to 'list' level and make it stateful?

Freddy03h commented 5 years ago

I think it can be something like this : https://github.com/facebook/react-native/blob/master/Libraries/Experimental/SwipeableRow/SwipeableFlatList.js

selcukoguz commented 5 years ago

Did anyone solve this issue. Coz I'm stuck with this! @St1maSphere ?

St1maSphere commented 5 years ago

@selcukoguz Sorry for delay For now, I am using an alternative solution: https://github.com/dancormier/react-native-swipeout with param: close={selectedId !== currentRow.id}

selcukoguz commented 5 years ago

@St1maSphere thx for answer.

deepankarsandy commented 5 years ago

A good alternative is NativeBase

swathi2378 commented 4 years ago

@St1maSphere Did you find a way?

kopax commented 4 years ago

All link given here are broken, I am currently testing https://github.com/jemise111/react-native-swipe-list-view but it is flaggy, is this doing better animation? (I ask because react-native-swipeout is the ancestor if react-native-swipe-list-view and I was going to try react-native-gesture-handler Swipeable component) Thanks and best!

jakub-gonet commented 4 years ago

This should be resolved by second comment.