React-native-swiper: Percentage of view in sight

Created on 28 Feb 2017  ·  2Comments  ·  Source: leecade/react-native-swiper

Would it be possible to get a callback how much of the incoming view is visible to create animations on the vanishing view for example?

Most helpful comment

@BraunreutherA technically you can do this by resolving the width of your views keeping track of the current index and implementing an onScroll handler and resolving the height of the current screen.

// this.currentIndex = 0;
// this.viewWidth = Dimensions.get('window').width;
<Swiper
        scrollEventThrottle={16}
        onScroll={(e) =>
                console.log(e.nativeEvent.contentOffset.x / (this.viewWidth * (this.currentIndex + 1))); // percent transition
       }
>
    ...
</Swiper>

All 2 comments

+1 would like this too

@BraunreutherA technically you can do this by resolving the width of your views keeping track of the current index and implementing an onScroll handler and resolving the height of the current screen.

// this.currentIndex = 0;
// this.viewWidth = Dimensions.get('window').width;
<Swiper
        scrollEventThrottle={16}
        onScroll={(e) =>
                console.log(e.nativeEvent.contentOffset.x / (this.viewWidth * (this.currentIndex + 1))); // percent transition
       }
>
    ...
</Swiper>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

itinance picture itinance  ·  3Comments

tibic picture tibic  ·  3Comments

nomoreboredom picture nomoreboredom  ·  3Comments

agzuniverse picture agzuniverse  ·  3Comments

gwhite-dayspring picture gwhite-dayspring  ·  3Comments