webraptor / react-native-deck-swiper

tinder like react-native deck swiper
ISC License
126 stars 81 forks source link

Prop to tell Swiper to stay on same card after swipe action #20

Closed psychosoft closed 3 years ago

psychosoft commented 3 years ago

It would be great to have a prop for the Swiper to tell it that it shall stay on the same card (no skip forward in the deck) after a certain Swipe action. For example 4 props named, stayOnSameCardAfterSwipeTop, stayOnSameCardAfterSwipeLeft, stayOnSameCardAfterSwipeRight, stayOnSameCardAfterSwipeBottom.

Love your work! Many thanks!!! :)

webraptor commented 3 years ago

It’s actually quite easy to do so. If you keep cardindex in sync with the swiper in a prent component or in your app state, by not updating the cardindex prop on swipe and by making sure you pass back to the swiper the old cardindex it will still display the same card.

But in any way, why would you want to achieve that? Do you want to revert to the same card, as if user’s not allowed to swipe and on release you want to revert to the same card instead of swiping?

psychosoft commented 3 years ago

Nice, I will try that. I am building an app for my local hockey team where audience will use it to vote for the best player during the game. Navigation is Swipe left/right to chose player, Swipe up to place a vote for current player. Each user will have for example 10 votes to distribute. The users are allowed to use all 10 votes on same player, which i think will be the most common use case, and for useability I would like the card to stay on the same Player card

Thaks for the great lib anyway!

/Robert

Den sön 6 sep. 2020 kl 15:13 skrev Bogdan Pop notifications@github.com:

It’s actually quite easy to do so. If you keep cardindex in sync with the swiper in a prent component or in your app state, by not updating the cardindex prop on swipe and by making sure you pass back to the swiper the old cardindex it will still display the same card.

But in any way, why would you want to achieve that? Do you want to revert to the same card, as if user’s not allowed to swipe and on release you want to revert to the same card instead of swiping?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/webraptor/react-native-deck-swiper/issues/20#issuecomment-687786317, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADDUYXMTSWU7UP6H5FLFGJTSEODHBANCNFSM4Q3OWICQ .