小编Guh*_*han的帖子

如何在本机反应中更改平面列表滚动动画持续时间?

我现在有一个包含一堆项目的平面列表,当我按下按钮时,平面列表使用 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={{ …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-flatlist flatlist

5
推荐指数
0
解决办法
1299
查看次数