Hello,
I am a beginner in react-native and I found your swiper very powerful and easy-to-use! Thank you 馃槂
Now I'd like to do a method that will autoscroll to another index when I touch a button (not with autoplay).
I think it's possible with the scrollBy(index,animated) method but I can't find an example that uses it.
I guess I should pass the swiper as a parameter (props) to the view component but I really don't understand how could I...
Here is the important part of my code
export default class swiper extends Component {
render() {
return (
<Swiper
showsPagination={false}
showsButtons={false}
loop= {false}
index={0}>
<Swiper
horizontal={false}
showsPagination={false}
showsButtons={false}
loop= {false}
index={0}>
<Tastr typeConnection={ConnectMusic} />
<Tastr typeConnection={ConnectMusic} />
</Swiper>
<Tastr typeConnection={ConnectShows} />
</Swiper>
)
}
}
I need to go from ConnectMusic to ConnectedMusic when i touch a button.
Best regards,
Hadrien
You have to create a reference to the swiper to access its method.
add to the swiper of which you want to use scrollBy
ref={(swiper) => {this._swiper = swiper;}}
then add this to the button you have to click to scroll the swiper
onPress={() => this._swiper.scrollBy(1)}
thx! working example also here : https://github.com/leecade/react-native-swiper/issues/282
You have to create a reference to the swiper to access its method.
add to the swiper of which you want to use scrollBy
ref={(swiper) => {this._swiper = swiper;}}
then add this to the button you have to click to scroll the swiper
onPress={() => this._swiper.scrollBy(1)}
GREAT Thanks.
Most helpful comment
You have to create a reference to the swiper to access its method.
add to the swiper of which you want to use scrollBy
ref={(swiper) => {this._swiper = swiper;}}then add this to the button you have to click to scroll the swiper
onPress={() => this._swiper.scrollBy(1)}