@legendapp/list 0.3.4 → 0.3.5
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/index.js +20 -9
- package/index.mjs +20 -9
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -107,7 +107,7 @@ var Container = ({
|
|
|
107
107
|
onLayout: (event) => {
|
|
108
108
|
const index = peek$(ctx, `containerIndex${id}`);
|
|
109
109
|
if (index >= 0) {
|
|
110
|
-
const length =
|
|
110
|
+
const length = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
111
111
|
onLayout(index, length);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -307,6 +307,7 @@ var LegendListInner = React6.forwardRef(
|
|
|
307
307
|
pendingAdjust: 0,
|
|
308
308
|
animFrameScroll: null,
|
|
309
309
|
animFrameLayout: null,
|
|
310
|
+
animFrameTotalSize: null,
|
|
310
311
|
isStartReached: false,
|
|
311
312
|
isEndReached: false,
|
|
312
313
|
isAtBottom: false,
|
|
@@ -318,7 +319,8 @@ var LegendListInner = React6.forwardRef(
|
|
|
318
319
|
startNoBuffer: 0,
|
|
319
320
|
endBuffered: 0,
|
|
320
321
|
endNoBuffer: 0,
|
|
321
|
-
scroll: initialContentOffset || 0
|
|
322
|
+
scroll: initialContentOffset || 0,
|
|
323
|
+
totalSize: 0
|
|
322
324
|
};
|
|
323
325
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
324
326
|
}
|
|
@@ -326,12 +328,21 @@ var LegendListInner = React6.forwardRef(
|
|
|
326
328
|
set$(ctx, `numItems`, data.length);
|
|
327
329
|
set$(ctx, `stylePaddingTop`, (_b = (_a = styleFlattened == null ? void 0 : styleFlattened.paddingTop) != null ? _a : contentContainerStyleFlattened == null ? void 0 : contentContainerStyleFlattened.paddingTop) != null ? _b : 0);
|
|
328
330
|
const addTotalSize = (add) => {
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
331
|
+
const prev = refState.current.totalSize;
|
|
332
|
+
const length = refState.current.totalSize += add;
|
|
333
|
+
const doAdd = () => {
|
|
334
|
+
refState.current.animFrameTotalSize = null;
|
|
335
|
+
set$(ctx, `totalLength`, length);
|
|
336
|
+
const screenLength = refState.current.scrollLength;
|
|
337
|
+
if (alignItemsAtEnd) {
|
|
338
|
+
const listPaddingTop = peek$(ctx, `stylePaddingTop`);
|
|
339
|
+
set$(ctx, `paddingTop`, Math.max(0, screenLength - length - listPaddingTop));
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
if (!prev) {
|
|
343
|
+
doAdd();
|
|
344
|
+
} else if (!refState.current.animFrameTotalSize) {
|
|
345
|
+
refState.current.animFrameTotalSize = requestAnimationFrame(doAdd);
|
|
335
346
|
}
|
|
336
347
|
};
|
|
337
348
|
const allocateContainers = React6.useCallback(() => {
|
|
@@ -543,7 +554,7 @@ var LegendListInner = React6.forwardRef(
|
|
|
543
554
|
const id = getId(index);
|
|
544
555
|
const wasInFirstRender = (_c = refState.current) == null ? void 0 : _c.idsInFirstRender.has(id);
|
|
545
556
|
const prevLength = lengths.get(id) || (wasInFirstRender ? getItemLength(index, data2[index]) : 0);
|
|
546
|
-
if (!prevLength || prevLength
|
|
557
|
+
if (!prevLength || Math.abs(prevLength - length) > 0.5) {
|
|
547
558
|
lengths.set(id, length);
|
|
548
559
|
addTotalSize(length - prevLength);
|
|
549
560
|
if (((_d = refState.current) == null ? void 0 : _d.isAtBottom) && maintainScrollAtEnd) {
|
package/index.mjs
CHANGED
|
@@ -86,7 +86,7 @@ var Container = ({
|
|
|
86
86
|
onLayout: (event) => {
|
|
87
87
|
const index = peek$(ctx, `containerIndex${id}`);
|
|
88
88
|
if (index >= 0) {
|
|
89
|
-
const length =
|
|
89
|
+
const length = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
90
90
|
onLayout(index, length);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -286,6 +286,7 @@ var LegendListInner = forwardRef(
|
|
|
286
286
|
pendingAdjust: 0,
|
|
287
287
|
animFrameScroll: null,
|
|
288
288
|
animFrameLayout: null,
|
|
289
|
+
animFrameTotalSize: null,
|
|
289
290
|
isStartReached: false,
|
|
290
291
|
isEndReached: false,
|
|
291
292
|
isAtBottom: false,
|
|
@@ -297,7 +298,8 @@ var LegendListInner = forwardRef(
|
|
|
297
298
|
startNoBuffer: 0,
|
|
298
299
|
endBuffered: 0,
|
|
299
300
|
endNoBuffer: 0,
|
|
300
|
-
scroll: initialContentOffset || 0
|
|
301
|
+
scroll: initialContentOffset || 0,
|
|
302
|
+
totalSize: 0
|
|
301
303
|
};
|
|
302
304
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
303
305
|
}
|
|
@@ -305,12 +307,21 @@ var LegendListInner = forwardRef(
|
|
|
305
307
|
set$(ctx, `numItems`, data.length);
|
|
306
308
|
set$(ctx, `stylePaddingTop`, (_b = (_a = styleFlattened == null ? void 0 : styleFlattened.paddingTop) != null ? _a : contentContainerStyleFlattened == null ? void 0 : contentContainerStyleFlattened.paddingTop) != null ? _b : 0);
|
|
307
309
|
const addTotalSize = (add) => {
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
310
|
+
const prev = refState.current.totalSize;
|
|
311
|
+
const length = refState.current.totalSize += add;
|
|
312
|
+
const doAdd = () => {
|
|
313
|
+
refState.current.animFrameTotalSize = null;
|
|
314
|
+
set$(ctx, `totalLength`, length);
|
|
315
|
+
const screenLength = refState.current.scrollLength;
|
|
316
|
+
if (alignItemsAtEnd) {
|
|
317
|
+
const listPaddingTop = peek$(ctx, `stylePaddingTop`);
|
|
318
|
+
set$(ctx, `paddingTop`, Math.max(0, screenLength - length - listPaddingTop));
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
if (!prev) {
|
|
322
|
+
doAdd();
|
|
323
|
+
} else if (!refState.current.animFrameTotalSize) {
|
|
324
|
+
refState.current.animFrameTotalSize = requestAnimationFrame(doAdd);
|
|
314
325
|
}
|
|
315
326
|
};
|
|
316
327
|
const allocateContainers = useCallback(() => {
|
|
@@ -522,7 +533,7 @@ var LegendListInner = forwardRef(
|
|
|
522
533
|
const id = getId(index);
|
|
523
534
|
const wasInFirstRender = (_c = refState.current) == null ? void 0 : _c.idsInFirstRender.has(id);
|
|
524
535
|
const prevLength = lengths.get(id) || (wasInFirstRender ? getItemLength(index, data2[index]) : 0);
|
|
525
|
-
if (!prevLength || prevLength
|
|
536
|
+
if (!prevLength || Math.abs(prevLength - length) > 0.5) {
|
|
526
537
|
lengths.set(id, length);
|
|
527
538
|
addTotalSize(length - prevLength);
|
|
528
539
|
if (((_d = refState.current) == null ? void 0 : _d.isAtBottom) && maintainScrollAtEnd) {
|