react-native-swiper icon indicating copy to clipboard operation
react-native-swiper copied to clipboard

A way to swipe by action

Open pazer001 opened this issue 10 years ago • 5 comments

i am looking to have the ability to scroll to another slide by an action i made myself.

like, i want to add some button that when i press it, it will swipe to 5th slide. how can i do it?

pazer001 avatar Oct 11 '16 17:10 pazer001

I'm not sure if it's the best option, but you can give the swiper component a reference and then use the scollBy method.

render() {
  return (
     <Swiper ref='mySwiper'  />
     <Button onClick={this._jumpSlide}>Jump</Button>
  )
}

_jumpSlide = () => {
  this.refs.mySwiper.scrollBy( n ); // where n is the number of slides to move
};

andrantis avatar Oct 18 '16 16:10 andrantis

It's the only solution that worked for me, thanks @andrantis .

recs182 avatar Jun 30 '17 13:06 recs182

Cool!, thank you!!! Ir worked perfectly from the first time! 👍

sejas avatar Nov 07 '17 09:11 sejas

"this.refs" is deprecated, what is the alternative?

aryankothiyal avatar Nov 14 '18 11:11 aryankothiyal

this approach helped me a lot. Thanks for sharing the solution

intransitorio avatar Aug 26 '20 19:08 intransitorio