Skip to content

Commit 60d5a5d

Browse files
authored
Merge pull request #3 from azimgd/fix-flatlist-ios-safari-render-bug
2 parents bfe201a + 5548f3a commit 60d5a5d

File tree

1 file changed

+29
-9
lines changed
  • packages/react-native-web/src/vendor/react-native/VirtualizedList

1 file changed

+29
-9
lines changed

packages/react-native-web/src/vendor/react-native/VirtualizedList/index.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
12031203

12041204
_defaultRenderScrollComponent = props => {
12051205
const onRefresh = props.onRefresh;
1206+
const inversionStyle = this.props.inverted
1207+
? this.props.horizontal
1208+
? styles.rowReverse
1209+
: styles.columnReverse
1210+
: null;
1211+
12061212
if (this._isNestedWithSameOrientation()) {
12071213
// $FlowFixMe - Typing ReactNativeComponent revealed errors
12081214
return <View {...props} />;
@@ -1231,11 +1237,23 @@ class VirtualizedList extends React.PureComponent<Props, State> {
12311237
props.refreshControl
12321238
)
12331239
}
1240+
contentContainerStyle={StyleSheet.compose(
1241+
inversionStyle,
1242+
this.props.contentContainerStyle,
1243+
)}
12341244
/>
12351245
);
12361246
} else {
12371247
// $FlowFixMe Invalid prop usage
1238-
return <ScrollView {...props} />;
1248+
return (
1249+
<ScrollView
1250+
{...props}
1251+
contentContainerStyle={StyleSheet.compose(
1252+
inversionStyle,
1253+
this.props.contentContainerStyle,
1254+
)}
1255+
/>
1256+
);
12391257
}
12401258
};
12411259

@@ -1513,11 +1531,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
15131531
};
15141532

15151533
_onScroll = (e: Object) => {
1516-
var contentOffset = (this.props.inverted) ? {
1517-
x: - e.nativeEvent.contentOffset.x,
1518-
y: - e.nativeEvent.contentOffset.y,
1519-
} : e.nativeEvent.contentOffset
1520-
15211534
this._nestedChildLists.forEach(childList => {
15221535
childList.ref && childList.ref._onScroll(e);
15231536
});
@@ -1527,7 +1540,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
15271540
const timestamp = e.timeStamp;
15281541
let visibleLength = this._selectLength(e.nativeEvent.layoutMeasurement);
15291542
let contentLength = this._selectLength(e.nativeEvent.contentSize);
1530-
let offset = this._selectOffset(contentOffset);
1543+
let offset = this._selectOffset(e.nativeEvent.contentOffset);
15311544
let dOffset = offset - this._scrollMetrics.offset;
15321545

15331546
if (this._isNestedWithSameOrientation()) {
@@ -1703,6 +1716,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
17031716
this._getFrameMetricsApprox,
17041717
this._scrollMetrics,
17051718
);
1719+
1720+
// revert the state if calculations are off
1721+
// this would only happen on the inverted flatlist (probably a bug with overscroll-behavior)
1722+
// when scrolled from bottom all the way up until onEndReached is triggered
1723+
if (newState.first === newState.last) {
1724+
newState = state
1725+
}
17061726
}
17071727
}
17081728
} else {
@@ -2061,10 +2081,10 @@ function describeNestedLists(childList: {
20612081

20622082
const styles = StyleSheet.create({
20632083
verticallyInverted: {
2064-
flexDirection: 'column-reverse',
2084+
transform: [{scaleY: -1}],
20652085
},
20662086
horizontallyInverted: {
2067-
flexDirection: 'row-reverse',
2087+
transform: [{scaleX: -1}],
20682088
},
20692089
row: {
20702090
flexDirection: 'row',

0 commit comments

Comments
 (0)