From a8395fe1845c9539ae7dccff4a5a03a71185b144 Mon Sep 17 00:00:00 2001 From: Neo Date: Wed, 10 May 2017 12:01:03 +0800 Subject: [PATCH] fix stickySectionHeader re-render issue Close #13500 --- .../ScrollView/ScrollViewStickyHeader.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index 8db0f0b4f43b99..b072a67c6bf0fb 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -61,8 +61,9 @@ class ScrollViewStickyHeader extends React.Component { render() { const {measured, layoutHeight, layoutY, nextHeaderLayoutY} = this.state; + const inputRange: Array = [-1, 0]; + const outputRange: Array = [0, 0]; - let translateY; if (measured) { // The interpolation looks like: // - Negative scroll: no translation @@ -74,8 +75,8 @@ class ScrollViewStickyHeader extends React.Component { // header to continue scrolling up and make room for the next sticky header. // In the case that there is no next header just translate equally to // scroll indefinetly. - const inputRange = [-1, 0, layoutY]; - const outputRange: Array = [0, 0, 0]; + inputRange.push(layoutY); + outputRange.push(0); // Sometimes headers jump around so we make sure we don't violate the monotonic inputRange // condition. const collisionPoint = (nextHeaderLayoutY || 0) - layoutHeight; @@ -86,14 +87,12 @@ class ScrollViewStickyHeader extends React.Component { inputRange.push(layoutY + 1); outputRange.push(1); } - translateY = this.props.scrollAnimatedValue.interpolate({ - inputRange, - outputRange, - }); - } else { - translateY = 0; } + const translateY = this.props.scrollAnimatedValue.interpolate({ + inputRange, + outputRange, + }); const child = React.Children.only(this.props.children); return (