bolan9999 / react-native-largelist

The best large list component for React Native.
https://bolan9999.github.io/react-native-largelist/
MIT License
2.32k stars 261 forks source link

Android 如何判断列表是否在顶端? #92

Closed demobo-com closed 6 years ago

demobo-com commented 6 years ago

如今遇到的问题是,安卓无法判断列表是否到顶端,下滑列表会强制刷新。附上gify显示

case 1: On top of the list, scroll down, trigger OnRefresh()

case 2: In the middle of the list, scroll down, still trigger OnRefresh()

case 3: Scroll up, hold the finger to scroll down, won't trigger OnRefresh()

demobo-com commented 6 years ago

videotogif_2018 02 23_19 40 37

bolan9999 commented 6 years ago

你这个是LargeList的刷新 ?样式不正确吧,我的sample没有出现这种情况吧

demobo-com commented 6 years ago
  import { LargeList } from "react-native-largelist";
  list = (
    <LargeList
      onRefresh={this.onRefresh}
      refreshing={isInventoryLoading}
      safeMargin={1800}
      dynamicMargin={1300}
      numberOfRowsInSection={()=> 1}
      renderCell={this.renderListItems}
      heightForCell={() => styles.height}
      renderFooter={this.renderFooterRow}
      heightForLoadMore={() => 1}
      style={styles.flatList}
    />);

  onRefresh = () => {
      this.props.inventoryFetchData(this.props.currentUser.uid);
  }

in styles.js:

flatList: {
      height: deviceHeight - (Platform.isPad ? (100 + 80) : (64 + 55)) - (Platform.OS === "android" ? 20 : 0) - (Platform.isPad ? deviceHeight / 20 : 30),
      backgroundColor: "transparent",
  },

您好,这是我们的代码,iOS 没有出现以上问题,只有android 会有下拉刷新的问题。

bolan9999 commented 6 years ago

numberOfRowsInSection 返回1怎么可能,只有一行?你这个不是你真实的代码吧。

至于你说那个问题,我没遇到过。我的sample没有这种问题吧。 如果要找原因的话,需要你发下RN版本,和你的demo代码。

demobo-com commented 6 years ago

谢谢,找到原因了,当初因为还没支持左滑功能所以我们自己套了list, 所以把 section 设成 1行。 刚刚把section 改成 .length。 问题好像解决了。万分感谢!

bolan9999 commented 6 years ago

好的