react-native-swiper
react-native-swiper copied to clipboard
Start and stop autoplay programatically
Hello everyone,
is it yet possible to start and stop autoplay programatically?
If not this might be a nice feature.
Thanks
Hi,
You can bind swiper autoplay property your screen state on below.
<Swiper autoplay={this.state.swiperAutoPlay}
If you want to stop swiper at any time, just set the swiperAutoPlay value to false.
Good luck.
@ermankuruoglu this method can stop autoplay,but can not start autoplay after stop
Yes, it only works one way, because it kills the timer if the new props are "!autoplay". But it sets the timer only onScrollEnd, which never occurs automatically after it's stopped.
Meanwhile you can use <Swiper ref={node => this.swiper = node} />. And after that this.swiper.autoplay()
Meanwhile you can use
<Swiper ref={node => this.swiper = node} />. And after thatthis.swiper.autoplay()
Does this solution works? It's not working in my case
just changed my autoplay state to null and vice versa