meliorence / meliorence/react-native-snap-carousel
Carousel._repositionScroll doesn't fire if Carousel._getScrollOffset is not an integer.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Is this a bug report, a feature request, or a question?
Bug report. I'm also going to submit a PR for this.
It looks like there was an attempt to resolve this issue in https://github.com/archriss/react-native-snap-carousel/issues/318, but the commit mentioned here: https://github.com/archriss/react-native-snap-carousel/issues/318#issuecomment-387546445 cannot account for a case where the value of Carousel._getScrollOffset still ends up being fractional.
Have you followed the required steps before opening a bug report?
(Check the step you've followed - replace the space character between the square brackets ([]) by an x.)
- I have read the guidelines regarding bug report.
- I have reviewed the documentation in its entirety, including the dedicated documentations 📚.
- I have searched for existing issues and made sure that the problem hasn't already been reported.
- I am using the latest plugin version.
- I am following the issue template closely in order to produce a useful bug report.
Have you made sure that it wasn't a React Native bug?
It isn't, it's simply a logic bug.
Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?
I've only observed the bug in Android on an Asus ZenPad 8.0 with Android 7.0, but it's possible that it could happen on iOS.
Is the bug reproductible in a production environment (not a debug one)?
Yes.
Environment
"react": "^16.6.1"
"react-native": "^0.57.7"
"react-native-snap-carousel": "^3.7.5"
Platform:
Android (7.0)
Expected Behavior
After the first loop of the carousel with loop and autoplay set to true, upon reaching the first cloned slide at the end of the list, it would then call _repositionScroll to set the Carousel to the first non-cloned slide in the list. E.g: If there is data for 8 slides, and loopClonesPerSlide was set to 2, upon reaching the 9th slide (which is one of the cloned slides) it would soon reset the carousel to the slide with index of 2 (the first non-cloned slide).
Actual Behavior
Screencast: https://youtu.be/bN3wNWiyK_E
Reproducible Demo
See screencast.
Steps to Reproduce
I'm only documenting this issue for the PR I'm going to submit to fix it, so I'm going to pass on this.
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 by tracing Carousel._repositionScroll and Carousel._getScrollOffset in the carousel implementation, then compare the loop and autoplay path described in the issue. Reproduce the Android case with loop and autoplay enabled and fractional scroll offsets; done means the carousel resets from the cloned end slides to the first non-cloned slide.
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
- 25/100