From 970af503ff264423caa9c0c2c2dd03a9d59fd299 Mon Sep 17 00:00:00 2001 From: Masayuki Iwai Date: Mon, 7 Aug 2017 12:11:45 +0900 Subject: [PATCH 1/2] Fix a bug with sticky headers don't stick at correct position. --- Libraries/Components/ScrollView/ScrollView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 0d668a8eab6d48..abf0749206fb16 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -438,7 +438,8 @@ const ScrollView = createReactClass({ }, componentWillMount: function() { - this._scrollAnimatedValue = new Animated.Value(0); + this._scrollAnimatedValue = new Animated.Value(this.props.contentOffset ? this.props.contentOffset.y : 0); + this._scrollAnimatedValue.setOffset(this.props.contentInset ? this.props.contentInset.top : 0); this._stickyHeaderRefs = new Map(); this._headerLayoutYs = new Map(); }, From 44a5ec87d1c06f4fb52bb5602f62b9015f76a786 Mon Sep 17 00:00:00 2001 From: Masayuki Iwai Date: Mon, 7 Aug 2017 16:45:33 +0900 Subject: [PATCH 2/2] Support setting negative value for contentOffset. --- React/Views/RCTScrollView.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/React/Views/RCTScrollView.m b/React/Views/RCTScrollView.m index 6253599206cbc7..15821732cecf3b 100644 --- a/React/Views/RCTScrollView.m +++ b/React/Views/RCTScrollView.m @@ -317,8 +317,8 @@ - (void)setFrame:(CGRect)frame CGSize boundsSize = self.bounds.size; self.contentOffset = CGPointMake( - MAX(0, MIN(originalOffset.x, fullContentSize.width - boundsSize.width)), - MAX(0, MIN(originalOffset.y, fullContentSize.height - boundsSize.height))); + MAX(-contentInset.left, MIN(originalOffset.x, fullContentSize.width - boundsSize.width)), + MAX(-contentInset.top, MIN(originalOffset.y, fullContentSize.height - boundsSize.height))); } #if !TARGET_OS_TV