leecade / react-native-swiper

The best Swiper component for React Native.
MIT License
10.4k stars 2.34k forks source link

loadMinimal doesn't work on Android #358

Open opolyo01 opened 7 years ago

opolyo01 commented 7 years ago

I had to put loadMinimal={Platform.OS === "ios"} for Swiper property as it doesn't work on Android. On Android it only swipes to loadMinimalSize={1} of cards. So if I swipe past loadMinimalSize it shows empty card, but works fine on iOS.

I am using "react": "15.3.2", "react-native-swiper": "^1.4.11", "react-native": "^0.38.0",

vedran commented 6 years ago

The issue is that In the Android case of renderScrollView ( https://github.com/leecade/react-native-swiper/blob/master/src/index.js#L623-L647 ), the code isn't passing along the following callbacks, which are necessary for the library to update its state and render the active page:

    onScrollBeginDrag={this.onScrollBegin}
    onMomentumScrollEnd={this.onScrollEnd}
    onScrollEndDrag={this.onScrollEndDrag}

I assume this is because this library currently uses ViewPagerAndroid, which doesn't have these callbacks as far as I can tell: https://facebook.github.io/react-native/docs/viewpagerandroid.html#props

For Android support, I recommend switching to the fork from this pull request: https://github.com/leecade/react-native-swiper/pull/643 and then adding the appropriate callbacks above.

For an example, you can check out my fork which is based on the PR above: https://github.com/vedran/react-native-swiper/commits/android-vertical-swiper

But I don't recommend others to use it in production because I have added some hacks for my own purposes.

dannysood commented 6 years ago

Any update on this?