Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from "react";
- import SwiperFlatList from "react-native-swiper-flatlist";
- export default class MyComponent extends React.Component {
- // INSIDE A COMPONENT
- constructor(props) {
- super(props);
- this.currentIndex = 0;
- this._updateIndex = this._updateIndex.bind(this);
- this.viewabilityConfig = {
- itemVisiblePercentThreshold: 50
- };
- }
- _updateIndex({ viewableItems }) {
- // getting the first element visible index
- this.currentIndex = viewableItems[0].index;
- }
- render() {
- return // ...
- <SwiperFlatList
- loop={false}
- index={0}
- onViewableItemsChanged={this._updateIndex}
- viewabilityConfig={this.viewabilityConfig}
- >
- {data}
- </SwiperFlatList>;
- }
- }
Add Comment
Please, Sign In to add comment