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?
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
};
It's the only solution that worked for me, thanks @andrantis .
Cool!, thank you!!!
Ir worked perfectly from the first time! 馃憤
"this.refs" is deprecated, what is the alternative?
this approach helped me a lot. Thanks for sharing the solution
Most helpful comment
I'm not sure if it's the best option, but you can give the swiper component a reference and then use the
scollBymethod.