Guest User

Untitled

a guest
Jan 24th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment