Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix stickySectionHeader re-render issue #13885

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions Libraries/Components/ScrollView/ScrollViewStickyHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ class ScrollViewStickyHeader extends React.Component {

render() {
const {measured, layoutHeight, layoutY, nextHeaderLayoutY} = this.state;
const inputRange: Array<number> = [-1, 0];
const outputRange: Array<number> = [0, 0];

let translateY;
if (measured) {
// The interpolation looks like:
// - Negative scroll: no translation
Expand All @@ -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<number> = [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;
Expand All @@ -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 (
Expand Down