我试图通过单击按钮来实现滚动到顶部功能,以在滑动列表视图的顶部位置滚动,并尝试从SectionList访问方法scrollToLocation,但是我无法使用SwipelistView的引用来访问它。所以我需要帮助来实现它。下面是渲染函数中的代码。
<SwipelistView
useSectionList={true}
sections={this.state.data}
keyExtractor={(item,section) => item.key }
renderItem={this.renderRow}
renderHiddenItem={this.renderHiddenItems}
renderSectionHeader={this.renderSectionHeader}
rightOpenValue={-75}
stopRightSwipe={-75}
previewRowKey={'0'}
closeonRowPress={true}
previewOpenValue={-40}
onRowDidOpen={this.onRowDidOpen}
stickySectionHeadersEnabled={false}
bounces
disableRightSwipe={true}
enableEmptySections={false}
tension={20}
scrollsToTop={true}
onEndReachedThreshold={0.99}
onEndReached={() => {
this.setState({ isScrollToTopVisible: !this.state.isScrollToTopVisible })
}}
ref={(ref) => this.sectionListRef = ref }
/>
滚动到列表顶部的代码。
scrollToTop() {
this.sectionListRef.scrollToLocation({ offset : 0,animated : true })
}
OS:iOS 12.1
反应本机版本:v0.59.8
native-swipe-list-view版本:v2.0.3