【问题标题】:How to modify ScrollView scroll sensitivity?如何修改 ScrollView 滚动灵敏度?
【发布时间】:2021-11-30 14:20:14
【问题描述】:

我有一个启用分页的水平 ScrollView,每个页面都是垂直的 FlatList。

通常,当用户尝试在 FlatList 上向下滚动时,会发生水平滚动并最终进入下一个 ScrollView 页面。

有没有办法配置 ScrollView 敏感度,使其仅在水平拖动较大时触发,如果有意义的话?

我已经查看了文档,但没有找到任何东西。

<ScrollView
    ref={swiperRef}
    horizontal={true}
    decelerationRate={'normal'}
    snapToInterval={screenWidth} 
    snapToAlignment={'center'}
    pagingEnabled={true}
    disableIntervalMomentum={true}
    >
    {categories.map((category, index) => {
        return (
            <View key={category?.code}>
               <FlatList
                  data={categories[index]}
                  renderItem={renderBox}
                  keyExtractor={(item, index) => index}
                  contentContainerStyle={styles.categoryNewsContainer}
                  onEndReached={({ distanceFromEnd }) => {
                    loadMore()
                  }}
                  onEndReachedThreshold={0.1}
                  onRefresh={() => refresh()}
                  refreshing={isRefreshing}
                />
            </View>
                )
    })}
</ScrollView>

【问题讨论】:

    标签: javascript android react-native scrollview


    【解决方案1】:

    我遇到了类似的问题,但垂直滚动太敏感了。这是我在原生 Android 中的解决方案,所以它可能会有所帮助:

    https://github.com/gavingt/upcoming-games/blob/master/app/src/main/java/com/gavinsappcreations/upcominggames/ui/detail/NestedScrollingParentScrollView.kt

    【讨论】:

      【解决方案2】:

      您可以只使用decelerationRate 来获得“快速”/“正常”或任何浮动速度

      【讨论】:

        猜你喜欢
        • 2015-01-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-14
        • 2012-07-30
        • 1970-01-01
        相关资源
        最近更新 更多