@legendapp/list 1.0.0-beta.22 → 1.0.0-beta.23
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.d.mts +4 -1
- package/index.d.ts +4 -1
- package/index.js +66 -40
- package/index.mjs +66 -40
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -100,7 +100,7 @@ interface InternalState {
|
|
|
100
100
|
isAtBottom: boolean;
|
|
101
101
|
isAtTop: boolean;
|
|
102
102
|
data: readonly any[];
|
|
103
|
-
hasScrolled
|
|
103
|
+
hasScrolled?: boolean;
|
|
104
104
|
scrollLength: number;
|
|
105
105
|
startBuffered: number;
|
|
106
106
|
startBufferedId?: string;
|
|
@@ -135,6 +135,9 @@ interface InternalState {
|
|
|
135
135
|
enableScrollForNextCalculateItemsInView: boolean;
|
|
136
136
|
minIndexSizeChanged: number | undefined;
|
|
137
137
|
numPendingInitialLayout: number;
|
|
138
|
+
queuedCalculateItemsInView: number | undefined;
|
|
139
|
+
lastBatchingAction: number;
|
|
140
|
+
ignoreScrollFromCalcTotal?: boolean;
|
|
138
141
|
}
|
|
139
142
|
interface ViewableRange<T> {
|
|
140
143
|
startBuffered: number;
|
package/index.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ interface InternalState {
|
|
|
100
100
|
isAtBottom: boolean;
|
|
101
101
|
isAtTop: boolean;
|
|
102
102
|
data: readonly any[];
|
|
103
|
-
hasScrolled
|
|
103
|
+
hasScrolled?: boolean;
|
|
104
104
|
scrollLength: number;
|
|
105
105
|
startBuffered: number;
|
|
106
106
|
startBufferedId?: string;
|
|
@@ -135,6 +135,9 @@ interface InternalState {
|
|
|
135
135
|
enableScrollForNextCalculateItemsInView: boolean;
|
|
136
136
|
minIndexSizeChanged: number | undefined;
|
|
137
137
|
numPendingInitialLayout: number;
|
|
138
|
+
queuedCalculateItemsInView: number | undefined;
|
|
139
|
+
lastBatchingAction: number;
|
|
140
|
+
ignoreScrollFromCalcTotal?: boolean;
|
|
138
141
|
}
|
|
139
142
|
interface ViewableRange<T> {
|
|
140
143
|
startBuffered: number;
|
package/index.js
CHANGED
|
@@ -247,9 +247,7 @@ var Container = ({
|
|
|
247
247
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
248
248
|
verticalPaddingStyles = {
|
|
249
249
|
paddingBottom: !lastItemKeys.has(itemKey) ? rowGap || gap || void 0 : void 0,
|
|
250
|
-
|
|
251
|
-
paddingLeft: column > 1 ? (columnGap || gap || 0) / 2 : void 0,
|
|
252
|
-
paddingRight: column < numColumns ? (columnGap || gap || 0) / 2 : void 0
|
|
250
|
+
paddingHorizontal: (columnGap || gap || 0) / 2
|
|
253
251
|
};
|
|
254
252
|
}
|
|
255
253
|
const style = horizontal ? {
|
|
@@ -272,18 +270,6 @@ var Container = ({
|
|
|
272
270
|
[itemKey, data, extraData]
|
|
273
271
|
);
|
|
274
272
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
275
|
-
React6.useEffect(() => {
|
|
276
|
-
if (itemKey) {
|
|
277
|
-
const timeout = setTimeout(() => {
|
|
278
|
-
if (refLastSize.current) {
|
|
279
|
-
updateItemSize(id, itemKey, refLastSize.current);
|
|
280
|
-
}
|
|
281
|
-
}, 16);
|
|
282
|
-
return () => {
|
|
283
|
-
clearTimeout(timeout);
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
}, [itemKey]);
|
|
287
273
|
const onLayout = (event) => {
|
|
288
274
|
if (itemKey !== void 0) {
|
|
289
275
|
const layout = event.nativeEvent.layout;
|
|
@@ -300,7 +286,7 @@ var Container = ({
|
|
|
300
286
|
return;
|
|
301
287
|
}
|
|
302
288
|
refLastSize.current = size;
|
|
303
|
-
updateItemSize(
|
|
289
|
+
updateItemSize(itemKey, size);
|
|
304
290
|
}
|
|
305
291
|
};
|
|
306
292
|
const ref = React6.useRef(null);
|
|
@@ -312,11 +298,24 @@ var Container = ({
|
|
|
312
298
|
if (measured) {
|
|
313
299
|
const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
|
|
314
300
|
if (size) {
|
|
315
|
-
updateItemSize(
|
|
301
|
+
updateItemSize(itemKey, size);
|
|
316
302
|
}
|
|
317
303
|
}
|
|
318
304
|
}
|
|
319
305
|
}, [itemKey]);
|
|
306
|
+
} else {
|
|
307
|
+
React6.useEffect(() => {
|
|
308
|
+
if (itemKey) {
|
|
309
|
+
const timeout = setTimeout(() => {
|
|
310
|
+
if (refLastSize.current) {
|
|
311
|
+
updateItemSize(itemKey, refLastSize.current);
|
|
312
|
+
}
|
|
313
|
+
}, 16);
|
|
314
|
+
return () => {
|
|
315
|
+
clearTimeout(timeout);
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}, [itemKey]);
|
|
320
319
|
}
|
|
321
320
|
const contextValue = React6.useMemo(
|
|
322
321
|
() => ({ containerId: id, itemKey, index, value: data }),
|
|
@@ -371,6 +370,9 @@ var Containers = typedMemo(function Containers2({
|
|
|
371
370
|
updateItemSize,
|
|
372
371
|
getRenderedItem
|
|
373
372
|
}) {
|
|
373
|
+
const ctx = useStateContext();
|
|
374
|
+
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
375
|
+
const numColumns = use$("numColumns");
|
|
374
376
|
const numContainers = use$("numContainersPooled");
|
|
375
377
|
const animSize = useValue$(
|
|
376
378
|
"totalSizeWithScrollAdjust",
|
|
@@ -397,6 +399,13 @@ var Containers = typedMemo(function Containers2({
|
|
|
397
399
|
);
|
|
398
400
|
}
|
|
399
401
|
const style = horizontal ? { width: animSize, opacity: animOpacity } : { height: animSize, opacity: animOpacity };
|
|
402
|
+
if (columnWrapperStyle && !horizontal && numColumns > 1) {
|
|
403
|
+
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
404
|
+
const mx = (columnGap || gap || 0) / 2;
|
|
405
|
+
if (mx) {
|
|
406
|
+
style.marginHorizontal = -mx;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
400
409
|
return /* @__PURE__ */ React6__namespace.createElement(reactNative.Animated.View, { style }, containers);
|
|
401
410
|
});
|
|
402
411
|
|
|
@@ -864,7 +873,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
864
873
|
isAtBottom: false,
|
|
865
874
|
isAtTop: false,
|
|
866
875
|
data: dataProp,
|
|
867
|
-
hasScrolled: false,
|
|
868
876
|
scrollLength: initialScrollLength,
|
|
869
877
|
startBuffered: 0,
|
|
870
878
|
startNoBuffer: 0,
|
|
@@ -894,7 +902,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
894
902
|
scrollForNextCalculateItemsInView: void 0,
|
|
895
903
|
enableScrollForNextCalculateItemsInView: true,
|
|
896
904
|
minIndexSizeChanged: 0,
|
|
897
|
-
numPendingInitialLayout: 0
|
|
905
|
+
numPendingInitialLayout: 0,
|
|
906
|
+
queuedCalculateItemsInView: 0,
|
|
907
|
+
lastBatchingAction: Date.now()
|
|
898
908
|
};
|
|
899
909
|
if (maintainVisibleContentPosition) {
|
|
900
910
|
if (initialScrollIndex) {
|
|
@@ -1017,7 +1027,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1017
1027
|
}
|
|
1018
1028
|
return res;
|
|
1019
1029
|
};
|
|
1020
|
-
const calculateItemsInView = React6.useCallback((
|
|
1030
|
+
const calculateItemsInView = React6.useCallback(() => {
|
|
1021
1031
|
var _a2;
|
|
1022
1032
|
const state = refState.current;
|
|
1023
1033
|
const {
|
|
@@ -1027,7 +1037,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1027
1037
|
startBufferedId: startBufferedIdOrig,
|
|
1028
1038
|
positions,
|
|
1029
1039
|
columns,
|
|
1030
|
-
scrollAdjustHandler
|
|
1040
|
+
scrollAdjustHandler,
|
|
1041
|
+
scrollVelocity: speed
|
|
1031
1042
|
} = state;
|
|
1032
1043
|
if (!data || scrollLength === 0) {
|
|
1033
1044
|
return;
|
|
@@ -1386,7 +1397,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1386
1397
|
if (!keyExtractorProp) {
|
|
1387
1398
|
state.positions.clear();
|
|
1388
1399
|
}
|
|
1389
|
-
calculateItemsInView(
|
|
1400
|
+
calculateItemsInView();
|
|
1390
1401
|
const didMaintainScrollAtEnd = doMaintainScrollAtEnd(false);
|
|
1391
1402
|
if (!didMaintainScrollAtEnd && dataProp.length > state.data.length) {
|
|
1392
1403
|
state.isEndReached = false;
|
|
@@ -1435,7 +1446,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1435
1446
|
(_a2 = refState.current.belowAnchorElementPositions) == null ? void 0 : _a2.clear();
|
|
1436
1447
|
(_b2 = refScroller.current) == null ? void 0 : _b2.scrollTo({ x: 0, y: 0, animated: false });
|
|
1437
1448
|
setTimeout(() => {
|
|
1438
|
-
calculateItemsInView(
|
|
1449
|
+
calculateItemsInView();
|
|
1439
1450
|
}, 0);
|
|
1440
1451
|
} else {
|
|
1441
1452
|
refState.current.startBufferedId = void 0;
|
|
@@ -1450,7 +1461,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1450
1461
|
}
|
|
1451
1462
|
(_c2 = refScroller.current) == null ? void 0 : _c2.scrollTo({ x: 0, y: 0, animated: false });
|
|
1452
1463
|
setTimeout(() => {
|
|
1453
|
-
calculateItemsInView(
|
|
1464
|
+
calculateItemsInView();
|
|
1454
1465
|
}, 0);
|
|
1455
1466
|
}
|
|
1456
1467
|
}
|
|
@@ -1473,10 +1484,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1473
1484
|
if (maxSizeInRow > 0) {
|
|
1474
1485
|
totalSize += maxSizeInRow;
|
|
1475
1486
|
}
|
|
1487
|
+
const state = refState.current;
|
|
1488
|
+
state.ignoreScrollFromCalcTotal = true;
|
|
1489
|
+
requestAnimationFrame(() => {
|
|
1490
|
+
state.ignoreScrollFromCalcTotal = false;
|
|
1491
|
+
});
|
|
1476
1492
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1477
1493
|
};
|
|
1478
1494
|
const isFirst = !refState.current.renderItem;
|
|
1479
1495
|
if (isFirst || didDataChange || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
1496
|
+
refState.current.lastBatchingAction = Date.now();
|
|
1480
1497
|
if (!keyExtractorProp && !isFirst && didDataChange) {
|
|
1481
1498
|
refState.current.sizes.clear();
|
|
1482
1499
|
refState.current.positions.clear();
|
|
@@ -1557,10 +1574,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1557
1574
|
set$(ctx, "numContainersPooled", numContainers * 2);
|
|
1558
1575
|
if (initialScrollIndex) {
|
|
1559
1576
|
requestAnimationFrame(() => {
|
|
1560
|
-
calculateItemsInView(
|
|
1577
|
+
calculateItemsInView();
|
|
1561
1578
|
});
|
|
1562
1579
|
} else {
|
|
1563
|
-
calculateItemsInView(
|
|
1580
|
+
calculateItemsInView();
|
|
1564
1581
|
}
|
|
1565
1582
|
}
|
|
1566
1583
|
};
|
|
@@ -1571,7 +1588,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1571
1588
|
state.enableScrollForNextCalculateItemsInView = !viewability;
|
|
1572
1589
|
doInitialAllocateContainers();
|
|
1573
1590
|
});
|
|
1574
|
-
const updateItemSize = React6.useCallback((
|
|
1591
|
+
const updateItemSize = React6.useCallback((itemKey, size) => {
|
|
1575
1592
|
const state = refState.current;
|
|
1576
1593
|
const { sizes, indexByKey, sizesLaidOut, data, rowHeights } = state;
|
|
1577
1594
|
if (!data) {
|
|
@@ -1641,27 +1658,30 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1641
1658
|
if (needsCalculate) {
|
|
1642
1659
|
const scrollVelocity = state.scrollVelocity;
|
|
1643
1660
|
if ((Number.isNaN(scrollVelocity) || Math.abs(scrollVelocity) < 1) && (!waitForInitialLayout || state.numPendingInitialLayout < 0)) {
|
|
1644
|
-
|
|
1661
|
+
if (Date.now() - state.lastBatchingAction < 500) {
|
|
1662
|
+
state.queuedCalculateItemsInView = requestAnimationFrame(() => {
|
|
1663
|
+
state.queuedCalculateItemsInView = void 0;
|
|
1664
|
+
calculateItemsInView();
|
|
1665
|
+
});
|
|
1666
|
+
} else {
|
|
1667
|
+
calculateItemsInView();
|
|
1668
|
+
}
|
|
1645
1669
|
}
|
|
1646
1670
|
}
|
|
1647
1671
|
}, []);
|
|
1648
|
-
const handleScrollDebounced = React6.useCallback((velocity) => {
|
|
1649
|
-
calculateItemsInView(velocity);
|
|
1650
|
-
checkAtBottom();
|
|
1651
|
-
checkAtTop();
|
|
1652
|
-
}, []);
|
|
1653
1672
|
const onLayout = React6.useCallback((event) => {
|
|
1673
|
+
const state = refState.current;
|
|
1654
1674
|
const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
1655
|
-
const didChange = scrollLength !==
|
|
1656
|
-
|
|
1657
|
-
|
|
1675
|
+
const didChange = scrollLength !== state.scrollLength;
|
|
1676
|
+
state.scrollLength = scrollLength;
|
|
1677
|
+
state.lastBatchingAction = Date.now();
|
|
1658
1678
|
doInitialAllocateContainers();
|
|
1659
1679
|
doMaintainScrollAtEnd(false);
|
|
1660
1680
|
doUpdatePaddingTop();
|
|
1661
1681
|
checkAtBottom();
|
|
1662
1682
|
checkAtTop();
|
|
1663
1683
|
if (didChange) {
|
|
1664
|
-
calculateItemsInView(
|
|
1684
|
+
calculateItemsInView();
|
|
1665
1685
|
}
|
|
1666
1686
|
if (__DEV__) {
|
|
1667
1687
|
const isWidthZero = event.nativeEvent.layout.width === 0;
|
|
@@ -1683,7 +1703,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1683
1703
|
return;
|
|
1684
1704
|
}
|
|
1685
1705
|
const state = refState.current;
|
|
1706
|
+
if (state.ignoreScrollFromCalcTotal) {
|
|
1707
|
+
return;
|
|
1708
|
+
}
|
|
1686
1709
|
state.hasScrolled = true;
|
|
1710
|
+
state.lastBatchingAction = Date.now();
|
|
1687
1711
|
const currentTime = performance.now();
|
|
1688
1712
|
const newScroll = event.nativeEvent.contentOffset[horizontal ? "x" : "y"];
|
|
1689
1713
|
if (!(state.scrollHistory.length === 0 && newScroll === initialContentOffset)) {
|
|
@@ -1711,7 +1735,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1711
1735
|
state.scroll = newScroll;
|
|
1712
1736
|
state.scrollTime = currentTime;
|
|
1713
1737
|
state.scrollVelocity = velocity;
|
|
1714
|
-
|
|
1738
|
+
calculateItemsInView();
|
|
1739
|
+
checkAtBottom();
|
|
1740
|
+
checkAtTop();
|
|
1715
1741
|
if (!fromSelf) {
|
|
1716
1742
|
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
1717
1743
|
}
|
|
@@ -1750,7 +1776,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1750
1776
|
if (wasAdjusted) {
|
|
1751
1777
|
refState.current.scrollVelocity = 0;
|
|
1752
1778
|
refState.current.scrollHistory = [];
|
|
1753
|
-
calculateItemsInView(
|
|
1779
|
+
calculateItemsInView();
|
|
1754
1780
|
}
|
|
1755
1781
|
},
|
|
1756
1782
|
animated ? 1e3 : 50
|
|
@@ -1801,7 +1827,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1801
1827
|
if (wasPaused) {
|
|
1802
1828
|
refState.current.scrollVelocity = 0;
|
|
1803
1829
|
refState.current.scrollHistory = [];
|
|
1804
|
-
calculateItemsInView(
|
|
1830
|
+
calculateItemsInView();
|
|
1805
1831
|
}
|
|
1806
1832
|
if (onMomentumScrollEnd) {
|
|
1807
1833
|
onMomentumScrollEnd(event);
|
package/index.mjs
CHANGED
|
@@ -226,9 +226,7 @@ var Container = ({
|
|
|
226
226
|
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
227
227
|
verticalPaddingStyles = {
|
|
228
228
|
paddingBottom: !lastItemKeys.has(itemKey) ? rowGap || gap || void 0 : void 0,
|
|
229
|
-
|
|
230
|
-
paddingLeft: column > 1 ? (columnGap || gap || 0) / 2 : void 0,
|
|
231
|
-
paddingRight: column < numColumns ? (columnGap || gap || 0) / 2 : void 0
|
|
229
|
+
paddingHorizontal: (columnGap || gap || 0) / 2
|
|
232
230
|
};
|
|
233
231
|
}
|
|
234
232
|
const style = horizontal ? {
|
|
@@ -251,18 +249,6 @@ var Container = ({
|
|
|
251
249
|
[itemKey, data, extraData]
|
|
252
250
|
);
|
|
253
251
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
254
|
-
useEffect(() => {
|
|
255
|
-
if (itemKey) {
|
|
256
|
-
const timeout = setTimeout(() => {
|
|
257
|
-
if (refLastSize.current) {
|
|
258
|
-
updateItemSize(id, itemKey, refLastSize.current);
|
|
259
|
-
}
|
|
260
|
-
}, 16);
|
|
261
|
-
return () => {
|
|
262
|
-
clearTimeout(timeout);
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
}, [itemKey]);
|
|
266
252
|
const onLayout = (event) => {
|
|
267
253
|
if (itemKey !== void 0) {
|
|
268
254
|
const layout = event.nativeEvent.layout;
|
|
@@ -279,7 +265,7 @@ var Container = ({
|
|
|
279
265
|
return;
|
|
280
266
|
}
|
|
281
267
|
refLastSize.current = size;
|
|
282
|
-
updateItemSize(
|
|
268
|
+
updateItemSize(itemKey, size);
|
|
283
269
|
}
|
|
284
270
|
};
|
|
285
271
|
const ref = useRef(null);
|
|
@@ -291,11 +277,24 @@ var Container = ({
|
|
|
291
277
|
if (measured) {
|
|
292
278
|
const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
|
|
293
279
|
if (size) {
|
|
294
|
-
updateItemSize(
|
|
280
|
+
updateItemSize(itemKey, size);
|
|
295
281
|
}
|
|
296
282
|
}
|
|
297
283
|
}
|
|
298
284
|
}, [itemKey]);
|
|
285
|
+
} else {
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
if (itemKey) {
|
|
288
|
+
const timeout = setTimeout(() => {
|
|
289
|
+
if (refLastSize.current) {
|
|
290
|
+
updateItemSize(itemKey, refLastSize.current);
|
|
291
|
+
}
|
|
292
|
+
}, 16);
|
|
293
|
+
return () => {
|
|
294
|
+
clearTimeout(timeout);
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}, [itemKey]);
|
|
299
298
|
}
|
|
300
299
|
const contextValue = useMemo(
|
|
301
300
|
() => ({ containerId: id, itemKey, index, value: data }),
|
|
@@ -350,6 +349,9 @@ var Containers = typedMemo(function Containers2({
|
|
|
350
349
|
updateItemSize,
|
|
351
350
|
getRenderedItem
|
|
352
351
|
}) {
|
|
352
|
+
const ctx = useStateContext();
|
|
353
|
+
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
354
|
+
const numColumns = use$("numColumns");
|
|
353
355
|
const numContainers = use$("numContainersPooled");
|
|
354
356
|
const animSize = useValue$(
|
|
355
357
|
"totalSizeWithScrollAdjust",
|
|
@@ -376,6 +378,13 @@ var Containers = typedMemo(function Containers2({
|
|
|
376
378
|
);
|
|
377
379
|
}
|
|
378
380
|
const style = horizontal ? { width: animSize, opacity: animOpacity } : { height: animSize, opacity: animOpacity };
|
|
381
|
+
if (columnWrapperStyle && !horizontal && numColumns > 1) {
|
|
382
|
+
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
383
|
+
const mx = (columnGap || gap || 0) / 2;
|
|
384
|
+
if (mx) {
|
|
385
|
+
style.marginHorizontal = -mx;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
379
388
|
return /* @__PURE__ */ React6.createElement(Animated.View, { style }, containers);
|
|
380
389
|
});
|
|
381
390
|
|
|
@@ -843,7 +852,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
843
852
|
isAtBottom: false,
|
|
844
853
|
isAtTop: false,
|
|
845
854
|
data: dataProp,
|
|
846
|
-
hasScrolled: false,
|
|
847
855
|
scrollLength: initialScrollLength,
|
|
848
856
|
startBuffered: 0,
|
|
849
857
|
startNoBuffer: 0,
|
|
@@ -873,7 +881,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
873
881
|
scrollForNextCalculateItemsInView: void 0,
|
|
874
882
|
enableScrollForNextCalculateItemsInView: true,
|
|
875
883
|
minIndexSizeChanged: 0,
|
|
876
|
-
numPendingInitialLayout: 0
|
|
884
|
+
numPendingInitialLayout: 0,
|
|
885
|
+
queuedCalculateItemsInView: 0,
|
|
886
|
+
lastBatchingAction: Date.now()
|
|
877
887
|
};
|
|
878
888
|
if (maintainVisibleContentPosition) {
|
|
879
889
|
if (initialScrollIndex) {
|
|
@@ -996,7 +1006,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
996
1006
|
}
|
|
997
1007
|
return res;
|
|
998
1008
|
};
|
|
999
|
-
const calculateItemsInView = useCallback((
|
|
1009
|
+
const calculateItemsInView = useCallback(() => {
|
|
1000
1010
|
var _a2;
|
|
1001
1011
|
const state = refState.current;
|
|
1002
1012
|
const {
|
|
@@ -1006,7 +1016,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1006
1016
|
startBufferedId: startBufferedIdOrig,
|
|
1007
1017
|
positions,
|
|
1008
1018
|
columns,
|
|
1009
|
-
scrollAdjustHandler
|
|
1019
|
+
scrollAdjustHandler,
|
|
1020
|
+
scrollVelocity: speed
|
|
1010
1021
|
} = state;
|
|
1011
1022
|
if (!data || scrollLength === 0) {
|
|
1012
1023
|
return;
|
|
@@ -1365,7 +1376,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1365
1376
|
if (!keyExtractorProp) {
|
|
1366
1377
|
state.positions.clear();
|
|
1367
1378
|
}
|
|
1368
|
-
calculateItemsInView(
|
|
1379
|
+
calculateItemsInView();
|
|
1369
1380
|
const didMaintainScrollAtEnd = doMaintainScrollAtEnd(false);
|
|
1370
1381
|
if (!didMaintainScrollAtEnd && dataProp.length > state.data.length) {
|
|
1371
1382
|
state.isEndReached = false;
|
|
@@ -1414,7 +1425,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1414
1425
|
(_a2 = refState.current.belowAnchorElementPositions) == null ? void 0 : _a2.clear();
|
|
1415
1426
|
(_b2 = refScroller.current) == null ? void 0 : _b2.scrollTo({ x: 0, y: 0, animated: false });
|
|
1416
1427
|
setTimeout(() => {
|
|
1417
|
-
calculateItemsInView(
|
|
1428
|
+
calculateItemsInView();
|
|
1418
1429
|
}, 0);
|
|
1419
1430
|
} else {
|
|
1420
1431
|
refState.current.startBufferedId = void 0;
|
|
@@ -1429,7 +1440,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1429
1440
|
}
|
|
1430
1441
|
(_c2 = refScroller.current) == null ? void 0 : _c2.scrollTo({ x: 0, y: 0, animated: false });
|
|
1431
1442
|
setTimeout(() => {
|
|
1432
|
-
calculateItemsInView(
|
|
1443
|
+
calculateItemsInView();
|
|
1433
1444
|
}, 0);
|
|
1434
1445
|
}
|
|
1435
1446
|
}
|
|
@@ -1452,10 +1463,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1452
1463
|
if (maxSizeInRow > 0) {
|
|
1453
1464
|
totalSize += maxSizeInRow;
|
|
1454
1465
|
}
|
|
1466
|
+
const state = refState.current;
|
|
1467
|
+
state.ignoreScrollFromCalcTotal = true;
|
|
1468
|
+
requestAnimationFrame(() => {
|
|
1469
|
+
state.ignoreScrollFromCalcTotal = false;
|
|
1470
|
+
});
|
|
1455
1471
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1456
1472
|
};
|
|
1457
1473
|
const isFirst = !refState.current.renderItem;
|
|
1458
1474
|
if (isFirst || didDataChange || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
1475
|
+
refState.current.lastBatchingAction = Date.now();
|
|
1459
1476
|
if (!keyExtractorProp && !isFirst && didDataChange) {
|
|
1460
1477
|
refState.current.sizes.clear();
|
|
1461
1478
|
refState.current.positions.clear();
|
|
@@ -1536,10 +1553,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1536
1553
|
set$(ctx, "numContainersPooled", numContainers * 2);
|
|
1537
1554
|
if (initialScrollIndex) {
|
|
1538
1555
|
requestAnimationFrame(() => {
|
|
1539
|
-
calculateItemsInView(
|
|
1556
|
+
calculateItemsInView();
|
|
1540
1557
|
});
|
|
1541
1558
|
} else {
|
|
1542
|
-
calculateItemsInView(
|
|
1559
|
+
calculateItemsInView();
|
|
1543
1560
|
}
|
|
1544
1561
|
}
|
|
1545
1562
|
};
|
|
@@ -1550,7 +1567,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1550
1567
|
state.enableScrollForNextCalculateItemsInView = !viewability;
|
|
1551
1568
|
doInitialAllocateContainers();
|
|
1552
1569
|
});
|
|
1553
|
-
const updateItemSize = useCallback((
|
|
1570
|
+
const updateItemSize = useCallback((itemKey, size) => {
|
|
1554
1571
|
const state = refState.current;
|
|
1555
1572
|
const { sizes, indexByKey, sizesLaidOut, data, rowHeights } = state;
|
|
1556
1573
|
if (!data) {
|
|
@@ -1620,27 +1637,30 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1620
1637
|
if (needsCalculate) {
|
|
1621
1638
|
const scrollVelocity = state.scrollVelocity;
|
|
1622
1639
|
if ((Number.isNaN(scrollVelocity) || Math.abs(scrollVelocity) < 1) && (!waitForInitialLayout || state.numPendingInitialLayout < 0)) {
|
|
1623
|
-
|
|
1640
|
+
if (Date.now() - state.lastBatchingAction < 500) {
|
|
1641
|
+
state.queuedCalculateItemsInView = requestAnimationFrame(() => {
|
|
1642
|
+
state.queuedCalculateItemsInView = void 0;
|
|
1643
|
+
calculateItemsInView();
|
|
1644
|
+
});
|
|
1645
|
+
} else {
|
|
1646
|
+
calculateItemsInView();
|
|
1647
|
+
}
|
|
1624
1648
|
}
|
|
1625
1649
|
}
|
|
1626
1650
|
}, []);
|
|
1627
|
-
const handleScrollDebounced = useCallback((velocity) => {
|
|
1628
|
-
calculateItemsInView(velocity);
|
|
1629
|
-
checkAtBottom();
|
|
1630
|
-
checkAtTop();
|
|
1631
|
-
}, []);
|
|
1632
1651
|
const onLayout = useCallback((event) => {
|
|
1652
|
+
const state = refState.current;
|
|
1633
1653
|
const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
1634
|
-
const didChange = scrollLength !==
|
|
1635
|
-
|
|
1636
|
-
|
|
1654
|
+
const didChange = scrollLength !== state.scrollLength;
|
|
1655
|
+
state.scrollLength = scrollLength;
|
|
1656
|
+
state.lastBatchingAction = Date.now();
|
|
1637
1657
|
doInitialAllocateContainers();
|
|
1638
1658
|
doMaintainScrollAtEnd(false);
|
|
1639
1659
|
doUpdatePaddingTop();
|
|
1640
1660
|
checkAtBottom();
|
|
1641
1661
|
checkAtTop();
|
|
1642
1662
|
if (didChange) {
|
|
1643
|
-
calculateItemsInView(
|
|
1663
|
+
calculateItemsInView();
|
|
1644
1664
|
}
|
|
1645
1665
|
if (__DEV__) {
|
|
1646
1666
|
const isWidthZero = event.nativeEvent.layout.width === 0;
|
|
@@ -1662,7 +1682,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1662
1682
|
return;
|
|
1663
1683
|
}
|
|
1664
1684
|
const state = refState.current;
|
|
1685
|
+
if (state.ignoreScrollFromCalcTotal) {
|
|
1686
|
+
return;
|
|
1687
|
+
}
|
|
1665
1688
|
state.hasScrolled = true;
|
|
1689
|
+
state.lastBatchingAction = Date.now();
|
|
1666
1690
|
const currentTime = performance.now();
|
|
1667
1691
|
const newScroll = event.nativeEvent.contentOffset[horizontal ? "x" : "y"];
|
|
1668
1692
|
if (!(state.scrollHistory.length === 0 && newScroll === initialContentOffset)) {
|
|
@@ -1690,7 +1714,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1690
1714
|
state.scroll = newScroll;
|
|
1691
1715
|
state.scrollTime = currentTime;
|
|
1692
1716
|
state.scrollVelocity = velocity;
|
|
1693
|
-
|
|
1717
|
+
calculateItemsInView();
|
|
1718
|
+
checkAtBottom();
|
|
1719
|
+
checkAtTop();
|
|
1694
1720
|
if (!fromSelf) {
|
|
1695
1721
|
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
1696
1722
|
}
|
|
@@ -1729,7 +1755,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1729
1755
|
if (wasAdjusted) {
|
|
1730
1756
|
refState.current.scrollVelocity = 0;
|
|
1731
1757
|
refState.current.scrollHistory = [];
|
|
1732
|
-
calculateItemsInView(
|
|
1758
|
+
calculateItemsInView();
|
|
1733
1759
|
}
|
|
1734
1760
|
},
|
|
1735
1761
|
animated ? 1e3 : 50
|
|
@@ -1780,7 +1806,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1780
1806
|
if (wasPaused) {
|
|
1781
1807
|
refState.current.scrollVelocity = 0;
|
|
1782
1808
|
refState.current.scrollHistory = [];
|
|
1783
|
-
calculateItemsInView(
|
|
1809
|
+
calculateItemsInView();
|
|
1784
1810
|
}
|
|
1785
1811
|
if (onMomentumScrollEnd) {
|
|
1786
1812
|
onMomentumScrollEnd(event);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/list",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.23",
|
|
4
4
|
"description": "Legend List aims to be a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"private": false,
|