alexbrillant / react-native-deck-swiper

tinder like react-native deck swiper
ISC License
1.54k stars 460 forks source link

Disable bottom swipe just for first card #376

Open isaacshalom1 opened 2 years ago

isaacshalom1 commented 2 years ago

I want my user to be able to go backward on the cards, but is there a way to disable bottom swipe just for the first card? if the user swipes down on the first card as of now nothing would appear on the screen

FatjonRrapaj commented 2 years ago

Yes, save the swipe index on the state, so the initial is 0. And the swiper has a prop called disableBottomSwipe along with other props for disabling each direction. So you can write:

//the state: const [cardIndex,setCardIndex] = useState(0) //the Swiper <Swiper onSwiped = {()=>setCardIndex(cardIndex+1)} disableBottomSwipe={cardIndex === 0} //rest of the props />