meliorence / react-native-snap-carousel

Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.
BSD 3-Clause "New" or "Revised" License
10.37k stars 2.29k forks source link

Got error with firstItem in the first time swipe #960

Open hienpvptit opened 2 years ago

hienpvptit commented 2 years ago

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?