kkemple/react-native-sideswipe

Feature -> Auto play

Marcello168 opened this issue · 2 comments

It would be perfect if it supported auto-play

Hope I am not too late. You can easily implement autoplay by assigning the index of the component to state of your view and then incrementing or decrementing the said state

Example:

<SideSwipe index={this.state.currentIndex} data={data} ..other params />

then write this function to increment index:
startFeaturedSlider = () => { this.autoFeaturedSlider = setInterval(() => { if(this.state.slideFeatured){ if(this.state.currentFeaturedIndex==data.length) this.setState({currentFeaturedIndex: 0}); else this.setState({currentFeaturedIndex: this.state.currentFeaturedIndex + 1}); } }, 4000); }

and simply call it anywhere like inside componentDidMount

@Sosmot Thanks ,it`s not later