如何停止在 ScrollView 中滑动?
How to stop swipe in ScrollView?
look this video of current scrolling behavior。我想在手指离开屏幕后立即禁用滚动。
编辑:视频显示用户滚动列表。当手指离开屏幕时,您会看到滚动会继续向上或向下滚动一小段时间。
我相信你想要的基本上是当动量存在时停止滚动。为此,您可以在 ScrollView 上使用 onMomentumScrollBegin
回调并对其调用 .scrollToEnd({animated: false})
。
这是它的样子:
<ScrollView
ref={(ref) => this.scrollView = ref}
scrollEnabled={this.state.scroll}
onMomentumScrollBegin={
() => this.scrollView.scrollToEnd({animated: false})
}
>
...CONTENT HERE...
</ScrollView>
我想你需要的是:
<ScrollView
bounces={false}
/>
这样滚动结束后,滚动动画就不会继续了,直接停止了。
我想你的意思是一旦用户抬起手指就停止滚动
尝试:
<ScrollView
...
decelerationRate = {0}
/>
look this video of current scrolling behavior。我想在手指离开屏幕后立即禁用滚动。
编辑:视频显示用户滚动列表。当手指离开屏幕时,您会看到滚动会继续向上或向下滚动一小段时间。
我相信你想要的基本上是当动量存在时停止滚动。为此,您可以在 ScrollView 上使用 onMomentumScrollBegin
回调并对其调用 .scrollToEnd({animated: false})
。
这是它的样子:
<ScrollView
ref={(ref) => this.scrollView = ref}
scrollEnabled={this.state.scroll}
onMomentumScrollBegin={
() => this.scrollView.scrollToEnd({animated: false})
}
>
...CONTENT HERE...
</ScrollView>
我想你需要的是:
<ScrollView
bounces={false}
/>
这样滚动结束后,滚动动画就不会继续了,直接停止了。
我想你的意思是一旦用户抬起手指就停止滚动 尝试:
<ScrollView
...
decelerationRate = {0}
/>