meliorence / meliorence/react-native-snap-carousel

Got error with firstItem in the first time swipe

Open
#960 0 comments 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

I have 4 items [0, 1, 2, 3]
And I set the firstItem is 3.
In the first time, correctly with the default active is 3.
But when I tried to snap to the 0, NO trigger from onSnapToItem.
If I snap to 1 OR 2 from 3. I see HAVE trigger from onSnapToItem.

Example:
<Carousel
data={[0, 1, 2, 3]}
renderItem={renderItem}
firstItem={3}
onSnapToItem={(slideIndex) => {
console.log(slideIndex)
}}
useScrollView
enableMomentum
/>

I found this from Carousel.js line 1047
image

It need be changed to this._scrollEndOffset = this._scrollOffsetRef; instead of this._scrollEndOffset = this._currentContentOffset;

Anyone have same issue with me, and do you think my understanding is correct?

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 at Carousel.js line 1047 and reproduce the reported carousel sequence with data [0, 1, 2, 3], firstItem={3}, useScrollView, and enableMomentum. Verify that snapping from 3 to 0 triggers onSnapToItem while the existing 3-to-1 and 3-to-2 behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
frontend, mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.