【发布时间】:2021-04-29 06:52:47
【问题描述】:
我正在尝试在我的 react native 部分列表中完成滚动动量后运行一个函数。
参考文档后,我发现了有关 onMomentumScrollEnd 的信息。但问题是onMomentumScrollEnd 仅在我们手动滚动部分列表时有效。但我在函数中使用scrollToLocation 滚动到特定部分。使用 onMomentumScrollEnd 时似乎不会触发。使用scrollToLocation时如何在滚动完成时触发此功能@
<SectionList
sections={groupActivities}
keyExtractor={(item) => item?.id?.toString()}
ref={sectionList}
getItemLayout={getItemLayout}
onMomentumScrollEnd={() => console.log('ends')}
renderItem={({ section: { title }, item, index }) => {
const sectionTitle = String(title);
return (
<View style={activityContainer}>
<MCard
startTime={getFormattedStartTime(item.duration?.start)}
/>
</View>
);
}}
renderSectionHeader={({ section: { title } }) => (
<MText>
{setSectionTitle}
</MText>
)}
refreshing={groupActivityLoading}
onRefresh={handleRefresh}
/>
【问题讨论】:
标签: javascript reactjs react-native scroll react-native-sectionlist