[英]reactnative - flatlist - use scrollbar to scroll
I work on react native (react 16.2.0 , react native 0.54) 我在React Native上工作(React 16.2.0,React Native 0.54)
I display a large list of items with flatlist . 我用flatlist显示大量项目。 We can take the example of a contact list with 1000 employees.
我们可以举一个拥有1000名员工的联系人列表为例。
The flatlist is working good, no bug, but i cannot press the cursor of the scrollbar to navigate as in native Android or in html page. 平面列表运行良好,没有错误,但是我无法按滚动条的光标进行导航,就像在本机Android或html页面中一样。
Steps to Reproduce 重现步骤
<FlatList
ref="listRef"
data={this.state.data}
keyExtractor={(item, index) => item.name.toString()}
removeClippedSubviews={true}
extraData={{ refreshListIteration: this.state.refreshListIteration }}
renderItem={({ item, index }) => this.renderListItem(item, index)}
initialNumToRender={15}
ItemSeparatorComponent={this.renderSeparator}
ListHeaderComponent={this.renderOptionBar}
ListFooterComponent={this.renderFooter}
onEndThreshold={5}
/>
Expected Behavior 预期行为
So i have 1000 items in this.state.data
that i need to display. 所以我需要在
this.state.data
中显示1000个项目。
I initaly display 15 items ( initialNumToRender={15}
) for faster performance, so if i want to see the 600th item i need to scroll down like 40 times, not very user friendly. 我最初显示15个项目(
initialNumToRender={15}
)以获得更快的性能,因此,如果我想查看第600个项目,则需要向下滚动40次,但不是非常用户友好。 I cannot press the cursor of the scrollbar like an html page to navigate very fast to the end of the list. 我无法像html页面一样按滚动条的光标快速导航到列表的末尾。
Question 题
Did you have any idea how to fix this or to navigate fastly without scrolling down dozen times ? 您是否知道如何解决此问题或无需向下滚动数十次即可快速导航?
This is not a typical behaviour on iOS. 这不是iOS上的典型行为。 The scroll indicator is usually not tappable.
滚动指示器通常不可点击。
FlatList has a prop called initialScrollIndex that you could use if you want the list to load at a particular item. FlatList有一个名为initialScrollIndex的道具,如果希望列表在特定项目上加载,可以使用该道具。 Alternatively, if you don't want to do it on start.
或者,如果您不想一开始就这样做。 FlatList also has the methods scrollToIndex and scrollToItem which allow you to programatically move to a specific index or item.
FlatList还具有方法scrollToIndex和scrollToItem ,可通过这些方法以编程方式移动到特定索引或项目。 https://facebook.github.io/react-native/docs/flatlist.html
https://facebook.github.io/react-native/docs/flatlist.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.