Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ const ScrollViewStickyHeader: component(
if (child.props.onLayout) {
child.props.onLayout(event);
}
// VirtualizedList cells use `onCellLayout` instead of `onLayout` for
// layout tracking. Forward the sticky wrapper's layout (which is measured
// relative to the ScrollView) so ListMetricsAggregator records the correct
// offset instead of the cell's offset relative to this wrapper (y = 0).
if (child.props.onCellLayout) {
child.props.onCellLayout(event, child.props.cellKey, child.props.index);
}
};

const child = React.Children.only<$FlowFixMe>(props.children);
Expand Down Expand Up @@ -304,6 +311,7 @@ const ScrollViewStickyHeader: component(
}>
{cloneElement(child, {
onLayout: undefined, // we call this manually through our this._onLayout
onCellLayout: undefined, // likewise, forwarded manually above for VirtualizedList cells
style: styles.fill, // We transfer the child style to the wrapper.
})}
</Animated.View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ export default class CellRenderer<ItemT> extends React.PureComponent<
index,
);

// NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
// called explicitly by `ScrollViewStickyHeader`.
// NOTE: that when this is a sticky header, `onCellLayout` will get automatically intercepted
// and called explicitly by `ScrollViewStickyHeader` using the wrapper's ScrollView-relative
// coordinates. `onLayout` is similarly forwarded for non-VirtualizedList sticky children.
const itemSeparator: React.Node = isValidElement(ItemSeparatorComponent)
? // $FlowFixMe[incompatible-type]
ItemSeparatorComponent
Expand Down
Loading