react-native-snap-carousel icon indicating copy to clipboard operation
react-native-snap-carousel copied to clipboard

Calling carouselRef.current.snapToItem() invoke carousel onSnapToItem twice for Android

Open Romick2005 opened this issue 2 years ago • 0 comments

For my particular case I need to go back to the previous slide if not all fields is filled. So I used carousel onSnapToItem callback to listen to the swipe events. But if I need to go back I call carouselRef.current.snapToItem(invalidFieldSlideIndex), but this cause onSnapToItem to call twice first time with correct index and second with bad index.

So for example I have 3 slides. Swiping from the first slide and then back I will get on onSnapToItem called three times with the following values: 1 // active slide index (swipe) 0 // active slide index (programmatically call carouselRef.current.snapToItem(0)) 1 // active slide index (called from _onMomentumScrollEnd function passed to the ScrollViewComponent)

For iOS it is working perfectly well.

Romick2005 avatar Nov 17 '21 21:11 Romick2005