meliorence / meliorence/react-native-snap-carousel

Carousel._repositionScroll doesn't fire if Carousel._getScrollOffset is not an integer.

Open
#470 1 comment 0 reactions 0 assignees View on GitHub

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.)

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.