【问题标题】:React Native Scrollview Stop Momentum? (expo)React Native Scrollview 停止动量? (世博会)
【发布时间】:2018-08-04 15:04:12
【问题描述】:
我正在使用ScrollView,当我滚动并松开时,它会因为动量而继续滚动。我希望它只在手指触摸屏幕时滚动,我不想要这种势头。这可能吗,如果可以,怎么做?
【问题讨论】:
标签:
javascript
react-native
【解决方案1】:
使用带有值0 的decelerationRate 属性可以提供帮助。
基于the document,它的值接受字符串normal | fast和从0到1的浮点数,从最慢到最快。
<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>