最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React Native Scrollview Stop Momentum? (expo) - Stack Overflow

programmeradmin1浏览0评论

I am using a ScrollView, and when I scroll and let go, it keeps scrolling because of momentum. I want it to only scroll when the finger is touching the screen, I do not want the momentum. Is this possible, if so, how?

I am using a ScrollView, and when I scroll and let go, it keeps scrolling because of momentum. I want it to only scroll when the finger is touching the screen, I do not want the momentum. Is this possible, if so, how?

Share Improve this question asked Feb 24, 2018 at 19:32 Simon AnderssonSimon Andersson 7912 gold badges9 silver badges32 bronze badges 3
  • Set decelerationRate to "fast". facebook.github.io/react-native/docs/… – Wainage Commented Feb 25, 2018 at 17:01
  • 1 this is IOS only – Simon Andersson Commented Feb 26, 2018 at 18:36
  • any luck with this 8 months later? – jpls93 Commented Oct 8, 2018 at 12:44
Add a ment  | 

3 Answers 3

Reset to default 2

Using decelerationRate prop with value 0 can help.

Based on the document, its value accept string normal | fast and floating number from 0 to 1 orderly from slowest to fastest.

<ScrollView decelerationRate={0}>

</ScrollView>

** I am using RN v0.59 **

Add 2 following properties to ScrollView:

snapToInterval={1}
disableIntervalMomentum={true}

Why not try this (RN 0.55)

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

评论列表(0)

  1. 暂无评论