meliorence / meliorence/react-native-snap-carousel
Carousel with autoplay and pagination issue
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Hello Thanks for this package, its very useful for my project.
When I am using onSnapToItem={index => setActiveSlide(index)} it updates the state and update active dot but on next slide it resets the Carousel items and starts the play from first item again.
If I remove onSnapToItem autoplay works fine.
I think something wrong with updating state with my code?
Could someone pls help looking into this ? Thanks
Here is my code:
<View style={[styles.homePriorityNotifMainView]}>
<Carousel
// ref={c => this._slider1Ref = c}
loop
enableSnap
autoplay={true}
layout={'default'}
autoplayInterval={3000}
data={notifications}
sliderWidth={deviceWidth}
itemWidth={deviceWidth}
renderItem={_renderItemCarousel}
activeAnimationType={'spring'}
removeClippedSubviews={false}
onSnapToItem={index => setActiveSlide(index)}
/>
<Pagination
dotsLength={notifications.length}
activeDotIndex={activeSlide}
containerStyle={{
// width: 200
}}
dotStyle={{
width: 10,
height: 10,
borderRadius: 5,
// marginHorizontal: 8,
backgroundColor: 'red'
}}
inactiveDotStyle={{
backgroundColor: 'yellow'
}}
inactiveDotOpacity={0.4}
inactiveDotScale={0.6}
/>
</View>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Carousel behavior for autoplay, loop, and onSnapToItem, using the provided example with Pagination as the reproduction case. Check how updating activeSlide affects the carousel's current item and autoplay state. Done means autoplay advances beyond the first item while the pagination remains synchronized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100