React native 如何在react native中更改平面列表滚动动画持续时间?
我现在有一个平面列表,里面有一堆项目,当我按下按钮时,平面列表使用ref和scrollToIndex方法向下滚动。但是滚动动画比我所需要的要快,是否还有增加滚动动画持续时间的方法 这是scrollup(向上滑动手势)功能的代码React native 如何在react native中更改平面列表滚动动画持续时间?,react-native,react-native-android,react-native-flatlist,flatlist,React Native,React Native Android,React Native Flatlist,Flatlist,我现在有一个平面列表,里面有一堆项目,当我按下按钮时,平面列表使用ref和scrollToIndex方法向下滚动。但是滚动动画比我所需要的要快,是否还有增加滚动动画持续时间的方法 这是scrollup(向上滑动手势)功能的代码 constscrollup=()=>{ 日志(“向上手势”,currentIndex); 如果(当前索引) index.toString()} renderItem={({item,index})=>{ 返回 }} /> ); 任何帮助都将不胜感激,过去几天我一直在研究
constscrollup=()=>{
日志(“向上手势”,currentIndex);
如果(当前索引)
index.toString()}
renderItem={({item,index})=>{
返回
}}
/>
);
任何帮助都将不胜感激,过去几天我一直在研究这个bug,但我没有找到任何明确的解决方案:(我也尝试过对此进行搜索,但似乎没有延迟属性或时间属性来控制动画速度。是的,这就是问题所在
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);
}
}
}
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} />
}}
/>
</>
);