forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react-native-web+0.19.13+005+osr-improvement.patch
208 lines (199 loc) · 11.1 KB
/
react-native-web+0.19.13+005+osr-improvement.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
diff --git a/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js b/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js
index 5689220..df40877 100644
--- a/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js
+++ b/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js
@@ -334,7 +334,7 @@ class VirtualizedList extends StateSafePureComponent {
zoomScale: 1
};
this._scrollRef = null;
- this._sentStartForContentLength = 0;
+ this._sentStartForFirstVisibleItemKey = null;
this._sentEndForContentLength = 0;
this._totalCellLength = 0;
this._totalCellsMeasured = 0;
@@ -686,16 +686,18 @@ class VirtualizedList extends StateSafePureComponent {
});
}
}
+ var itemCount = this.props.getItemCount(this.props.data);
var initialRenderRegion = VirtualizedList._initialRenderRegion(_props);
var minIndexForVisible = (_this$props$maintainV = (_this$props$maintainV2 = this.props.maintainVisibleContentPosition) == null ? void 0 : _this$props$maintainV2.minIndexForVisible) !== null && _this$props$maintainV !== void 0 ? _this$props$maintainV : 0;
this.state = {
cellsAroundViewport: initialRenderRegion,
renderMask: VirtualizedList._createRenderMask(_props, initialRenderRegion),
- firstVisibleItemKey: this.props.getItemCount(this.props.data) > minIndexForVisible ? VirtualizedList._getItemKey(this.props, minIndexForVisible) : null,
+ firstVisibleItemKey: itemCount > minIndexForVisible ? VirtualizedList._getItemKey(this.props, minIndexForVisible) : null,
// When we have a non-zero initialScrollIndex, we will receive a
// scroll event later so this will prevent the window from updating
// until we get a valid offset.
- pendingScrollUpdateCount: this.props.initialScrollIndex != null && this.props.initialScrollIndex > 0 ? 1 : 0
+ pendingScrollUpdateCount: this.props.initialScrollIndex != null && this.props.initialScrollIndex > 0 ? 1 : 0,
+ lastItemCount: itemCount
};
// REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
@@ -921,13 +923,13 @@ class VirtualizedList extends StateSafePureComponent {
// first and last could be stale (e.g. if a new, shorter items props is passed in), so we make
// sure we're rendering a reasonable range here.
var itemCount = newProps.getItemCount(newProps.data);
- if (itemCount === prevState.renderMask.numCells()) {
+ if (itemCount === prevState.renderMask.numCells() && itemCount === prevState.lastItemCount) {
return prevState;
}
var maintainVisibleContentPositionAdjustment = null;
var prevFirstVisibleItemKey = prevState.firstVisibleItemKey;
var minIndexForVisible = (_newProps$maintainVis = (_newProps$maintainVis2 = newProps.maintainVisibleContentPosition) == null ? void 0 : _newProps$maintainVis2.minIndexForVisible) !== null && _newProps$maintainVis !== void 0 ? _newProps$maintainVis : 0;
- var newFirstVisibleItemKey = newProps.getItemCount(newProps.data) > minIndexForVisible ? VirtualizedList._getItemKey(newProps, minIndexForVisible) : null;
+ var newFirstVisibleItemKey = itemCount > minIndexForVisible ? VirtualizedList._getItemKey(newProps, minIndexForVisible) : null;
if (newProps.maintainVisibleContentPosition != null && prevFirstVisibleItemKey != null && newFirstVisibleItemKey != null) {
if (newFirstVisibleItemKey !== prevFirstVisibleItemKey) {
// Fast path if items were added at the start of the list.
@@ -946,7 +948,8 @@ class VirtualizedList extends StateSafePureComponent {
cellsAroundViewport: constrainedCells,
renderMask: VirtualizedList._createRenderMask(newProps, constrainedCells),
firstVisibleItemKey: newFirstVisibleItemKey,
- pendingScrollUpdateCount: maintainVisibleContentPositionAdjustment != null ? prevState.pendingScrollUpdateCount + 1 : prevState.pendingScrollUpdateCount
+ pendingScrollUpdateCount: maintainVisibleContentPositionAdjustment != null ? prevState.pendingScrollUpdateCount + 1 : prevState.pendingScrollUpdateCount,
+ lastItemCount: itemCount
};
}
_pushCells(cells, stickyHeaderIndices, stickyIndicesFromProps, first, last, inversionStyle) {
@@ -1222,7 +1225,7 @@ class VirtualizedList extends StateSafePureComponent {
return ret;
}
}
- componentDidUpdate(prevProps) {
+ componentDidUpdate(prevProps, prevState) {
var _this$props7 = this.props,
data = _this$props7.data,
extraData = _this$props7.extraData;
@@ -1246,6 +1249,11 @@ class VirtualizedList extends StateSafePureComponent {
if (hiPriInProgress) {
this._hiPriInProgress = false;
}
+
+ if (this.state.cellsAroundViewport.first !== prevState.cellsAroundViewport.first ||
+ this.state.cellsAroundViewport.last !== prevState.cellsAroundViewport.last) {
+ this._maybeCallOnEdgeReached();
+ }
}
// Used for preventing scrollToIndex from being called multiple times for initialScrollIndex
@@ -1409,8 +1417,8 @@ class VirtualizedList extends StateSafePureComponent {
// Next check if the user just scrolled within the start threshold
// and call onStartReached only once for a given content length,
// and only if onEndReached is not being executed
- else if (onStartReached != null && this.state.cellsAroundViewport.first === 0 && isWithinStartThreshold && this._scrollMetrics.contentLength !== this._sentStartForContentLength) {
- this._sentStartForContentLength = this._scrollMetrics.contentLength;
+ else if (onStartReached != null && this.state.cellsAroundViewport.first === 0 && isWithinStartThreshold && this.state.firstVisibleItemKey !== this._sentStartForFirstVisibleItemKey) {
+ this._sentStartForFirstVisibleItemKey = this.state.firstVisibleItemKey;
onStartReached({
distanceFromStart
});
@@ -1419,7 +1427,7 @@ class VirtualizedList extends StateSafePureComponent {
// If the user scrolls away from the start or end and back again,
// cause onStartReached or onEndReached to be triggered again
else {
- this._sentStartForContentLength = isWithinStartThreshold ? this._sentStartForContentLength : 0;
+ this._sentStartForFirstVisibleItemKey = isWithinStartThreshold ? this._sentStartForFirstVisibleItemKey : null;
this._sentEndForContentLength = isWithinEndThreshold ? this._sentEndForContentLength : 0;
}
}
diff --git a/node_modules/react-native-web/src/vendor/react-native/VirtualizedList/index.js b/node_modules/react-native-web/src/vendor/react-native/VirtualizedList/index.js
index 459f017..fb2d269 100644
--- a/node_modules/react-native-web/src/vendor/react-native/VirtualizedList/index.js
+++ b/node_modules/react-native-web/src/vendor/react-native/VirtualizedList/index.js
@@ -79,6 +79,7 @@ type State = {
firstVisibleItemKey: ?string,
// When > 0 the scroll position available in JS is considered stale and should not be used.
pendingScrollUpdateCount: number,
+ lastItemCount: number,
};
/**
@@ -453,12 +454,13 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
const minIndexForVisible =
this.props.maintainVisibleContentPosition?.minIndexForVisible ?? 0;
+ const itemCount = this.props.getItemCount(this.props.data);
this.state = {
cellsAroundViewport: initialRenderRegion,
renderMask: VirtualizedList._createRenderMask(props, initialRenderRegion),
firstVisibleItemKey:
- this.props.getItemCount(this.props.data) > minIndexForVisible
+ itemCount > minIndexForVisible
? VirtualizedList._getItemKey(this.props, minIndexForVisible)
: null,
// When we have a non-zero initialScrollIndex, we will receive a
@@ -469,6 +471,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
this.props.initialScrollIndex > 0
? 1
: 0,
+ lastItemCount: itemCount,
};
// REACT-NATIVE-WEB patch to preserve during future RN merges: Support inverted wheel scroller.
@@ -809,16 +812,15 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
// first and last could be stale (e.g. if a new, shorter items props is passed in), so we make
// sure we're rendering a reasonable range here.
const itemCount = newProps.getItemCount(newProps.data);
- if (itemCount === prevState.renderMask.numCells()) {
+ if (itemCount === prevState.renderMask.numCells() && itemCount === prevState.lastItemCount) {
return prevState;
}
-
let maintainVisibleContentPositionAdjustment: ?number = null;
const prevFirstVisibleItemKey = prevState.firstVisibleItemKey;
const minIndexForVisible =
newProps.maintainVisibleContentPosition?.minIndexForVisible ?? 0;
const newFirstVisibleItemKey =
- newProps.getItemCount(newProps.data) > minIndexForVisible
+ itemCount > minIndexForVisible
? VirtualizedList._getItemKey(newProps, minIndexForVisible)
: null;
if (
@@ -866,6 +868,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
maintainVisibleContentPositionAdjustment != null
? prevState.pendingScrollUpdateCount + 1
: prevState.pendingScrollUpdateCount,
+ lastItemCount: itemCount,
};
}
@@ -1285,6 +1288,11 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
if (hiPriInProgress) {
this._hiPriInProgress = false;
}
+
+ if (this.state.cellsAroundViewport.first !== prevState.cellsAroundViewport.first ||
+ this.state.cellsAroundViewport.last !== prevState.cellsAroundViewport.last) {
+ this._maybeCallOnEdgeReached();
+ }
}
_averageCellLength = 0;
@@ -1325,7 +1333,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
zoomScale: 1,
};
_scrollRef: ?React.ElementRef<any> = null;
- _sentStartForContentLength = 0;
+ _sentStartForFirstVisibleItemKey: ?string = null;
_sentEndForContentLength = 0;
_totalCellLength = 0;
_totalCellsMeasured = 0;
@@ -1675,18 +1683,18 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
onStartReached != null &&
this.state.cellsAroundViewport.first === 0 &&
isWithinStartThreshold &&
- this._scrollMetrics.contentLength !== this._sentStartForContentLength
+ this.state.firstVisibleItemKey !== this._sentStartForFirstVisibleItemKey
) {
- this._sentStartForContentLength = this._scrollMetrics.contentLength;
+ this._sentStartForFirstVisibleItemKey = this.state.firstVisibleItemKey;
onStartReached({distanceFromStart});
}
// If the user scrolls away from the start or end and back again,
// cause onStartReached or onEndReached to be triggered again
else {
- this._sentStartForContentLength = isWithinStartThreshold
- ? this._sentStartForContentLength
- : 0;
+ this._sentStartForFirstVisibleItemKey = isWithinStartThreshold
+ ? this._sentStartForFirstVisibleItemKey
+ : null;
this._sentEndForContentLength = isWithinEndThreshold
? this._sentEndForContentLength
: 0;