react-component / m-list-view

ReactNative ListView Web Port
http://react-component.github.io/m-list-view/
85 stars 28 forks source link

希望可以滚动到列表底部 #24

Open hsuehic opened 6 years ago

hsuehic commented 6 years ago

我在做一个IM 聊天界面的时候,希望初始化和有消息更新的时候,列表的滚动条都可以滚动到底部。

scrollToCurrent() {
    const self = this
    setTimeout(() => {
      if (self.listView) {
        const { listviewRef } = self.listView
        if (listviewRef) {
          const scrollProperties = listviewRef.ListViewRef.getMetrics()
          if (scrollProperties) {
            const { contentLength, visibleLength } = scrollProperties
            if (contentLength && visibleLength) {
              const offset = contentLength - visibleLength
              if (offset > 0) {
                listviewRef.scrollTo(0, offset)
              }
            }
          }
        }
      }
    })
  }

使用以上的代码,拿到的 contentLength不是正确。

hsuehic commented 6 years ago

能否新增加个属性,让列表从后面的行开始渲染, 然后滚动到底部,下拉时渲染前面的记录?