@legendapp/list 0.3.3 → 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 +21 -9
- package/index.mjs +21 -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
|
}
|
|
@@ -208,6 +208,7 @@ var ListComponent = React6__namespace.memo(function ListComponent2({
|
|
|
208
208
|
],
|
|
209
209
|
onScroll: handleScroll,
|
|
210
210
|
onLayout,
|
|
211
|
+
scrollEventThrottle: 32,
|
|
211
212
|
horizontal,
|
|
212
213
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
213
214
|
ref: refScroller
|
|
@@ -306,6 +307,7 @@ var LegendListInner = React6.forwardRef(
|
|
|
306
307
|
pendingAdjust: 0,
|
|
307
308
|
animFrameScroll: null,
|
|
308
309
|
animFrameLayout: null,
|
|
310
|
+
animFrameTotalSize: null,
|
|
309
311
|
isStartReached: false,
|
|
310
312
|
isEndReached: false,
|
|
311
313
|
isAtBottom: false,
|
|
@@ -317,7 +319,8 @@ var LegendListInner = React6.forwardRef(
|
|
|
317
319
|
startNoBuffer: 0,
|
|
318
320
|
endBuffered: 0,
|
|
319
321
|
endNoBuffer: 0,
|
|
320
|
-
scroll: initialContentOffset || 0
|
|
322
|
+
scroll: initialContentOffset || 0,
|
|
323
|
+
totalSize: 0
|
|
321
324
|
};
|
|
322
325
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
323
326
|
}
|
|
@@ -325,12 +328,21 @@ var LegendListInner = React6.forwardRef(
|
|
|
325
328
|
set$(ctx, `numItems`, data.length);
|
|
326
329
|
set$(ctx, `stylePaddingTop`, (_b = (_a = styleFlattened == null ? void 0 : styleFlattened.paddingTop) != null ? _a : contentContainerStyleFlattened == null ? void 0 : contentContainerStyleFlattened.paddingTop) != null ? _b : 0);
|
|
327
330
|
const addTotalSize = (add) => {
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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);
|
|
334
346
|
}
|
|
335
347
|
};
|
|
336
348
|
const allocateContainers = React6.useCallback(() => {
|
|
@@ -542,7 +554,7 @@ var LegendListInner = React6.forwardRef(
|
|
|
542
554
|
const id = getId(index);
|
|
543
555
|
const wasInFirstRender = (_c = refState.current) == null ? void 0 : _c.idsInFirstRender.has(id);
|
|
544
556
|
const prevLength = lengths.get(id) || (wasInFirstRender ? getItemLength(index, data2[index]) : 0);
|
|
545
|
-
if (!prevLength || prevLength
|
|
557
|
+
if (!prevLength || Math.abs(prevLength - length) > 0.5) {
|
|
546
558
|
lengths.set(id, length);
|
|
547
559
|
addTotalSize(length - prevLength);
|
|
548
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
|
}
|
|
@@ -187,6 +187,7 @@ var ListComponent = React6.memo(function ListComponent2({
|
|
|
187
187
|
],
|
|
188
188
|
onScroll: handleScroll,
|
|
189
189
|
onLayout,
|
|
190
|
+
scrollEventThrottle: 32,
|
|
190
191
|
horizontal,
|
|
191
192
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
192
193
|
ref: refScroller
|
|
@@ -285,6 +286,7 @@ var LegendListInner = forwardRef(
|
|
|
285
286
|
pendingAdjust: 0,
|
|
286
287
|
animFrameScroll: null,
|
|
287
288
|
animFrameLayout: null,
|
|
289
|
+
animFrameTotalSize: null,
|
|
288
290
|
isStartReached: false,
|
|
289
291
|
isEndReached: false,
|
|
290
292
|
isAtBottom: false,
|
|
@@ -296,7 +298,8 @@ var LegendListInner = forwardRef(
|
|
|
296
298
|
startNoBuffer: 0,
|
|
297
299
|
endBuffered: 0,
|
|
298
300
|
endNoBuffer: 0,
|
|
299
|
-
scroll: initialContentOffset || 0
|
|
301
|
+
scroll: initialContentOffset || 0,
|
|
302
|
+
totalSize: 0
|
|
300
303
|
};
|
|
301
304
|
refState.current.idsInFirstRender = new Set(data.map((_, i) => getId(i)));
|
|
302
305
|
}
|
|
@@ -304,12 +307,21 @@ var LegendListInner = forwardRef(
|
|
|
304
307
|
set$(ctx, `numItems`, data.length);
|
|
305
308
|
set$(ctx, `stylePaddingTop`, (_b = (_a = styleFlattened == null ? void 0 : styleFlattened.paddingTop) != null ? _a : contentContainerStyleFlattened == null ? void 0 : contentContainerStyleFlattened.paddingTop) != null ? _b : 0);
|
|
306
309
|
const addTotalSize = (add) => {
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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);
|
|
313
325
|
}
|
|
314
326
|
};
|
|
315
327
|
const allocateContainers = useCallback(() => {
|
|
@@ -521,7 +533,7 @@ var LegendListInner = forwardRef(
|
|
|
521
533
|
const id = getId(index);
|
|
522
534
|
const wasInFirstRender = (_c = refState.current) == null ? void 0 : _c.idsInFirstRender.has(id);
|
|
523
535
|
const prevLength = lengths.get(id) || (wasInFirstRender ? getItemLength(index, data2[index]) : 0);
|
|
524
|
-
if (!prevLength || prevLength
|
|
536
|
+
if (!prevLength || Math.abs(prevLength - length) > 0.5) {
|
|
525
537
|
lengths.set(id, length);
|
|
526
538
|
addTotalSize(length - prevLength);
|
|
527
539
|
if (((_d = refState.current) == null ? void 0 : _d.isAtBottom) && maintainScrollAtEnd) {
|