【问题标题】:React Native Scrollview Stop Momentum? (expo)React Native Scrollview 停止动量? (世博会)
【发布时间】:2018-08-04 15:04:12
【问题描述】:

我正在使用ScrollView,当我滚动并松开时,它会因为动量而继续滚动。我希望它只在手指触摸屏幕时滚动,我不想要这种势头。这可能吗,如果可以,怎么做?

【问题讨论】:

标签: javascript react-native


【解决方案1】:

使用带有值0decelerationRate 属性可以提供帮助。

基于the document,它的值接受字符串normal | fast和从01的浮点数,从最慢到最快。

<ScrollView decelerationRate={0}>

</ScrollView>

** 我正在使用 RN v0.59 **

【讨论】:

    【解决方案2】:

    将以下 2 个属性添加到 ScrollView

    snapToInterval={1}
    disableIntervalMomentum={true}
    

    【讨论】:

      【解决方案3】:

      为什么不试试这个(RN 0.55)

      <ScrollView 
        ref={r => (this.scrollView = r)}
        onScrollEndDrag={e => {
          return this.scrollView.scrollTo({ y: e.nativeEvent.contentOffset.y });
        }}>
        ...
      </ScrollView>
      

      【讨论】:

        猜你喜欢
        • 2023-02-17
        • 1970-01-01
        • 1970-01-01
        • 2022-12-05
        • 2023-04-09
        • 1970-01-01
        • 1970-01-01
        • 2021-12-10
        • 2021-05-30
        相关资源
        最近更新 更多