How to get currently visible index in RN flat list

前端 未结 5 1121
温柔的废话
温柔的废话 2021-02-01 01:54

I have a horizontal flat list where each item is width:300 All I am trying to do is to get index of currently visible item.



        
5条回答
  •  轮回少年
    2021-02-01 02:42

    this.handleScroll = (event) => {
      let yOffset = event.nativeEvent.contentOffset.y
      let contentHeight = event.nativeEvent.contentSize.height
      let value = yOffset / contentHeight
    }
    
    
    

    Get the round-off value to calculate the page-number/index.

提交回复
热议问题