@@ -1203,6 +1203,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1203
1203
1204
1204
_defaultRenderScrollComponent = props => {
1205
1205
const onRefresh = props . onRefresh ;
1206
+ const inversionStyle = this . props . inverted
1207
+ ? this . props . horizontal
1208
+ ? styles . rowReverse
1209
+ : styles . columnReverse
1210
+ : null ;
1211
+
1206
1212
if ( this . _isNestedWithSameOrientation ( ) ) {
1207
1213
// $FlowFixMe - Typing ReactNativeComponent revealed errors
1208
1214
return < View { ...props } /> ;
@@ -1231,11 +1237,23 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1231
1237
props . refreshControl
1232
1238
)
1233
1239
}
1240
+ contentContainerStyle = { StyleSheet . compose (
1241
+ inversionStyle ,
1242
+ this . props . contentContainerStyle ,
1243
+ ) }
1234
1244
/>
1235
1245
) ;
1236
1246
} else {
1237
1247
// $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
+ ) ;
1239
1257
}
1240
1258
} ;
1241
1259
@@ -1513,11 +1531,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1513
1531
} ;
1514
1532
1515
1533
_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
-
1521
1534
this . _nestedChildLists . forEach ( childList => {
1522
1535
childList . ref && childList . ref . _onScroll ( e ) ;
1523
1536
} ) ;
@@ -1527,7 +1540,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1527
1540
const timestamp = e.timeStamp;
1528
1541
let visibleLength = this._selectLength(e.nativeEvent.layoutMeasurement);
1529
1542
let contentLength = this._selectLength(e.nativeEvent.contentSize);
1530
- let offset = this._selectOffset(contentOffset);
1543
+ let offset = this._selectOffset(e.nativeEvent. contentOffset);
1531
1544
let dOffset = offset - this._scrollMetrics.offset;
1532
1545
1533
1546
if (this._isNestedWithSameOrientation()) {
@@ -1703,6 +1716,13 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1703
1716
this . _getFrameMetricsApprox ,
1704
1717
this . _scrollMetrics ,
1705
1718
) ;
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
+ }
1706
1726
}
1707
1727
}
1708
1728
} else {
@@ -2061,10 +2081,10 @@ function describeNestedLists(childList: {
2061
2081
2062
2082
const styles = StyleSheet . create ( {
2063
2083
verticallyInverted : {
2064
- flexDirection : 'column-reverse' ,
2084
+ transform : [ { scaleY : - 1 } ] ,
2065
2085
} ,
2066
2086
horizontallyInverted : {
2067
- flexDirection : 'row-reverse' ,
2087
+ transform : [ { scaleX : - 1 } ] ,
2068
2088
} ,
2069
2089
row : {
2070
2090
flexDirection : 'row' ,
0 commit comments