Guh*_*han 5 react-native react-native-flatlist flatlist
我现在有一个包含一堆项目的平面列表,当我按下按钮时,平面列表使用 ref 和scrollToIndex 方法向下滚动。但滚动动画比我需要的要快,是否有办法增加滚动动画持续时间?
这是向上滚动(向上滑动手势)功能的代码
const scrollUp = () => {
console.log("Up Gesture", currentIndex);
if (currentIndex <= DATA.length - 1) {
if (currentIndex != DATA.length - 1) {
flatlistRef.current.scrollToIndex({
index: currentIndex + 1,
animated: true,
viewOffset: 200,
});
setCurrentIndex(currentIndex + 1);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是jsx返回的
return (
<>
<StatusBar hidden={true} />
<Button title="click me" style={{ position: 'absolute', zIndex: 20, top: 20, }} onPress={() => scrollUp()} />
<AnimatedFlatList
{...{ onScroll, ListFooterComponent, ListHeaderComponent, onScrollEndDrag }}
ref={flatlistRef}
overScrollMode='never'
// scrollEnabled={false}
scrollEventThrottle={1}
data={DATA}
style={{ width: WINDOW_WIDTH, height: WINDOW_HEIGHT, backgroundColor: 'black' }}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item, index }) => {
return <SinglePost aspectRatio={item.aspectRatio} uri={item.imgUrl} y={y} index={index} />
}}
/>
</>
);
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激,过去几天我一直在研究这个错误,但我没有找到任何明确的解决方案:(
| 归档时间: |
|
| 查看次数: |
1299 次 |
| 最近记录: |