alexbrillant / react-native-deck-swiper

tinder like react-native deck swiper
ISC License
1.55k stars 462 forks source link

Triggering swipeLeft on button which is outside of Swiper; Triggering function while swiping left or right #279

Open web-mickey opened 4 years ago

web-mickey commented 4 years ago

Hi,

gauravsbagul commented 4 years ago

Hi,

  • I have application where I have some buttons outside of Swiper component and would like to swipe left or right when I press the button. How can I do it?
  • I would like to show something while I am swiping to left or right. I know there is a function "onSwiping" but how can I know that I am swiping left or right to show different text?

Have you find any solution for this please share.

in-techouse commented 4 years ago

@gauravsbagul @Mikowhy-owl

<Swiper ref={swiper=>{ this.swiper = swiper }}/>

In your <Swiper /> add a reference, and you can use this reference to swipe the card left or right on a button click which is outside the swiper. To swipe left this.swiper.swipeLeft(); To swipe right this.swiper.swipeRight();

gauravsbagul commented 4 years ago

Hi found the solution <Swiper ref={'swiper'} key={this.state.questions.length} {swiperItems} </Swiper>

and this.refs.swiper.scrollBy(1);