React Native nested ScrollView locking up

后端 未结 5 1518
野趣味
野趣味 2021-01-30 17:03

I\'m trying to nest ScrollViews in React Native; a horizontal scroll with nested vertical scrolls.

Here\'s an example:

var Test = React.createClass({
           


        
5条回答
  •  忘了有多久
    2021-01-30 17:44

    Modify node_modules/react-native/Libraries/Components/ScrollResponder.js: Line 136 (See UPDATE):

    scrollResponderHandleScrollShouldSetResponder: function(): boolean {
        return this.state.isTouching;
    },
    

    UPDATE: I find if the scroll view is currently animating and wants to become the responder, then it will reject. Line 189 in ScrollResponder.js. So I modify Line 340 and it work for me:

    scrollResponderIsAnimating: function(): boolean {
      // var now = Date.now();
      // var timeSinceLastMomentumScrollEnd = now - this.state.lastMomentumScrollEndTime;
      // var isAnimating = timeSinceLastMomentumScrollEnd < IS_ANIMATING_TOUCH_START_THRESHOLD_MS ||
      //   this.state.lastMomentumScrollEndTime < this.state.lastMomentumScrollBeginTime;
      // return isAnimating;
        return false;
    },
    

    You can see here: https://github.com/facebook/react-native/issues/41

提交回复
热议问题