Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. scrollToItem = () => {
  2. const MARGIN = 4;
  3. let i = this.state.contentOffset.y / (c.PLACE_HEIGHT + MARGIN);
  4.  
  5. if (this.state.scrollDirection === 'down') {
  6. i = Math.ceil(i) // 1.1 2
  7. } else {
  8. i = Math.floor(i); // 1.1 1
  9. }
  10.  
  11. i !== -1 && i < this.props.places.length && this.props.scrollToPlace(i, true)
  12. };
  13.  
  14. <FlatList
  15. data={places}
  16. enderItem={this.renderPlace}
  17. keyExtractor={({place_id}) => place_id}
  18. onScroll={this.onScroll}
  19. scrollEventThrottle={30}
  20. onViewableItemsChanged={this.onViewableItemsChanged}
  21. viewabilityConfig={{itemVisiblePercentThreshold: 0}}
  22. getItemLayout={this.getItemLayout}
  23. scrollEnabled={scrollEnabled || !this.state.isFingerPress}
  24. style={{height: scrollBarHeight}}
  25. onScrollEndDrag={ () => {}}
  26. {...this._panResponder.panHandlers}
  27. />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement