daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from "react";
  2. import SwiperFlatList from "react-native-swiper-flatlist";
  3.  
  4. export default class MyComponent extends React.Component {
  5. // INSIDE A COMPONENT
  6.   constructor(props) {
  7.     super(props);
  8.     this.currentIndex = 0;
  9.     this._updateIndex = this._updateIndex.bind(this);
  10.     this.viewabilityConfig = {
  11.       itemVisiblePercentThreshold: 50
  12.     };
  13.   }
  14.  
  15.   _updateIndex({ viewableItems }) {
  16.   // getting the first element visible index
  17.     this.currentIndex = viewableItems[0].index;
  18.   }
  19.  
  20.   render() {
  21.     return  // ...
  22.       <SwiperFlatList
  23.               loop={false}
  24.               index={0}
  25.               onViewableItemsChanged={this._updateIndex}
  26.               viewabilityConfig={this.viewabilityConfig}
  27.             >
  28.              {data}
  29.             </SwiperFlatList>;
  30.             }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top