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

cngeru picture cngeru  路  18Comments

innerexception picture innerexception  路  41Comments

nikolasleblanc picture nikolasleblanc  路  17Comments

ShawnBaek picture ShawnBaek  路  27Comments

divyenduz picture divyenduz  路  21Comments