android,ios
Which versions are you using:
Want to control swiper's autoplay at any time
Only changed once, again changed swiper no response
this.state={
swiperAutoplay:true
}
loop={true}
autoplay={this.state.swiperAutoplay}
>
Opacity:
this.setState({
swiperAutoplay: !this.state.swiperAutoplay
});
then swiperAutoplay = false,
and swiper does not scroll automatically,
but Opacity angin:
then swiperAutoplay = true,
swiper still does not scroll automatically,
You can use <Swiper ref={node => this.swiper = node} />. And after that this.swiper.autoplay()
@ifours
autoplayTimeout={4}
autoplay={false}
>
this.swiper.autoplay()
this isn't work
You should set autoplay={true} before this.swiper.autoplay(). Like that this.setState({ swiperAutoplay: true }, () => { this.swiper.autoplay() ;})
@ifours Thank you very much!
First of all, many Thanks!!
Second, what are the difference betweens the codes:
Code 1: - WORKS:
this.setState({autoPlay:true},() => { this.swiper.autoplay() ;})
Code 2: - Not Works:
this.setState({autoPlay:true})
this.swiper.autoplay();
???
@roysG in first case you will call autoplay after swiper receives autoplay={true}
Thanks.
Most helpful comment
You should set
autoplay={true}beforethis.swiper.autoplay(). Like thatthis.setState({ swiperAutoplay: true }, () => { this.swiper.autoplay() ;})