@legendapp/list 0.5.9 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -6
- package/animated.d.mts +9 -0
- package/animated.d.ts +9 -0
- package/animated.js +9 -0
- package/animated.mjs +7 -0
- package/index.d.mts +27 -4
- package/index.d.ts +27 -4
- package/index.js +316 -191
- package/index.mjs +299 -174
- package/package.json +1 -1
- package/reanimated.d.mts +13 -0
- package/reanimated.d.ts +13 -0
- package/reanimated.js +47 -0
- package/reanimated.mjs +40 -0
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React4 = require('react');
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
|
|
6
6
|
function _interopNamespace(e) {
|
|
@@ -21,13 +21,12 @@ function _interopNamespace(e) {
|
|
|
21
21
|
return Object.freeze(n);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var React4__namespace = /*#__PURE__*/_interopNamespace(React4);
|
|
25
25
|
|
|
26
26
|
// src/LegendList.tsx
|
|
27
|
-
var
|
|
28
|
-
var ContextState = React5__namespace.createContext(null);
|
|
27
|
+
var ContextState = React4__namespace.createContext(null);
|
|
29
28
|
function StateProvider({ children }) {
|
|
30
|
-
const [value] =
|
|
29
|
+
const [value] = React4__namespace.useState(() => ({
|
|
31
30
|
listeners: /* @__PURE__ */ new Map(),
|
|
32
31
|
values: /* @__PURE__ */ new Map(),
|
|
33
32
|
mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
|
|
@@ -35,14 +34,14 @@ function StateProvider({ children }) {
|
|
|
35
34
|
mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
|
|
36
35
|
mapViewabilityAmountValues: /* @__PURE__ */ new Map()
|
|
37
36
|
}));
|
|
38
|
-
return /* @__PURE__ */
|
|
37
|
+
return /* @__PURE__ */ React4__namespace.createElement(ContextState.Provider, { value }, children);
|
|
39
38
|
}
|
|
40
39
|
function useStateContext() {
|
|
41
|
-
return
|
|
40
|
+
return React4__namespace.useContext(ContextState);
|
|
42
41
|
}
|
|
43
42
|
function use$(signalName) {
|
|
44
|
-
const ctx =
|
|
45
|
-
const value =
|
|
43
|
+
const ctx = React4__namespace.useContext(ContextState);
|
|
44
|
+
const value = React4.useSyncExternalStore(
|
|
46
45
|
(onStoreChange) => listen$(ctx, signalName, onStoreChange),
|
|
47
46
|
() => ctx.values.get(signalName)
|
|
48
47
|
);
|
|
@@ -74,25 +73,6 @@ function set$(ctx, signalName, value) {
|
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
|
-
|
|
78
|
-
// src/$ScrollView.tsx
|
|
79
|
-
var OFFSET_TEST = 0;
|
|
80
|
-
var $ScrollView = React5__namespace.forwardRef(function $ScrollView2(props, ref) {
|
|
81
|
-
const { style, horizontal, ...rest } = props;
|
|
82
|
-
const scrollAdjust = use$("scrollAdjust");
|
|
83
|
-
const adjustProps = {};
|
|
84
|
-
if (scrollAdjust !== 0) {
|
|
85
|
-
if (USE_CONTENT_INSET) {
|
|
86
|
-
adjustProps.contentInset = horizontal ? { left: -scrollAdjust } : { top: -scrollAdjust + OFFSET_TEST };
|
|
87
|
-
} else {
|
|
88
|
-
adjustProps.style = horizontal ? { marginLeft: -scrollAdjust } : { marginTop: -scrollAdjust };
|
|
89
|
-
if (style) {
|
|
90
|
-
adjustProps.style = reactNative.StyleSheet.compose(style, adjustProps.style);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return /* @__PURE__ */ React5__namespace.createElement(reactNative.ScrollView, { ...rest, style, horizontal, ...adjustProps, ref });
|
|
95
|
-
});
|
|
96
76
|
var Container = ({
|
|
97
77
|
id,
|
|
98
78
|
recycleItems,
|
|
@@ -108,31 +88,35 @@ var Container = ({
|
|
|
108
88
|
const numColumns = use$("numColumns");
|
|
109
89
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
110
90
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
111
|
-
|
|
91
|
+
let style = horizontal ? {
|
|
112
92
|
flexDirection: "row",
|
|
113
93
|
position: "absolute",
|
|
114
|
-
top:
|
|
94
|
+
top: otherAxisPos,
|
|
115
95
|
bottom: numColumns > 1 ? null : 0,
|
|
116
96
|
height: otherAxisSize,
|
|
117
97
|
left: position
|
|
118
98
|
} : {
|
|
119
99
|
position: "absolute",
|
|
120
|
-
left:
|
|
100
|
+
left: otherAxisPos,
|
|
121
101
|
right: numColumns > 1 ? null : 0,
|
|
122
102
|
width: otherAxisSize,
|
|
123
103
|
top: position
|
|
124
104
|
};
|
|
105
|
+
{
|
|
106
|
+
style.opacity = visible ? 1 : 0;
|
|
107
|
+
}
|
|
125
108
|
const lastItemKey = use$("lastItemKey");
|
|
126
109
|
const itemKey = use$(`containerItemKey${id}`);
|
|
127
|
-
const
|
|
128
|
-
|
|
110
|
+
const data = use$(`containerItemData${id}`);
|
|
111
|
+
const renderedItem = React4.useMemo(() => itemKey !== void 0 && getRenderedItem(itemKey, id), [itemKey, data]);
|
|
112
|
+
return /* @__PURE__ */ React4__namespace.default.createElement(
|
|
129
113
|
reactNative.View,
|
|
130
114
|
{
|
|
131
115
|
style,
|
|
132
116
|
onLayout: (event) => {
|
|
133
117
|
const key = peek$(ctx, `containerItemKey${id}`);
|
|
134
118
|
if (key !== void 0) {
|
|
135
|
-
const size = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
119
|
+
const size = Math.floor(event.nativeEvent.layout[horizontal ? "width" : "height"] * 8) / 8;
|
|
136
120
|
updateItemSize(id, key, size);
|
|
137
121
|
const otherAxisSize2 = horizontal ? event.nativeEvent.layout.width : event.nativeEvent.layout.height;
|
|
138
122
|
set$(ctx, "otherAxisSize", Math.max(otherAxisSize2, peek$(ctx, "otherAxisSize") || 0));
|
|
@@ -145,37 +129,36 @@ var Container = ({
|
|
|
145
129
|
}
|
|
146
130
|
}
|
|
147
131
|
},
|
|
148
|
-
/* @__PURE__ */
|
|
132
|
+
/* @__PURE__ */ React4__namespace.default.createElement(React4__namespace.default.Fragment, { key: recycleItems ? void 0 : itemKey }, renderedItem, renderedItem && ItemSeparatorComponent && itemKey !== lastItemKey && ItemSeparatorComponent)
|
|
149
133
|
);
|
|
150
134
|
};
|
|
151
135
|
var useAnimatedValue = reactNative.useAnimatedValue || ((initialValue) => {
|
|
152
|
-
return
|
|
136
|
+
return React4.useRef(new reactNative.Animated.Value(initialValue)).current;
|
|
153
137
|
});
|
|
154
138
|
function useValue$(key, getValue, key2) {
|
|
155
139
|
var _a;
|
|
156
140
|
const ctx = useStateContext();
|
|
157
|
-
const animValue = useAnimatedValue((_a =
|
|
158
|
-
|
|
159
|
-
listen$(ctx, key, (v) => animValue.setValue(
|
|
141
|
+
const animValue = useAnimatedValue((_a = peek$(ctx, key)) != null ? _a : 0);
|
|
142
|
+
React4.useMemo(() => {
|
|
143
|
+
listen$(ctx, key, (v) => animValue.setValue(v));
|
|
160
144
|
}, []);
|
|
161
145
|
return animValue;
|
|
162
146
|
}
|
|
163
147
|
|
|
164
148
|
// src/Containers.tsx
|
|
165
|
-
var Containers =
|
|
149
|
+
var Containers = React4__namespace.memo(function Containers2({
|
|
166
150
|
horizontal,
|
|
167
151
|
recycleItems,
|
|
168
152
|
ItemSeparatorComponent,
|
|
169
153
|
updateItemSize,
|
|
170
154
|
getRenderedItem
|
|
171
155
|
}) {
|
|
172
|
-
const ctx = useStateContext();
|
|
173
156
|
const numContainers = use$("numContainersPooled");
|
|
174
|
-
const animSize = useValue$("totalSize"
|
|
157
|
+
const animSize = useValue$("totalSize");
|
|
175
158
|
const containers = [];
|
|
176
159
|
for (let i = 0; i < numContainers; i++) {
|
|
177
160
|
containers.push(
|
|
178
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ React4__namespace.createElement(
|
|
179
162
|
Container,
|
|
180
163
|
{
|
|
181
164
|
id: i,
|
|
@@ -190,20 +173,20 @@ var Containers = React5__namespace.memo(function Containers2({
|
|
|
190
173
|
);
|
|
191
174
|
}
|
|
192
175
|
const style = horizontal ? { width: animSize } : { height: animSize };
|
|
193
|
-
return /* @__PURE__ */
|
|
176
|
+
return /* @__PURE__ */ React4__namespace.createElement(reactNative.Animated.View, { style }, containers);
|
|
194
177
|
});
|
|
195
178
|
|
|
196
179
|
// src/ListComponent.tsx
|
|
197
180
|
var getComponent = (Component) => {
|
|
198
|
-
if (
|
|
181
|
+
if (React4__namespace.isValidElement(Component)) {
|
|
199
182
|
return Component;
|
|
200
183
|
}
|
|
201
184
|
if (Component) {
|
|
202
|
-
return /* @__PURE__ */
|
|
185
|
+
return /* @__PURE__ */ React4__namespace.createElement(Component, null);
|
|
203
186
|
}
|
|
204
187
|
return null;
|
|
205
188
|
};
|
|
206
|
-
var ListComponent =
|
|
189
|
+
var ListComponent = React4__namespace.memo(function ListComponent2({
|
|
207
190
|
style,
|
|
208
191
|
contentContainerStyle,
|
|
209
192
|
horizontal,
|
|
@@ -221,18 +204,20 @@ var ListComponent = React5__namespace.memo(function ListComponent2({
|
|
|
221
204
|
ListEmptyComponentStyle,
|
|
222
205
|
getRenderedItem,
|
|
223
206
|
updateItemSize,
|
|
224
|
-
|
|
225
|
-
|
|
207
|
+
refScrollView,
|
|
208
|
+
maintainVisibleContentPosition,
|
|
226
209
|
...rest
|
|
227
210
|
}) {
|
|
228
211
|
const ctx = useStateContext();
|
|
229
212
|
const animPaddingTop = useValue$("paddingTop");
|
|
230
213
|
const animScrollAdjust = useValue$("scrollAdjust");
|
|
231
|
-
|
|
232
|
-
|
|
214
|
+
const additionalSize = { marginTop: animScrollAdjust, paddingTop: animPaddingTop };
|
|
215
|
+
return /* @__PURE__ */ React4__namespace.createElement(
|
|
216
|
+
reactNative.ScrollView,
|
|
233
217
|
{
|
|
234
218
|
...rest,
|
|
235
219
|
style,
|
|
220
|
+
maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
|
|
236
221
|
contentContainerStyle: [
|
|
237
222
|
contentContainerStyle,
|
|
238
223
|
horizontal ? {
|
|
@@ -243,15 +228,13 @@ var ListComponent = React5__namespace.memo(function ListComponent2({
|
|
|
243
228
|
onLayout,
|
|
244
229
|
horizontal,
|
|
245
230
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
246
|
-
ref:
|
|
231
|
+
ref: refScrollView
|
|
247
232
|
},
|
|
248
|
-
|
|
249
|
-
ListHeaderComponent && /* @__PURE__ */
|
|
233
|
+
/* @__PURE__ */ React4__namespace.createElement(reactNative.Animated.View, { style: additionalSize }),
|
|
234
|
+
ListHeaderComponent && /* @__PURE__ */ React4__namespace.createElement(
|
|
250
235
|
reactNative.Animated.View,
|
|
251
236
|
{
|
|
252
|
-
style:
|
|
253
|
-
top: animScrollAdjust
|
|
254
|
-
}),
|
|
237
|
+
style: ListHeaderComponentStyle,
|
|
255
238
|
onLayout: (event) => {
|
|
256
239
|
const size = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
257
240
|
const prevSize = peek$(ctx, "headerSize") || 0;
|
|
@@ -262,16 +245,8 @@ var ListComponent = React5__namespace.memo(function ListComponent2({
|
|
|
262
245
|
},
|
|
263
246
|
getComponent(ListHeaderComponent)
|
|
264
247
|
),
|
|
265
|
-
ListEmptyComponent && /* @__PURE__ */
|
|
266
|
-
|
|
267
|
-
{
|
|
268
|
-
style: reactNative.StyleSheet.compose(ListEmptyComponentStyle, {
|
|
269
|
-
top: animScrollAdjust
|
|
270
|
-
})
|
|
271
|
-
},
|
|
272
|
-
getComponent(ListEmptyComponent)
|
|
273
|
-
),
|
|
274
|
-
/* @__PURE__ */ React5__namespace.createElement(
|
|
248
|
+
ListEmptyComponent && /* @__PURE__ */ React4__namespace.createElement(reactNative.Animated.View, { style: ListEmptyComponentStyle }, getComponent(ListEmptyComponent)),
|
|
249
|
+
/* @__PURE__ */ React4__namespace.createElement(
|
|
275
250
|
Containers,
|
|
276
251
|
{
|
|
277
252
|
horizontal,
|
|
@@ -281,12 +256,49 @@ var ListComponent = React5__namespace.memo(function ListComponent2({
|
|
|
281
256
|
updateItemSize
|
|
282
257
|
}
|
|
283
258
|
),
|
|
284
|
-
ListFooterComponent && /* @__PURE__ */
|
|
259
|
+
ListFooterComponent && /* @__PURE__ */ React4__namespace.createElement(reactNative.View, { style: ListFooterComponentStyle }, getComponent(ListFooterComponent))
|
|
285
260
|
);
|
|
286
261
|
});
|
|
262
|
+
|
|
263
|
+
// src/ScrollAdjustHandler.ts
|
|
264
|
+
var ScrollAdjustHandler = class {
|
|
265
|
+
constructor(ctx) {
|
|
266
|
+
this.ctx = ctx;
|
|
267
|
+
this.appliedAdjust = 0;
|
|
268
|
+
this.pendingAdjust = 0;
|
|
269
|
+
this.busy = false;
|
|
270
|
+
this.firstAdjust = true;
|
|
271
|
+
this.context = ctx;
|
|
272
|
+
}
|
|
273
|
+
requestAdjust(adjust, onAdjusted) {
|
|
274
|
+
const oldAdjustTop = peek$(this.context, "scrollAdjust");
|
|
275
|
+
if (oldAdjustTop === adjust) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
this.appliedAdjust = adjust;
|
|
279
|
+
this.pendingAdjust = adjust;
|
|
280
|
+
const doAjdust = () => {
|
|
281
|
+
set$(this.context, "scrollAdjust", this.pendingAdjust);
|
|
282
|
+
onAdjusted(oldAdjustTop - this.pendingAdjust);
|
|
283
|
+
this.busy = false;
|
|
284
|
+
};
|
|
285
|
+
if (!this.busy) {
|
|
286
|
+
this.busy = true;
|
|
287
|
+
if (this.firstAdjust) {
|
|
288
|
+
this.firstAdjust = false;
|
|
289
|
+
setTimeout(doAjdust, 50);
|
|
290
|
+
} else {
|
|
291
|
+
doAjdust();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
getAppliedAdjust() {
|
|
296
|
+
return this.appliedAdjust;
|
|
297
|
+
}
|
|
298
|
+
};
|
|
287
299
|
var symbolFirst = Symbol();
|
|
288
300
|
function useInit(cb) {
|
|
289
|
-
const refValue =
|
|
301
|
+
const refValue = React4.useRef(symbolFirst);
|
|
290
302
|
if (refValue.current === symbolFirst) {
|
|
291
303
|
refValue.current = cb();
|
|
292
304
|
}
|
|
@@ -442,14 +454,13 @@ function maybeUpdateViewabilityCallback(ctx, configId, viewToken) {
|
|
|
442
454
|
|
|
443
455
|
// src/LegendList.tsx
|
|
444
456
|
var DEFAULT_DRAW_DISTANCE = 250;
|
|
445
|
-
var INITIAL_SCROLL_ADJUST = 1e4;
|
|
446
457
|
var POSITION_OUT_OF_VIEW = -1e7;
|
|
447
458
|
var DEFAULT_ITEM_SIZE = 100;
|
|
448
|
-
var LegendList =
|
|
449
|
-
return /* @__PURE__ */
|
|
459
|
+
var LegendList = React4.forwardRef(function LegendList2(props, forwardedRef) {
|
|
460
|
+
return /* @__PURE__ */ React4__namespace.createElement(StateProvider, null, /* @__PURE__ */ React4__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
450
461
|
});
|
|
451
|
-
var LegendListInner =
|
|
452
|
-
var _a, _b, _c, _d, _e
|
|
462
|
+
var LegendListInner = React4.forwardRef(function LegendListInner2(props, forwardedRef) {
|
|
463
|
+
var _a, _b, _c, _d, _e;
|
|
453
464
|
const {
|
|
454
465
|
data,
|
|
455
466
|
initialScrollIndex,
|
|
@@ -473,15 +484,15 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
473
484
|
onEndReached,
|
|
474
485
|
onStartReached,
|
|
475
486
|
ListEmptyComponent,
|
|
487
|
+
refScrollView,
|
|
476
488
|
...rest
|
|
477
489
|
} = props;
|
|
478
490
|
const { style, contentContainerStyle } = props;
|
|
479
491
|
const ctx = useStateContext();
|
|
480
|
-
const
|
|
481
|
-
const refScroller = internalRef;
|
|
492
|
+
const refScroller = React4.useRef(null);
|
|
482
493
|
const scrollBuffer = drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE;
|
|
483
494
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
|
|
484
|
-
const refState =
|
|
495
|
+
const refState = React4.useRef();
|
|
485
496
|
const getId = (index) => {
|
|
486
497
|
var _a2;
|
|
487
498
|
const data2 = (_a2 = refState.current) == null ? void 0 : _a2.data;
|
|
@@ -511,37 +522,38 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
511
522
|
} else if (estimatedItemSize) {
|
|
512
523
|
offset = index * estimatedItemSize;
|
|
513
524
|
}
|
|
514
|
-
return offset
|
|
525
|
+
return offset / numColumnsProp;
|
|
515
526
|
}
|
|
516
|
-
return
|
|
527
|
+
return 0;
|
|
517
528
|
};
|
|
518
|
-
const initialContentOffset = initialScrollOffset != null ? initialScrollOffset :
|
|
529
|
+
const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : React4.useMemo(calculateInitialOffset, []);
|
|
519
530
|
if (!refState.current) {
|
|
531
|
+
const initialScrollLength = reactNative.Dimensions.get("window")[horizontal ? "width" : "height"];
|
|
520
532
|
refState.current = {
|
|
521
533
|
sizes: /* @__PURE__ */ new Map(),
|
|
522
534
|
positions: /* @__PURE__ */ new Map(),
|
|
523
535
|
columns: /* @__PURE__ */ new Map(),
|
|
524
536
|
pendingAdjust: 0,
|
|
525
537
|
animFrameLayout: null,
|
|
526
|
-
|
|
527
|
-
isStartReached: true,
|
|
538
|
+
isStartReached: initialContentOffset < initialScrollLength * onStartReachedThreshold,
|
|
528
539
|
isEndReached: false,
|
|
529
540
|
isAtBottom: false,
|
|
530
541
|
isAtTop: false,
|
|
531
542
|
data,
|
|
532
543
|
idsInFirstRender: void 0,
|
|
533
544
|
hasScrolled: false,
|
|
534
|
-
scrollLength:
|
|
545
|
+
scrollLength: initialScrollLength,
|
|
535
546
|
startBuffered: 0,
|
|
536
547
|
startNoBuffer: 0,
|
|
537
548
|
endBuffered: 0,
|
|
538
549
|
endNoBuffer: 0,
|
|
539
550
|
scroll: initialContentOffset || 0,
|
|
540
551
|
totalSize: 0,
|
|
552
|
+
totalSizeBelowAnchor: 0,
|
|
541
553
|
timeouts: /* @__PURE__ */ new Set(),
|
|
542
554
|
viewabilityConfigCallbackPairs: void 0,
|
|
543
555
|
renderItem: void 0,
|
|
544
|
-
|
|
556
|
+
scrollAdjustHandler: new ScrollAdjustHandler(ctx),
|
|
545
557
|
nativeMarginTop: 0,
|
|
546
558
|
scrollPrev: 0,
|
|
547
559
|
scrollPrevTime: 0,
|
|
@@ -552,54 +564,141 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
552
564
|
contentSize: { width: 0, height: 0 },
|
|
553
565
|
sizesLaidOut: __DEV__ ? /* @__PURE__ */ new Map() : void 0,
|
|
554
566
|
timeoutSizeMessage: 0,
|
|
555
|
-
scrollTimer: void 0
|
|
567
|
+
scrollTimer: void 0,
|
|
568
|
+
belowAnchorElementPositions: void 0,
|
|
569
|
+
rowHeights: /* @__PURE__ */ new Map(),
|
|
570
|
+
startReachedBlockedByTimer: false
|
|
556
571
|
};
|
|
557
572
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
558
|
-
|
|
573
|
+
if (maintainVisibleContentPosition) {
|
|
574
|
+
if (initialScrollIndex) {
|
|
575
|
+
refState.current.anchorElement = {
|
|
576
|
+
coordinate: initialContentOffset,
|
|
577
|
+
id: getId(initialScrollIndex)
|
|
578
|
+
};
|
|
579
|
+
} else if (data.length) {
|
|
580
|
+
refState.current.anchorElement = {
|
|
581
|
+
coordinate: initialContentOffset,
|
|
582
|
+
id: getId(0)
|
|
583
|
+
};
|
|
584
|
+
} else {
|
|
585
|
+
console.warn("[legend-list] maintainVisibleContentPosition was not able to find an anchor element");
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
set$(ctx, "scrollAdjust", 0);
|
|
559
589
|
}
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
|
|
590
|
+
const getAnchorElementIndex = () => {
|
|
591
|
+
const state = refState.current;
|
|
592
|
+
if (state.anchorElement) {
|
|
593
|
+
const el = state.indexByKey.get(state.anchorElement.id);
|
|
594
|
+
return el;
|
|
563
595
|
}
|
|
596
|
+
return void 0;
|
|
564
597
|
};
|
|
565
|
-
const addTotalSize =
|
|
598
|
+
const addTotalSize = React4.useCallback((key, add, totalSizeBelowAnchor) => {
|
|
566
599
|
const state = refState.current;
|
|
567
600
|
const index = key === null ? 0 : state.indexByKey.get(key);
|
|
568
|
-
|
|
569
|
-
|
|
601
|
+
let isAboveAnchor = false;
|
|
602
|
+
if (maintainVisibleContentPosition) {
|
|
603
|
+
if (state.anchorElement && index < getAnchorElementIndex()) {
|
|
604
|
+
isAboveAnchor = true;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
state.totalSize;
|
|
570
608
|
if (key === null) {
|
|
571
609
|
state.totalSize = add;
|
|
610
|
+
state.totalSizeBelowAnchor = totalSizeBelowAnchor;
|
|
572
611
|
} else {
|
|
573
612
|
state.totalSize += add;
|
|
613
|
+
if (isAboveAnchor) {
|
|
614
|
+
state.totalSizeBelowAnchor += add;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
let applyAdjustValue = void 0;
|
|
618
|
+
if (maintainVisibleContentPosition) {
|
|
619
|
+
const newAdjust = state.anchorElement.coordinate - state.totalSizeBelowAnchor;
|
|
620
|
+
applyAdjustValue = -newAdjust;
|
|
621
|
+
state.belowAnchorElementPositions = buildElementPositionsBelowAnchor();
|
|
622
|
+
state.rowHeights.clear();
|
|
574
623
|
}
|
|
575
624
|
const doAdd = () => {
|
|
576
625
|
const totalSize = state.totalSize;
|
|
577
|
-
|
|
578
|
-
|
|
626
|
+
let resultSize = totalSize;
|
|
627
|
+
if (applyAdjustValue !== void 0) {
|
|
628
|
+
resultSize -= applyAdjustValue;
|
|
629
|
+
refState.current.scrollAdjustHandler.requestAdjust(applyAdjustValue, (diff) => {
|
|
630
|
+
state.scroll -= diff;
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
set$(ctx, "totalSize", resultSize);
|
|
579
634
|
if (alignItemsAtEnd) {
|
|
580
635
|
doUpdatePaddingTop();
|
|
581
636
|
}
|
|
582
637
|
};
|
|
583
|
-
|
|
584
|
-
|
|
638
|
+
doAdd();
|
|
639
|
+
}, []);
|
|
640
|
+
const getRowHeight = (n) => {
|
|
641
|
+
const { rowHeights } = refState.current;
|
|
642
|
+
if (numColumnsProp === 1) {
|
|
643
|
+
const id = getId(n);
|
|
644
|
+
return getItemSize(id, n, data[n]);
|
|
585
645
|
}
|
|
586
|
-
if (
|
|
587
|
-
|
|
588
|
-
} else if (!state.animFrameTotalSize) {
|
|
589
|
-
state.animFrameTotalSize = requestAnimationFrame(doAdd);
|
|
646
|
+
if (rowHeights.has(n)) {
|
|
647
|
+
return rowHeights.get(n) || 0;
|
|
590
648
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
649
|
+
let rowHeight = 0;
|
|
650
|
+
const startEl = n * numColumnsProp;
|
|
651
|
+
for (let i = startEl; i < startEl + numColumnsProp; i++) {
|
|
652
|
+
const id = getId(i);
|
|
653
|
+
const size = getItemSize(id, i, data[i]);
|
|
654
|
+
rowHeight = Math.max(rowHeight, size);
|
|
655
|
+
}
|
|
656
|
+
rowHeights.set(n, rowHeight);
|
|
657
|
+
return rowHeight;
|
|
658
|
+
};
|
|
659
|
+
const buildElementPositionsBelowAnchor = () => {
|
|
660
|
+
const state = refState.current;
|
|
661
|
+
if (!state.anchorElement) {
|
|
662
|
+
return /* @__PURE__ */ new Map();
|
|
663
|
+
}
|
|
664
|
+
let top = state.anchorElement.coordinate;
|
|
665
|
+
const anchorIndex = state.indexByKey.get(state.anchorElement.id);
|
|
666
|
+
if (anchorIndex === 0) {
|
|
667
|
+
return /* @__PURE__ */ new Map();
|
|
668
|
+
}
|
|
669
|
+
const map = state.belowAnchorElementPositions || /* @__PURE__ */ new Map();
|
|
670
|
+
for (let i = anchorIndex - 1; i >= 0; i--) {
|
|
671
|
+
const id = getId(i);
|
|
672
|
+
const rowNumber = Math.floor(i / numColumnsProp);
|
|
673
|
+
if (i % numColumnsProp === 0) {
|
|
674
|
+
top -= getRowHeight(rowNumber);
|
|
675
|
+
}
|
|
676
|
+
map.set(id, top);
|
|
677
|
+
}
|
|
678
|
+
return map;
|
|
679
|
+
};
|
|
680
|
+
const getElementPositionBelowAchor = (id) => {
|
|
681
|
+
const state = refState.current;
|
|
682
|
+
if (!refState.current.belowAnchorElementPositions) {
|
|
683
|
+
state.belowAnchorElementPositions = buildElementPositionsBelowAnchor();
|
|
684
|
+
}
|
|
685
|
+
const res = state.belowAnchorElementPositions.get(id);
|
|
686
|
+
if (res === void 0) {
|
|
687
|
+
throw new Error("Undefined position below achor");
|
|
688
|
+
}
|
|
689
|
+
return res;
|
|
690
|
+
};
|
|
691
|
+
const calculateItemsInView = React4.useCallback((speed) => {
|
|
692
|
+
var _a2, _b2, _c2, _d2;
|
|
594
693
|
const state = refState.current;
|
|
595
694
|
const {
|
|
596
695
|
data: data2,
|
|
597
696
|
scrollLength,
|
|
598
697
|
scroll: scrollState,
|
|
599
|
-
|
|
698
|
+
startBufferedId: startBufferedIdOrig,
|
|
600
699
|
positions,
|
|
601
|
-
|
|
602
|
-
|
|
700
|
+
columns,
|
|
701
|
+
scrollAdjustHandler
|
|
603
702
|
} = state;
|
|
604
703
|
if (state.animFrameLayout) {
|
|
605
704
|
cancelAnimationFrame(state.animFrameLayout);
|
|
@@ -609,30 +708,35 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
609
708
|
return;
|
|
610
709
|
}
|
|
611
710
|
const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
|
|
612
|
-
const
|
|
711
|
+
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
613
712
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
614
|
-
const scroll =
|
|
615
|
-
0,
|
|
616
|
-
scrollState - topPad - (USE_CONTENT_INSET ? scrollAdjustPending : 0) + scrollExtra
|
|
617
|
-
);
|
|
713
|
+
const scroll = scrollState - previousScrollAdjust - topPad - scrollExtra;
|
|
618
714
|
const scrollBottom = scroll + scrollLength;
|
|
619
715
|
let startNoBuffer = null;
|
|
620
716
|
let startBuffered = null;
|
|
717
|
+
let startBufferedId = null;
|
|
621
718
|
let endNoBuffer = null;
|
|
622
719
|
let endBuffered = null;
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
720
|
+
const originalStartId = startBufferedIdOrig && state.indexByKey.get(startBufferedIdOrig);
|
|
721
|
+
let loopStart = originalStartId || 0;
|
|
722
|
+
const anchorElementIndex = getAnchorElementIndex();
|
|
723
|
+
for (let i = loopStart; i >= 0; i--) {
|
|
724
|
+
const id = getId(i);
|
|
725
|
+
let newPosition;
|
|
726
|
+
if (maintainVisibleContentPosition && anchorElementIndex && i < anchorElementIndex) {
|
|
727
|
+
newPosition = getElementPositionBelowAchor(id);
|
|
728
|
+
if (newPosition !== void 0) {
|
|
729
|
+
positions.set(id, newPosition);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
const top2 = newPosition || positions.get(id);
|
|
733
|
+
if (top2 !== void 0) {
|
|
734
|
+
const size = getItemSize(id, i, data2[i]);
|
|
735
|
+
const bottom = top2 + size;
|
|
736
|
+
if (bottom > scroll - scrollBuffer) {
|
|
737
|
+
loopStart = i;
|
|
738
|
+
} else {
|
|
739
|
+
break;
|
|
636
740
|
}
|
|
637
741
|
}
|
|
638
742
|
}
|
|
@@ -641,13 +745,28 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
641
745
|
if (loopStartMod > 0) {
|
|
642
746
|
loopStart -= loopStartMod;
|
|
643
747
|
}
|
|
644
|
-
let top =
|
|
748
|
+
let top = void 0;
|
|
645
749
|
let column = 1;
|
|
646
750
|
let maxSizeInRow = 0;
|
|
751
|
+
const getInitialTop = (i) => {
|
|
752
|
+
var _a3;
|
|
753
|
+
const id = getId(i);
|
|
754
|
+
let topOffset = 0;
|
|
755
|
+
if (positions.get(id)) {
|
|
756
|
+
topOffset = positions.get(id);
|
|
757
|
+
}
|
|
758
|
+
if (id === ((_a3 = state.anchorElement) == null ? void 0 : _a3.id)) {
|
|
759
|
+
topOffset = initialContentOffset || 0;
|
|
760
|
+
}
|
|
761
|
+
return topOffset;
|
|
762
|
+
};
|
|
647
763
|
for (let i = loopStart; i < data2.length; i++) {
|
|
648
764
|
const id = getId(i);
|
|
649
765
|
const size = getItemSize(id, i, data2[i]);
|
|
650
766
|
maxSizeInRow = Math.max(maxSizeInRow, size);
|
|
767
|
+
if (top === void 0) {
|
|
768
|
+
top = getInitialTop(i);
|
|
769
|
+
}
|
|
651
770
|
if (positions.get(id) !== top) {
|
|
652
771
|
positions.set(id, top);
|
|
653
772
|
}
|
|
@@ -659,6 +778,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
659
778
|
}
|
|
660
779
|
if (startBuffered === null && top + size > scroll - scrollBuffer) {
|
|
661
780
|
startBuffered = i;
|
|
781
|
+
startBufferedId = id;
|
|
662
782
|
}
|
|
663
783
|
if (startNoBuffer !== null) {
|
|
664
784
|
if (top <= scrollBottom) {
|
|
@@ -679,6 +799,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
679
799
|
}
|
|
680
800
|
Object.assign(refState.current, {
|
|
681
801
|
startBuffered,
|
|
802
|
+
startBufferedId,
|
|
682
803
|
startNoBuffer,
|
|
683
804
|
endBuffered,
|
|
684
805
|
endNoBuffer
|
|
@@ -697,7 +818,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
697
818
|
}
|
|
698
819
|
}
|
|
699
820
|
if (!isContained) {
|
|
700
|
-
const top2 =
|
|
821
|
+
const top2 = positions.get(id) || 0;
|
|
701
822
|
let furthestIndex = -1;
|
|
702
823
|
let furthestDistance = 0;
|
|
703
824
|
for (let u = 0; u < numContainers; u++) {
|
|
@@ -706,7 +827,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
706
827
|
furthestIndex = u;
|
|
707
828
|
break;
|
|
708
829
|
}
|
|
709
|
-
const index = (
|
|
830
|
+
const index = (_a2 = refState.current) == null ? void 0 : _a2.indexByKey.get(key);
|
|
710
831
|
const pos = peek$(ctx, `containerPosition${u}`);
|
|
711
832
|
if (index < startBuffered || index > endBuffered) {
|
|
712
833
|
const distance = Math.abs(pos - top2);
|
|
@@ -718,10 +839,14 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
718
839
|
}
|
|
719
840
|
if (furthestIndex >= 0) {
|
|
720
841
|
set$(ctx, `containerItemKey${furthestIndex}`, id);
|
|
842
|
+
const index = (_b2 = refState.current) == null ? void 0 : _b2.indexByKey.get(id);
|
|
843
|
+
set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
|
|
721
844
|
} else {
|
|
722
845
|
const containerId = numContainers;
|
|
723
846
|
numContainers++;
|
|
724
847
|
set$(ctx, `containerItemKey${containerId}`, id);
|
|
848
|
+
const index = (_c2 = refState.current) == null ? void 0 : _c2.indexByKey.get(id);
|
|
849
|
+
set$(ctx, `containerItemData${furthestIndex}`, data2[index]);
|
|
725
850
|
set$(ctx, `containerPosition${containerId}`, POSITION_OUT_OF_VIEW);
|
|
726
851
|
set$(ctx, `containerColumn${containerId}`, -1);
|
|
727
852
|
if (__DEV__ && numContainers > peek$(ctx, "numContainersPooled")) {
|
|
@@ -741,28 +866,32 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
741
866
|
}
|
|
742
867
|
for (let i = 0; i < numContainers; i++) {
|
|
743
868
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
744
|
-
const itemIndex = (
|
|
869
|
+
const itemIndex = (_d2 = refState.current) == null ? void 0 : _d2.indexByKey.get(itemKey);
|
|
745
870
|
const item = data2[itemIndex];
|
|
746
871
|
if (item) {
|
|
747
872
|
const id = getId(itemIndex);
|
|
748
873
|
if (itemKey !== id || itemIndex < startBuffered || itemIndex > endBuffered) {
|
|
749
|
-
const prevPos = peek$(ctx, `containerPosition${i}`)
|
|
874
|
+
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
750
875
|
const pos = positions.get(id) || 0;
|
|
751
|
-
const size =
|
|
876
|
+
const size = getItemSize(id, itemIndex, data2[i]);
|
|
752
877
|
if (pos + size >= scroll && pos <= scrollBottom || prevPos + size >= scroll && prevPos <= scrollBottom) {
|
|
753
878
|
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
754
879
|
}
|
|
755
880
|
} else {
|
|
756
|
-
const pos =
|
|
881
|
+
const pos = positions.get(id) || 0;
|
|
757
882
|
const column2 = columns.get(id) || 1;
|
|
758
883
|
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
759
884
|
const prevColumn = peek$(ctx, `containerColumn${i}`);
|
|
760
|
-
|
|
885
|
+
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
886
|
+
if (pos > POSITION_OUT_OF_VIEW && pos !== prevPos) {
|
|
761
887
|
set$(ctx, `containerPosition${i}`, pos);
|
|
762
888
|
}
|
|
763
889
|
if (column2 >= 0 && column2 !== prevColumn) {
|
|
764
890
|
set$(ctx, `containerColumn${i}`, column2);
|
|
765
891
|
}
|
|
892
|
+
if (prevData !== item) {
|
|
893
|
+
set$(ctx, `containerItemData${i}`, data2[itemIndex]);
|
|
894
|
+
}
|
|
766
895
|
}
|
|
767
896
|
}
|
|
768
897
|
}
|
|
@@ -829,17 +958,20 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
829
958
|
return;
|
|
830
959
|
}
|
|
831
960
|
const { scrollLength, scroll } = refState.current;
|
|
832
|
-
const
|
|
833
|
-
const distanceFromTop = scroll - scrollAdjust;
|
|
961
|
+
const distanceFromTop = scroll;
|
|
834
962
|
refState.current.isAtTop = distanceFromTop < 0;
|
|
835
963
|
if (onStartReached) {
|
|
836
|
-
if (!refState.current.isStartReached) {
|
|
964
|
+
if (!refState.current.isStartReached && !refState.current.startReachedBlockedByTimer) {
|
|
837
965
|
if (distanceFromTop < onStartReachedThreshold * scrollLength) {
|
|
838
966
|
refState.current.isStartReached = true;
|
|
839
967
|
onStartReached({ distanceFromStart: scroll });
|
|
968
|
+
refState.current.startReachedBlockedByTimer = true;
|
|
969
|
+
setTimeout(() => {
|
|
970
|
+
refState.current.startReachedBlockedByTimer = false;
|
|
971
|
+
}, 700);
|
|
840
972
|
}
|
|
841
973
|
} else {
|
|
842
|
-
if (distanceFromTop >= onStartReachedThreshold * scrollLength) {
|
|
974
|
+
if (distanceFromTop >= 1.3 * onStartReachedThreshold * scrollLength) {
|
|
843
975
|
refState.current.isStartReached = false;
|
|
844
976
|
}
|
|
845
977
|
}
|
|
@@ -853,43 +985,36 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
853
985
|
}
|
|
854
986
|
refState.current.data = data;
|
|
855
987
|
let totalSize = 0;
|
|
988
|
+
let totalSizeBelowIndex = 0;
|
|
856
989
|
const indexByKey = /* @__PURE__ */ new Map();
|
|
857
990
|
let column = 1;
|
|
858
991
|
let maxSizeInRow = 0;
|
|
859
992
|
for (let i = 0; i < data.length; i++) {
|
|
860
993
|
const key = getId(i);
|
|
861
994
|
indexByKey.set(key, i);
|
|
995
|
+
}
|
|
996
|
+
refState.current.indexByKey = indexByKey;
|
|
997
|
+
const anchorElementIndex = getAnchorElementIndex();
|
|
998
|
+
for (let i = 0; i < data.length; i++) {
|
|
999
|
+
const key = getId(i);
|
|
862
1000
|
const size = getItemSize(key, i, data[i]);
|
|
863
1001
|
maxSizeInRow = Math.max(maxSizeInRow, size);
|
|
864
|
-
if (maintainVisibleContentPosition && i < refState.current.startNoBuffer && !refState.current.indexByKey.has(key)) {
|
|
865
|
-
const size2 = getItemSize(key, i, data[i]);
|
|
866
|
-
adjustScroll(size2);
|
|
867
|
-
}
|
|
868
1002
|
column++;
|
|
869
1003
|
if (column > numColumnsProp) {
|
|
1004
|
+
if (maintainVisibleContentPosition && anchorElementIndex !== void 0 && i < anchorElementIndex) {
|
|
1005
|
+
totalSizeBelowIndex += maxSizeInRow;
|
|
1006
|
+
}
|
|
870
1007
|
totalSize += maxSizeInRow;
|
|
871
1008
|
column = 1;
|
|
872
1009
|
maxSizeInRow = 0;
|
|
873
1010
|
}
|
|
874
1011
|
}
|
|
875
|
-
addTotalSize(null, totalSize);
|
|
876
|
-
if (maintainVisibleContentPosition) {
|
|
877
|
-
for (const [key, index] of refState.current.indexByKey) {
|
|
878
|
-
if (index < refState.current.startNoBuffer && !indexByKey.has(key)) {
|
|
879
|
-
const size = (_a = refState.current.sizes.get(key)) != null ? _a : 0;
|
|
880
|
-
if (size) {
|
|
881
|
-
adjustScroll(-size);
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
refState.current.indexByKey = indexByKey;
|
|
1012
|
+
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
887
1013
|
if (!isFirst) {
|
|
888
|
-
refState.current.isEndReached = false;
|
|
889
1014
|
const numContainers = peek$(ctx, "numContainers");
|
|
890
1015
|
for (let i = 0; i < numContainers; i++) {
|
|
891
1016
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
892
|
-
if (!keyExtractorProp || itemKey && ((
|
|
1017
|
+
if (!keyExtractorProp || itemKey && ((_a = refState.current) == null ? void 0 : _a.indexByKey.get(itemKey)) === void 0) {
|
|
893
1018
|
set$(ctx, `containerItemKey${i}`, void 0);
|
|
894
1019
|
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
895
1020
|
set$(ctx, `containerColumn${i}`, -1);
|
|
@@ -899,10 +1024,12 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
899
1024
|
refState.current.sizes.clear();
|
|
900
1025
|
refState.current.positions;
|
|
901
1026
|
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1027
|
+
setTimeout(() => {
|
|
1028
|
+
calculateItemsInView(refState.current.scrollVelocity);
|
|
1029
|
+
doMaintainScrollAtEnd(false);
|
|
1030
|
+
checkAtTop();
|
|
1031
|
+
checkAtBottom();
|
|
1032
|
+
}, 0);
|
|
906
1033
|
}
|
|
907
1034
|
}
|
|
908
1035
|
refState.current.renderItem = renderItem;
|
|
@@ -911,9 +1038,9 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
911
1038
|
set$(
|
|
912
1039
|
ctx,
|
|
913
1040
|
"stylePaddingTop",
|
|
914
|
-
(
|
|
1041
|
+
(_e = (_d = (_b = reactNative.StyleSheet.flatten(style)) == null ? void 0 : _b.paddingTop) != null ? _d : (_c = reactNative.StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _c.paddingTop) != null ? _e : 0
|
|
915
1042
|
);
|
|
916
|
-
const getRenderedItem =
|
|
1043
|
+
const getRenderedItem = React4.useCallback((key, containerId) => {
|
|
917
1044
|
var _a2, _b2;
|
|
918
1045
|
const state = refState.current;
|
|
919
1046
|
if (!state) {
|
|
@@ -933,7 +1060,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
933
1060
|
}
|
|
934
1061
|
});
|
|
935
1062
|
ctx.mapViewabilityCallbacks.set(key2, callback);
|
|
936
|
-
|
|
1063
|
+
React4.useEffect(
|
|
937
1064
|
() => () => {
|
|
938
1065
|
ctx.mapViewabilityCallbacks.delete(key2);
|
|
939
1066
|
},
|
|
@@ -948,7 +1075,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
948
1075
|
}
|
|
949
1076
|
});
|
|
950
1077
|
ctx.mapViewabilityAmountCallbacks.set(containerId, callback);
|
|
951
|
-
|
|
1078
|
+
React4.useEffect(
|
|
952
1079
|
() => () => {
|
|
953
1080
|
ctx.mapViewabilityAmountCallbacks.delete(containerId);
|
|
954
1081
|
},
|
|
@@ -956,7 +1083,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
956
1083
|
);
|
|
957
1084
|
};
|
|
958
1085
|
const useRecyclingEffect = (effect) => {
|
|
959
|
-
|
|
1086
|
+
React4.useEffect(() => {
|
|
960
1087
|
const state2 = refState.current;
|
|
961
1088
|
let prevIndex = index;
|
|
962
1089
|
let prevItem = state2.data[index];
|
|
@@ -984,7 +1111,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
984
1111
|
}, []);
|
|
985
1112
|
};
|
|
986
1113
|
const useRecyclingState = (valueOrFun) => {
|
|
987
|
-
const stateInfo =
|
|
1114
|
+
const stateInfo = React4.useState(
|
|
988
1115
|
() => typeof valueOrFun === "function" ? valueOrFun({
|
|
989
1116
|
index,
|
|
990
1117
|
item: refState.current.data[index],
|
|
@@ -1020,9 +1147,9 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1020
1147
|
}
|
|
1021
1148
|
set$(ctx, "numContainers", numContainers);
|
|
1022
1149
|
set$(ctx, "numContainersPooled", numContainers * 2);
|
|
1023
|
-
calculateItemsInView();
|
|
1150
|
+
calculateItemsInView(refState.current.scrollVelocity);
|
|
1024
1151
|
});
|
|
1025
|
-
const updateItemSize =
|
|
1152
|
+
const updateItemSize = React4.useCallback((containerId, itemKey, size) => {
|
|
1026
1153
|
var _a2;
|
|
1027
1154
|
const data2 = (_a2 = refState.current) == null ? void 0 : _a2.data;
|
|
1028
1155
|
if (!data2) {
|
|
@@ -1031,21 +1158,16 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1031
1158
|
const state = refState.current;
|
|
1032
1159
|
const { sizes, indexByKey, idsInFirstRender, columns, sizesLaidOut } = state;
|
|
1033
1160
|
const index = indexByKey.get(itemKey);
|
|
1034
|
-
const
|
|
1035
|
-
const
|
|
1161
|
+
const numColumns = peek$(ctx, "numColumns");
|
|
1162
|
+
const row = Math.floor(index / numColumns);
|
|
1163
|
+
const prevSize = getRowHeight(row);
|
|
1036
1164
|
if (!prevSize || Math.abs(prevSize - size) > 0.5) {
|
|
1037
1165
|
let diff;
|
|
1038
|
-
const numColumns = peek$(ctx, "numColumns");
|
|
1039
1166
|
if (numColumns > 1) {
|
|
1167
|
+
const prevMaxSizeInRow = getRowHeight(row);
|
|
1168
|
+
sizes.set(itemKey, size);
|
|
1040
1169
|
const column = columns.get(itemKey);
|
|
1041
1170
|
const loopStart = index - (column - 1);
|
|
1042
|
-
let prevMaxSizeInRow = 0;
|
|
1043
|
-
for (let i = loopStart; i < loopStart + numColumns; i++) {
|
|
1044
|
-
const id = getId(i);
|
|
1045
|
-
const size2 = getItemSize(id, i, data2[i]);
|
|
1046
|
-
prevMaxSizeInRow = Math.max(prevMaxSizeInRow, size2);
|
|
1047
|
-
}
|
|
1048
|
-
sizes.set(itemKey, size);
|
|
1049
1171
|
let nextMaxSizeInRow = 0;
|
|
1050
1172
|
for (let i = loopStart; i < loopStart + numColumns; i++) {
|
|
1051
1173
|
const id = getId(i);
|
|
@@ -1076,7 +1198,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1076
1198
|
);
|
|
1077
1199
|
}, 1e3);
|
|
1078
1200
|
}
|
|
1079
|
-
addTotalSize(itemKey, diff);
|
|
1201
|
+
addTotalSize(itemKey, diff, 0);
|
|
1080
1202
|
doMaintainScrollAtEnd(true);
|
|
1081
1203
|
const scrollVelocity = state.scrollVelocity;
|
|
1082
1204
|
if (!state.animFrameLayout && (Number.isNaN(scrollVelocity) || Math.abs(scrollVelocity) < 1)) {
|
|
@@ -1091,19 +1213,13 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1091
1213
|
}
|
|
1092
1214
|
}
|
|
1093
1215
|
}, []);
|
|
1094
|
-
const handleScrollDebounced =
|
|
1095
|
-
var _a2, _b2;
|
|
1096
|
-
const scrollAdjustPending = (_b2 = (_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustPending) != null ? _b2 : 0;
|
|
1097
|
-
set$(ctx, "scrollAdjust", scrollAdjustPending);
|
|
1216
|
+
const handleScrollDebounced = React4.useCallback((velocity) => {
|
|
1098
1217
|
calculateItemsInView(velocity);
|
|
1099
1218
|
checkAtBottom();
|
|
1100
1219
|
checkAtTop();
|
|
1101
1220
|
}, []);
|
|
1102
|
-
const onLayout =
|
|
1103
|
-
|
|
1104
|
-
if (!USE_CONTENT_INSET) {
|
|
1105
|
-
scrollLength += event.nativeEvent.layout[horizontal ? "x" : "y"];
|
|
1106
|
-
}
|
|
1221
|
+
const onLayout = React4.useCallback((event) => {
|
|
1222
|
+
const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
1107
1223
|
refState.current.scrollLength = scrollLength;
|
|
1108
1224
|
if (refState.current.hasScrolled) {
|
|
1109
1225
|
doMaintainScrollAtEnd(false);
|
|
@@ -1121,7 +1237,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1121
1237
|
}
|
|
1122
1238
|
}
|
|
1123
1239
|
}, []);
|
|
1124
|
-
const handleScroll =
|
|
1240
|
+
const handleScroll = React4.useCallback(
|
|
1125
1241
|
(event, fromSelf) => {
|
|
1126
1242
|
var _a2, _b2, _c2;
|
|
1127
1243
|
if (((_b2 = (_a2 = event.nativeEvent) == null ? void 0 : _a2.contentSize) == null ? void 0 : _b2.height) === 0 && ((_c2 = event.nativeEvent.contentSize) == null ? void 0 : _c2.width) === 0) {
|
|
@@ -1164,7 +1280,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1164
1280
|
},
|
|
1165
1281
|
[]
|
|
1166
1282
|
);
|
|
1167
|
-
|
|
1283
|
+
React4.useImperativeHandle(
|
|
1168
1284
|
forwardedRef,
|
|
1169
1285
|
() => {
|
|
1170
1286
|
const scrollToIndex = ({ index, animated }) => {
|
|
@@ -1193,12 +1309,21 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1193
1309
|
},
|
|
1194
1310
|
[]
|
|
1195
1311
|
);
|
|
1196
|
-
return /* @__PURE__ */
|
|
1312
|
+
return /* @__PURE__ */ React4__namespace.createElement(
|
|
1197
1313
|
ListComponent,
|
|
1198
1314
|
{
|
|
1199
1315
|
...rest,
|
|
1200
1316
|
horizontal,
|
|
1201
|
-
|
|
1317
|
+
refScrollView: (r) => {
|
|
1318
|
+
refScroller.current = r;
|
|
1319
|
+
if (refScrollView) {
|
|
1320
|
+
if (typeof refScrollView === "function") {
|
|
1321
|
+
refScrollView(r);
|
|
1322
|
+
} else {
|
|
1323
|
+
refScrollView.current = r;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
},
|
|
1202
1327
|
initialContentOffset,
|
|
1203
1328
|
getRenderedItem,
|
|
1204
1329
|
updateItemSize,
|
|
@@ -1206,8 +1331,8 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1206
1331
|
onLayout,
|
|
1207
1332
|
recycleItems,
|
|
1208
1333
|
alignItemsAtEnd,
|
|
1209
|
-
addTotalSize,
|
|
1210
1334
|
ListEmptyComponent: data.length === 0 ? ListEmptyComponent : void 0,
|
|
1335
|
+
maintainVisibleContentPosition,
|
|
1211
1336
|
style
|
|
1212
1337
|
}
|
|
1213
1338
|
);
|