@legendapp/list 2.0.0-next.6 → 2.0.0-next.8
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/.DS_Store +0 -0
- package/index.d.mts +10 -1
- package/index.d.ts +10 -1
- package/index.js +280 -278
- package/index.mjs +280 -278
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React3 from 'react';
|
|
2
2
|
import React3__default, { useReducer, useEffect, createContext, useRef, useState, useMemo, useLayoutEffect, useCallback, useImperativeHandle, useContext, forwardRef, memo } from 'react';
|
|
3
|
-
import { View, Text, Platform, Animated, ScrollView, StyleSheet, Dimensions, RefreshControl } from 'react-native';
|
|
3
|
+
import { View, Text, Platform, Animated, ScrollView, StyleSheet, Dimensions, RefreshControl, unstable_batchedUpdates } from 'react-native';
|
|
4
4
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
5
5
|
|
|
6
6
|
// src/components/LazyLegendList.tsx
|
|
@@ -17,7 +17,8 @@ function StateProvider({ children }) {
|
|
|
17
17
|
["alignItemsPaddingTop", 0],
|
|
18
18
|
["stylePaddingTop", 0],
|
|
19
19
|
["headerSize", 0],
|
|
20
|
-
["numContainers", 0]
|
|
20
|
+
["numContainers", 0],
|
|
21
|
+
["totalSize", 0]
|
|
21
22
|
]),
|
|
22
23
|
viewRefs: /* @__PURE__ */ new Map()
|
|
23
24
|
}));
|
|
@@ -90,7 +91,7 @@ function getContentSize(ctx) {
|
|
|
90
91
|
const stylePaddingTop = values.get("stylePaddingTop") || 0;
|
|
91
92
|
const headerSize = values.get("headerSize") || 0;
|
|
92
93
|
const footerSize = values.get("footerSize") || 0;
|
|
93
|
-
const totalSize = values.get("totalSize")
|
|
94
|
+
const totalSize = values.get("totalSize");
|
|
94
95
|
return headerSize + footerSize + totalSize + stylePaddingTop;
|
|
95
96
|
}
|
|
96
97
|
function useArr$(signalNames) {
|
|
@@ -574,13 +575,15 @@ function useSyncLayout({
|
|
|
574
575
|
},
|
|
575
576
|
[onChange]
|
|
576
577
|
);
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
ref.current
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
578
|
+
if (IsNewArchitecture) {
|
|
579
|
+
useLayoutEffect(() => {
|
|
580
|
+
if (ref.current) {
|
|
581
|
+
ref.current.measure((x, y, width, height) => {
|
|
582
|
+
onChange({ height, width, x, y }, true);
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
}, []);
|
|
586
|
+
}
|
|
584
587
|
return { onLayout, ref };
|
|
585
588
|
}
|
|
586
589
|
|
|
@@ -747,7 +750,7 @@ function getItemSize(state, key, index, data, useAverageSize) {
|
|
|
747
750
|
return sizeKnown;
|
|
748
751
|
}
|
|
749
752
|
let size;
|
|
750
|
-
if (
|
|
753
|
+
if (useAverageSize !== void 0 && sizeKnown === void 0 && !getEstimatedItemSize && !scrollingTo) {
|
|
751
754
|
size = useAverageSize;
|
|
752
755
|
}
|
|
753
756
|
if (size === void 0) {
|
|
@@ -846,14 +849,15 @@ function prepareMVCP(ctx, state) {
|
|
|
846
849
|
}
|
|
847
850
|
|
|
848
851
|
// src/utils/setPaddingTop.ts
|
|
849
|
-
function setPaddingTop(ctx, { stylePaddingTop, alignItemsPaddingTop }) {
|
|
852
|
+
function setPaddingTop(ctx, state, { stylePaddingTop, alignItemsPaddingTop }) {
|
|
850
853
|
if (stylePaddingTop !== void 0) {
|
|
851
854
|
const prevStylePaddingTop = peek$(ctx, "stylePaddingTop") || 0;
|
|
852
855
|
if (stylePaddingTop < prevStylePaddingTop) {
|
|
853
|
-
|
|
856
|
+
let prevTotalSize = peek$(ctx, "totalSize");
|
|
854
857
|
set$(ctx, "totalSize", prevTotalSize + prevStylePaddingTop);
|
|
855
|
-
setTimeout(() => {
|
|
856
|
-
|
|
858
|
+
state.timeoutSetPaddingTop = setTimeout(() => {
|
|
859
|
+
prevTotalSize = peek$(ctx, "totalSize");
|
|
860
|
+
set$(ctx, "totalSize", prevTotalSize - prevStylePaddingTop);
|
|
857
861
|
}, 16);
|
|
858
862
|
}
|
|
859
863
|
set$(ctx, "stylePaddingTop", stylePaddingTop);
|
|
@@ -875,7 +879,7 @@ function updateAlignItemsPaddingTop(ctx, state) {
|
|
|
875
879
|
const contentSize = getContentSize(ctx);
|
|
876
880
|
alignItemsPaddingTop = Math.max(0, Math.floor(scrollLength - contentSize));
|
|
877
881
|
}
|
|
878
|
-
setPaddingTop(ctx, { alignItemsPaddingTop });
|
|
882
|
+
setPaddingTop(ctx, state, { alignItemsPaddingTop });
|
|
879
883
|
}
|
|
880
884
|
}
|
|
881
885
|
|
|
@@ -905,6 +909,10 @@ function addTotalSize(ctx, state, key, add) {
|
|
|
905
909
|
const { alignItemsAtEnd } = state.props;
|
|
906
910
|
{
|
|
907
911
|
state.totalSize = add;
|
|
912
|
+
if (state.timeoutSetPaddingTop) {
|
|
913
|
+
clearTimeout(state.timeoutSetPaddingTop);
|
|
914
|
+
state.timeoutSetPaddingTop = void 0;
|
|
915
|
+
}
|
|
908
916
|
}
|
|
909
917
|
set$(ctx, "totalSize", state.totalSize);
|
|
910
918
|
if (alignItemsAtEnd) {
|
|
@@ -1463,265 +1471,267 @@ function setDidLayout(ctx, state) {
|
|
|
1463
1471
|
|
|
1464
1472
|
// src/core/calculateItemsInView.ts
|
|
1465
1473
|
function calculateItemsInView(ctx, state, params = {}) {
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
}
|
|
1485
|
-
const totalSize = peek$(ctx, "totalSize");
|
|
1486
|
-
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1487
|
-
const numColumns = peek$(ctx, "numColumns");
|
|
1488
|
-
const previousScrollAdjust = 0;
|
|
1489
|
-
const { dataChanged, doMVCP } = params;
|
|
1490
|
-
const speed = getScrollVelocity(state);
|
|
1491
|
-
if (doMVCP || dataChanged) {
|
|
1492
|
-
const checkMVCP = doMVCP ? prepareMVCP(ctx, state) : void 0;
|
|
1493
|
-
updateAllPositions(ctx, state, dataChanged);
|
|
1494
|
-
checkMVCP == null ? void 0 : checkMVCP();
|
|
1495
|
-
}
|
|
1496
|
-
const scrollExtra = 0;
|
|
1497
|
-
const { queuedInitialLayout } = state;
|
|
1498
|
-
let { scroll: scrollState } = state;
|
|
1499
|
-
const initialScroll = state.props.initialScroll;
|
|
1500
|
-
if (!queuedInitialLayout && initialScroll) {
|
|
1501
|
-
const updatedOffset = calculateOffsetWithOffsetPosition(
|
|
1502
|
-
state,
|
|
1503
|
-
calculateOffsetForIndex(ctx, state, initialScroll.index),
|
|
1504
|
-
initialScroll
|
|
1505
|
-
);
|
|
1506
|
-
scrollState = updatedOffset;
|
|
1507
|
-
}
|
|
1508
|
-
const scrollAdjustPad = -previousScrollAdjust - topPad;
|
|
1509
|
-
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1510
|
-
if (scroll + scrollLength > totalSize) {
|
|
1511
|
-
scroll = totalSize - scrollLength;
|
|
1512
|
-
}
|
|
1513
|
-
if (ENABLE_DEBUG_VIEW) {
|
|
1514
|
-
set$(ctx, "debugRawScroll", scrollState);
|
|
1515
|
-
set$(ctx, "debugComputedScroll", scroll);
|
|
1516
|
-
}
|
|
1517
|
-
const scrollBuffer = state.props.scrollBuffer;
|
|
1518
|
-
let scrollBufferTop = scrollBuffer;
|
|
1519
|
-
let scrollBufferBottom = scrollBuffer;
|
|
1520
|
-
if (speed > 0) {
|
|
1521
|
-
scrollBufferTop = scrollBuffer * 0.5;
|
|
1522
|
-
scrollBufferBottom = scrollBuffer * 1.5;
|
|
1523
|
-
} else {
|
|
1524
|
-
scrollBufferTop = scrollBuffer * 1.5;
|
|
1525
|
-
scrollBufferBottom = scrollBuffer * 0.5;
|
|
1526
|
-
}
|
|
1527
|
-
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1528
|
-
const scrollBottom = scroll + scrollLength;
|
|
1529
|
-
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1530
|
-
if (scrollForNextCalculateItemsInView) {
|
|
1531
|
-
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
1532
|
-
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
1474
|
+
unstable_batchedUpdates(() => {
|
|
1475
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1476
|
+
const {
|
|
1477
|
+
scrollLength,
|
|
1478
|
+
startBufferedId: startBufferedIdOrig,
|
|
1479
|
+
positions,
|
|
1480
|
+
columns,
|
|
1481
|
+
containerItemKeys,
|
|
1482
|
+
idCache,
|
|
1483
|
+
sizes,
|
|
1484
|
+
indexByKey,
|
|
1485
|
+
scrollForNextCalculateItemsInView,
|
|
1486
|
+
enableScrollForNextCalculateItemsInView,
|
|
1487
|
+
minIndexSizeChanged
|
|
1488
|
+
} = state;
|
|
1489
|
+
const data = state.props.data;
|
|
1490
|
+
const prevNumContainers = peek$(ctx, "numContainers");
|
|
1491
|
+
if (!data || scrollLength === 0 || !prevNumContainers) {
|
|
1533
1492
|
return;
|
|
1534
1493
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
const
|
|
1548
|
-
|
|
1549
|
-
const
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1494
|
+
const totalSize = peek$(ctx, "totalSize");
|
|
1495
|
+
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1496
|
+
const numColumns = peek$(ctx, "numColumns");
|
|
1497
|
+
const previousScrollAdjust = 0;
|
|
1498
|
+
const { dataChanged, doMVCP } = params;
|
|
1499
|
+
const speed = getScrollVelocity(state);
|
|
1500
|
+
if (doMVCP || dataChanged) {
|
|
1501
|
+
const checkMVCP = doMVCP ? prepareMVCP(ctx, state) : void 0;
|
|
1502
|
+
updateAllPositions(ctx, state, dataChanged);
|
|
1503
|
+
checkMVCP == null ? void 0 : checkMVCP();
|
|
1504
|
+
}
|
|
1505
|
+
const scrollExtra = 0;
|
|
1506
|
+
const { queuedInitialLayout } = state;
|
|
1507
|
+
let { scroll: scrollState } = state;
|
|
1508
|
+
const initialScroll = state.props.initialScroll;
|
|
1509
|
+
if (!queuedInitialLayout && initialScroll) {
|
|
1510
|
+
const updatedOffset = calculateOffsetWithOffsetPosition(
|
|
1511
|
+
state,
|
|
1512
|
+
calculateOffsetForIndex(ctx, state, initialScroll.index),
|
|
1513
|
+
initialScroll
|
|
1514
|
+
);
|
|
1515
|
+
scrollState = updatedOffset;
|
|
1516
|
+
}
|
|
1517
|
+
const scrollAdjustPad = -previousScrollAdjust - topPad;
|
|
1518
|
+
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1519
|
+
if (scroll + scrollLength > totalSize) {
|
|
1520
|
+
scroll = totalSize - scrollLength;
|
|
1521
|
+
}
|
|
1522
|
+
if (ENABLE_DEBUG_VIEW) {
|
|
1523
|
+
set$(ctx, "debugRawScroll", scrollState);
|
|
1524
|
+
set$(ctx, "debugComputedScroll", scroll);
|
|
1525
|
+
}
|
|
1526
|
+
const scrollBuffer = state.props.scrollBuffer;
|
|
1527
|
+
let scrollBufferTop = scrollBuffer;
|
|
1528
|
+
let scrollBufferBottom = scrollBuffer;
|
|
1529
|
+
if (speed > 0) {
|
|
1530
|
+
scrollBufferTop = scrollBuffer * 0.5;
|
|
1531
|
+
scrollBufferBottom = scrollBuffer * 1.5;
|
|
1553
1532
|
} else {
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
let maxIndexRendered = 0;
|
|
1565
|
-
for (let i = 0; i < prevNumContainers; i++) {
|
|
1566
|
-
const key = peek$(ctx, `containerItemKey${i}`);
|
|
1567
|
-
if (key !== void 0) {
|
|
1568
|
-
const index = indexByKey.get(key);
|
|
1569
|
-
maxIndexRendered = Math.max(maxIndexRendered, index);
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
let firstFullyOnScreenIndex;
|
|
1573
|
-
const dataLength = data.length;
|
|
1574
|
-
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
1575
|
-
const id = (_c = idCache.get(i)) != null ? _c : getId(state, i);
|
|
1576
|
-
const size = (_d = sizes.get(id)) != null ? _d : getItemSize(state, id, i, data[i]);
|
|
1577
|
-
const top = positions.get(id);
|
|
1578
|
-
if (!foundEnd) {
|
|
1579
|
-
if (startNoBuffer === null && top + size > scroll) {
|
|
1580
|
-
startNoBuffer = i;
|
|
1581
|
-
}
|
|
1582
|
-
if (firstFullyOnScreenIndex === void 0 && top >= scroll - 10) {
|
|
1583
|
-
firstFullyOnScreenIndex = i;
|
|
1584
|
-
}
|
|
1585
|
-
if (startBuffered === null && top + size > scrollTopBuffered) {
|
|
1586
|
-
startBuffered = i;
|
|
1587
|
-
startBufferedId = id;
|
|
1588
|
-
nextTop = top;
|
|
1589
|
-
}
|
|
1590
|
-
if (startNoBuffer !== null) {
|
|
1591
|
-
if (top <= scrollBottom) {
|
|
1592
|
-
endNoBuffer = i;
|
|
1593
|
-
}
|
|
1594
|
-
if (top <= scrollBottomBuffered) {
|
|
1595
|
-
endBuffered = i;
|
|
1596
|
-
nextBottom = top + size;
|
|
1597
|
-
} else {
|
|
1598
|
-
foundEnd = true;
|
|
1599
|
-
}
|
|
1533
|
+
scrollBufferTop = scrollBuffer * 1.5;
|
|
1534
|
+
scrollBufferBottom = scrollBuffer * 0.5;
|
|
1535
|
+
}
|
|
1536
|
+
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1537
|
+
const scrollBottom = scroll + scrollLength;
|
|
1538
|
+
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1539
|
+
if (scrollForNextCalculateItemsInView) {
|
|
1540
|
+
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
1541
|
+
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
1542
|
+
return;
|
|
1600
1543
|
}
|
|
1601
1544
|
}
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
} : void 0;
|
|
1622
|
-
}
|
|
1623
|
-
const numContainers = peek$(ctx, "numContainers");
|
|
1624
|
-
const pendingRemoval = [];
|
|
1625
|
-
if (dataChanged) {
|
|
1626
|
-
for (let i = 0; i < numContainers; i++) {
|
|
1627
|
-
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1628
|
-
if (!state.props.keyExtractor || itemKey && indexByKey.get(itemKey) === void 0) {
|
|
1629
|
-
pendingRemoval.push(i);
|
|
1545
|
+
let startNoBuffer = null;
|
|
1546
|
+
let startBuffered = null;
|
|
1547
|
+
let startBufferedId = null;
|
|
1548
|
+
let endNoBuffer = null;
|
|
1549
|
+
let endBuffered = null;
|
|
1550
|
+
let loopStart = startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
1551
|
+
if (minIndexSizeChanged !== void 0) {
|
|
1552
|
+
loopStart = Math.min(minIndexSizeChanged, loopStart);
|
|
1553
|
+
state.minIndexSizeChanged = void 0;
|
|
1554
|
+
}
|
|
1555
|
+
for (let i = loopStart; i >= 0; i--) {
|
|
1556
|
+
const id = (_a = idCache.get(i)) != null ? _a : getId(state, i);
|
|
1557
|
+
const top = positions.get(id);
|
|
1558
|
+
const size = (_b = sizes.get(id)) != null ? _b : getItemSize(state, id, i, data[i]);
|
|
1559
|
+
const bottom = top + size;
|
|
1560
|
+
if (bottom > scroll - scrollBuffer) {
|
|
1561
|
+
loopStart = i;
|
|
1562
|
+
} else {
|
|
1563
|
+
break;
|
|
1630
1564
|
}
|
|
1631
1565
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1566
|
+
const loopStartMod = loopStart % numColumns;
|
|
1567
|
+
if (loopStartMod > 0) {
|
|
1568
|
+
loopStart -= loopStartMod;
|
|
1569
|
+
}
|
|
1570
|
+
let foundEnd = false;
|
|
1571
|
+
let nextTop;
|
|
1572
|
+
let nextBottom;
|
|
1573
|
+
let maxIndexRendered = 0;
|
|
1574
|
+
for (let i = 0; i < prevNumContainers; i++) {
|
|
1575
|
+
const key = peek$(ctx, `containerItemKey${i}`);
|
|
1576
|
+
if (key !== void 0) {
|
|
1577
|
+
const index = indexByKey.get(key);
|
|
1578
|
+
maxIndexRendered = Math.max(maxIndexRendered, index);
|
|
1640
1579
|
}
|
|
1641
1580
|
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1581
|
+
let firstFullyOnScreenIndex;
|
|
1582
|
+
const dataLength = data.length;
|
|
1583
|
+
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
1584
|
+
const id = (_c = idCache.get(i)) != null ? _c : getId(state, i);
|
|
1585
|
+
const size = (_d = sizes.get(id)) != null ? _d : getItemSize(state, id, i, data[i]);
|
|
1586
|
+
const top = positions.get(id);
|
|
1587
|
+
if (!foundEnd) {
|
|
1588
|
+
if (startNoBuffer === null && top + size > scroll) {
|
|
1589
|
+
startNoBuffer = i;
|
|
1590
|
+
}
|
|
1591
|
+
if (firstFullyOnScreenIndex === void 0 && top >= scroll - 10) {
|
|
1592
|
+
firstFullyOnScreenIndex = i;
|
|
1593
|
+
}
|
|
1594
|
+
if (startBuffered === null && top + size > scrollTopBuffered) {
|
|
1595
|
+
startBuffered = i;
|
|
1596
|
+
startBufferedId = id;
|
|
1597
|
+
nextTop = top;
|
|
1658
1598
|
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1599
|
+
if (startNoBuffer !== null) {
|
|
1600
|
+
if (top <= scrollBottom) {
|
|
1601
|
+
endNoBuffer = i;
|
|
1602
|
+
}
|
|
1603
|
+
if (top <= scrollBottomBuffered) {
|
|
1604
|
+
endBuffered = i;
|
|
1605
|
+
nextBottom = top + size;
|
|
1606
|
+
} else {
|
|
1607
|
+
foundEnd = true;
|
|
1608
|
+
}
|
|
1664
1609
|
}
|
|
1665
1610
|
}
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1611
|
+
}
|
|
1612
|
+
const idsInView = [];
|
|
1613
|
+
for (let i = firstFullyOnScreenIndex; i <= endNoBuffer; i++) {
|
|
1614
|
+
const id = (_e = idCache.get(i)) != null ? _e : getId(state, i);
|
|
1615
|
+
idsInView.push(id);
|
|
1616
|
+
}
|
|
1617
|
+
Object.assign(state, {
|
|
1618
|
+
endBuffered,
|
|
1619
|
+
endNoBuffer,
|
|
1620
|
+
firstFullyOnScreenIndex,
|
|
1621
|
+
idsInView,
|
|
1622
|
+
startBuffered,
|
|
1623
|
+
startBufferedId,
|
|
1624
|
+
startNoBuffer
|
|
1625
|
+
});
|
|
1626
|
+
if (enableScrollForNextCalculateItemsInView && nextTop !== void 0 && nextBottom !== void 0) {
|
|
1627
|
+
state.scrollForNextCalculateItemsInView = nextTop !== void 0 && nextBottom !== void 0 ? {
|
|
1628
|
+
bottom: nextBottom,
|
|
1629
|
+
top: nextTop
|
|
1630
|
+
} : void 0;
|
|
1631
|
+
}
|
|
1632
|
+
const numContainers = peek$(ctx, "numContainers");
|
|
1633
|
+
const pendingRemoval = [];
|
|
1634
|
+
if (dataChanged) {
|
|
1635
|
+
for (let i = 0; i < numContainers; i++) {
|
|
1636
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1637
|
+
if (!state.props.keyExtractor || itemKey && indexByKey.get(itemKey) === void 0) {
|
|
1638
|
+
pendingRemoval.push(i);
|
|
1670
1639
|
}
|
|
1671
1640
|
}
|
|
1672
1641
|
}
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
containerItemKeys.
|
|
1642
|
+
if (startBuffered !== null && endBuffered !== null) {
|
|
1643
|
+
let numContainers2 = prevNumContainers;
|
|
1644
|
+
const needNewContainers = [];
|
|
1645
|
+
for (let i = startBuffered; i <= endBuffered; i++) {
|
|
1646
|
+
const id = (_f = idCache.get(i)) != null ? _f : getId(state, i);
|
|
1647
|
+
if (!containerItemKeys.has(id)) {
|
|
1648
|
+
needNewContainers.push(i);
|
|
1649
|
+
}
|
|
1679
1650
|
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
const
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
1697
|
-
if (position > POSITION_OUT_OF_VIEW && position !== prevPos) {
|
|
1698
|
-
set$(ctx, `containerPosition${i}`, position);
|
|
1651
|
+
if (needNewContainers.length > 0) {
|
|
1652
|
+
const availableContainers = findAvailableContainers(
|
|
1653
|
+
ctx,
|
|
1654
|
+
state,
|
|
1655
|
+
needNewContainers.length,
|
|
1656
|
+
startBuffered,
|
|
1657
|
+
endBuffered,
|
|
1658
|
+
pendingRemoval
|
|
1659
|
+
);
|
|
1660
|
+
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
1661
|
+
const i = needNewContainers[idx];
|
|
1662
|
+
const containerIndex = availableContainers[idx];
|
|
1663
|
+
const id = (_g = idCache.get(i)) != null ? _g : getId(state, i);
|
|
1664
|
+
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
1665
|
+
if (oldKey && oldKey !== id) {
|
|
1666
|
+
containerItemKeys.delete(oldKey);
|
|
1699
1667
|
}
|
|
1700
|
-
|
|
1701
|
-
|
|
1668
|
+
set$(ctx, `containerItemKey${containerIndex}`, id);
|
|
1669
|
+
set$(ctx, `containerItemData${containerIndex}`, data[i]);
|
|
1670
|
+
containerItemKeys.add(id);
|
|
1671
|
+
if (containerIndex >= numContainers2) {
|
|
1672
|
+
numContainers2 = containerIndex + 1;
|
|
1702
1673
|
}
|
|
1703
|
-
|
|
1704
|
-
|
|
1674
|
+
}
|
|
1675
|
+
if (numContainers2 !== prevNumContainers) {
|
|
1676
|
+
set$(ctx, "numContainers", numContainers2);
|
|
1677
|
+
if (numContainers2 > peek$(ctx, "numContainersPooled")) {
|
|
1678
|
+
set$(ctx, "numContainersPooled", Math.ceil(numContainers2 * 1.5));
|
|
1705
1679
|
}
|
|
1706
1680
|
}
|
|
1707
1681
|
}
|
|
1708
1682
|
}
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1683
|
+
for (let i = 0; i < numContainers; i++) {
|
|
1684
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1685
|
+
if (pendingRemoval.includes(i)) {
|
|
1686
|
+
if (itemKey) {
|
|
1687
|
+
containerItemKeys.delete(itemKey);
|
|
1688
|
+
}
|
|
1689
|
+
set$(ctx, `containerItemKey${i}`, void 0);
|
|
1690
|
+
set$(ctx, `containerItemData${i}`, void 0);
|
|
1691
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1692
|
+
set$(ctx, `containerColumn${i}`, -1);
|
|
1693
|
+
} else {
|
|
1694
|
+
const itemIndex = indexByKey.get(itemKey);
|
|
1695
|
+
const item = data[itemIndex];
|
|
1696
|
+
if (item !== void 0) {
|
|
1697
|
+
const id = (_h = idCache.get(itemIndex)) != null ? _h : getId(state, itemIndex);
|
|
1698
|
+
const position = positions.get(id);
|
|
1699
|
+
if (position === void 0) {
|
|
1700
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1701
|
+
} else {
|
|
1702
|
+
const column = columns.get(id) || 1;
|
|
1703
|
+
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
1704
|
+
const prevColumn = peek$(ctx, `containerColumn${i}`);
|
|
1705
|
+
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
1706
|
+
if (position > POSITION_OUT_OF_VIEW && position !== prevPos) {
|
|
1707
|
+
set$(ctx, `containerPosition${i}`, position);
|
|
1708
|
+
}
|
|
1709
|
+
if (column >= 0 && column !== prevColumn) {
|
|
1710
|
+
set$(ctx, `containerColumn${i}`, column);
|
|
1711
|
+
}
|
|
1712
|
+
if (prevData !== item) {
|
|
1713
|
+
set$(ctx, `containerItemData${i}`, data[itemIndex]);
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1713
1718
|
}
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1719
|
+
if (!queuedInitialLayout && endBuffered !== null) {
|
|
1720
|
+
if (checkAllSizesKnown(state)) {
|
|
1721
|
+
setDidLayout(ctx, state);
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
if (state.props.viewabilityConfigCallbackPairs) {
|
|
1725
|
+
updateViewableItems(
|
|
1726
|
+
state,
|
|
1727
|
+
ctx,
|
|
1728
|
+
state.props.viewabilityConfigCallbackPairs,
|
|
1729
|
+
scrollLength,
|
|
1730
|
+
startNoBuffer,
|
|
1731
|
+
endNoBuffer
|
|
1732
|
+
);
|
|
1733
|
+
}
|
|
1734
|
+
});
|
|
1725
1735
|
}
|
|
1726
1736
|
|
|
1727
1737
|
// src/core/doInitialAllocateContainers.ts
|
|
@@ -1995,32 +2005,20 @@ function updateItemSizes(ctx, state, itemUpdates) {
|
|
|
1995
2005
|
}
|
|
1996
2006
|
}
|
|
1997
2007
|
function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
let measured;
|
|
2010
|
-
containerRef.current.measure((x, y, width, height) => {
|
|
2011
|
-
measured = { height, width, x, y };
|
|
2012
|
-
});
|
|
2013
|
-
if (measured) {
|
|
2014
|
-
changes.push({ itemKey: containerItemKey, sizeObj: measured });
|
|
2015
|
-
}
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
if (changes.length > 0) {
|
|
2020
|
-
updateItemSizes(ctx, state, changes);
|
|
2008
|
+
const { queuedItemSizeUpdates, queuedItemSizeUpdatesWaiting } = state;
|
|
2009
|
+
const containersDidLayout = peek$(ctx, "containersDidLayout");
|
|
2010
|
+
if (!containersDidLayout || !queuedItemSizeUpdatesWaiting) {
|
|
2011
|
+
updateItemSizes(ctx, state, [{ itemKey, sizeObj }]);
|
|
2012
|
+
if (containersDidLayout) {
|
|
2013
|
+
state.queuedItemSizeUpdatesWaiting = true;
|
|
2014
|
+
requestAnimationFrame(() => {
|
|
2015
|
+
state.queuedItemSizeUpdatesWaiting = false;
|
|
2016
|
+
updateItemSizes(ctx, state, queuedItemSizeUpdates);
|
|
2017
|
+
queuedItemSizeUpdates.length = 0;
|
|
2018
|
+
});
|
|
2021
2019
|
}
|
|
2022
2020
|
} else {
|
|
2023
|
-
|
|
2021
|
+
queuedItemSizeUpdates.push({ itemKey, sizeObj });
|
|
2024
2022
|
}
|
|
2025
2023
|
}
|
|
2026
2024
|
function updateOneItemSize(state, itemKey, sizeObj) {
|
|
@@ -2201,6 +2199,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2201
2199
|
positions: /* @__PURE__ */ new Map(),
|
|
2202
2200
|
props: {},
|
|
2203
2201
|
queuedCalculateItemsInView: 0,
|
|
2202
|
+
queuedItemSizeUpdates: [],
|
|
2204
2203
|
refScroller: void 0,
|
|
2205
2204
|
scroll: 0,
|
|
2206
2205
|
scrollAdjustHandler: new ScrollAdjustHandler(ctx),
|
|
@@ -2285,10 +2284,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2285
2284
|
set$(ctx, "lastItemKeys", memoizedLastItemKeys);
|
|
2286
2285
|
set$(ctx, "numColumns", numColumnsProp);
|
|
2287
2286
|
const prevPaddingTop = peek$(ctx, "stylePaddingTop");
|
|
2288
|
-
setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
|
|
2287
|
+
setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
|
|
2289
2288
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
2290
|
-
|
|
2289
|
+
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
2291
2290
|
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
2291
|
+
if (state.scroll < 0) {
|
|
2292
|
+
paddingDiff += state.scroll;
|
|
2293
|
+
}
|
|
2292
2294
|
requestAdjust(ctx, state, paddingDiff);
|
|
2293
2295
|
}
|
|
2294
2296
|
};
|