zachgibson / react-native-parallax-swiper

Paged Parallax Swiper with Effects
MIT License
623 stars 76 forks source link

onMomentumScrollEnd (activePageIndex) Not Sending Correct Index on iOS #34

Closed mikeyamato closed 5 years ago

mikeyamato commented 5 years ago

Similar to issue #5 , my activePageIndex is not propagating with the proper index. It's always an index behind. If I swipe to index 1, activePageIndex would state index 0. My swipe action is horizontal.

iOS 12.1

"react": "16.6.3",
"react-native": "0.57.8",
"react-native-parallax-swiper": "^1.1.7",

state = {scrollToIndex: 0}

<ParallaxSwiper
    speed={0.5}
    animatedValue={this.myCustomAnimatedValue}
    dividerWidth={0}
    dividerColor="black"
    backgroundColor="black"
    onMomentumScrollEnd={activePageIndex => this.setState({scrollToIndex: activePageIndex},() => console.log('scrollToIndex',scrollToIndex))}
    showProgressBar={true}
    progressBarBackgroundColor="rgba(0,0,0,0.25)"
    progressBarValueBackgroundColor="white"
    scrollToIndex={scrollToIndex} 
>

Animated gif to this issue can be found here (takes you to Imgur). My example has a length of 3 items.

mikeyamato commented 5 years ago

Okay, so I'm an idiot. I had a 2nd pair of eyes look at my code and I was making things way too complicated. After removing part of the complexity everything was functioning properly. Basically I removed setState and passed activePageIndex directly.

zachgibson commented 5 years ago

Hey @mikeyamato glad you got this figured out. Sorry I was late to respond, I took off for the holidays.