@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.js
CHANGED
|
@@ -38,7 +38,8 @@ function StateProvider({ children }) {
|
|
|
38
38
|
["alignItemsPaddingTop", 0],
|
|
39
39
|
["stylePaddingTop", 0],
|
|
40
40
|
["headerSize", 0],
|
|
41
|
-
["numContainers", 0]
|
|
41
|
+
["numContainers", 0],
|
|
42
|
+
["totalSize", 0]
|
|
42
43
|
]),
|
|
43
44
|
viewRefs: /* @__PURE__ */ new Map()
|
|
44
45
|
}));
|
|
@@ -111,7 +112,7 @@ function getContentSize(ctx) {
|
|
|
111
112
|
const stylePaddingTop = values.get("stylePaddingTop") || 0;
|
|
112
113
|
const headerSize = values.get("headerSize") || 0;
|
|
113
114
|
const footerSize = values.get("footerSize") || 0;
|
|
114
|
-
const totalSize = values.get("totalSize")
|
|
115
|
+
const totalSize = values.get("totalSize");
|
|
115
116
|
return headerSize + footerSize + totalSize + stylePaddingTop;
|
|
116
117
|
}
|
|
117
118
|
function useArr$(signalNames) {
|
|
@@ -595,13 +596,15 @@ function useSyncLayout({
|
|
|
595
596
|
},
|
|
596
597
|
[onChange]
|
|
597
598
|
);
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
ref.current
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
599
|
+
if (IsNewArchitecture) {
|
|
600
|
+
React3.useLayoutEffect(() => {
|
|
601
|
+
if (ref.current) {
|
|
602
|
+
ref.current.measure((x, y, width, height) => {
|
|
603
|
+
onChange({ height, width, x, y }, true);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
}, []);
|
|
607
|
+
}
|
|
605
608
|
return { onLayout, ref };
|
|
606
609
|
}
|
|
607
610
|
|
|
@@ -768,7 +771,7 @@ function getItemSize(state, key, index, data, useAverageSize) {
|
|
|
768
771
|
return sizeKnown;
|
|
769
772
|
}
|
|
770
773
|
let size;
|
|
771
|
-
if (
|
|
774
|
+
if (useAverageSize !== void 0 && sizeKnown === void 0 && !getEstimatedItemSize && !scrollingTo) {
|
|
772
775
|
size = useAverageSize;
|
|
773
776
|
}
|
|
774
777
|
if (size === void 0) {
|
|
@@ -867,14 +870,15 @@ function prepareMVCP(ctx, state) {
|
|
|
867
870
|
}
|
|
868
871
|
|
|
869
872
|
// src/utils/setPaddingTop.ts
|
|
870
|
-
function setPaddingTop(ctx, { stylePaddingTop, alignItemsPaddingTop }) {
|
|
873
|
+
function setPaddingTop(ctx, state, { stylePaddingTop, alignItemsPaddingTop }) {
|
|
871
874
|
if (stylePaddingTop !== void 0) {
|
|
872
875
|
const prevStylePaddingTop = peek$(ctx, "stylePaddingTop") || 0;
|
|
873
876
|
if (stylePaddingTop < prevStylePaddingTop) {
|
|
874
|
-
|
|
877
|
+
let prevTotalSize = peek$(ctx, "totalSize");
|
|
875
878
|
set$(ctx, "totalSize", prevTotalSize + prevStylePaddingTop);
|
|
876
|
-
setTimeout(() => {
|
|
877
|
-
|
|
879
|
+
state.timeoutSetPaddingTop = setTimeout(() => {
|
|
880
|
+
prevTotalSize = peek$(ctx, "totalSize");
|
|
881
|
+
set$(ctx, "totalSize", prevTotalSize - prevStylePaddingTop);
|
|
878
882
|
}, 16);
|
|
879
883
|
}
|
|
880
884
|
set$(ctx, "stylePaddingTop", stylePaddingTop);
|
|
@@ -896,7 +900,7 @@ function updateAlignItemsPaddingTop(ctx, state) {
|
|
|
896
900
|
const contentSize = getContentSize(ctx);
|
|
897
901
|
alignItemsPaddingTop = Math.max(0, Math.floor(scrollLength - contentSize));
|
|
898
902
|
}
|
|
899
|
-
setPaddingTop(ctx, { alignItemsPaddingTop });
|
|
903
|
+
setPaddingTop(ctx, state, { alignItemsPaddingTop });
|
|
900
904
|
}
|
|
901
905
|
}
|
|
902
906
|
|
|
@@ -926,6 +930,10 @@ function addTotalSize(ctx, state, key, add) {
|
|
|
926
930
|
const { alignItemsAtEnd } = state.props;
|
|
927
931
|
{
|
|
928
932
|
state.totalSize = add;
|
|
933
|
+
if (state.timeoutSetPaddingTop) {
|
|
934
|
+
clearTimeout(state.timeoutSetPaddingTop);
|
|
935
|
+
state.timeoutSetPaddingTop = void 0;
|
|
936
|
+
}
|
|
929
937
|
}
|
|
930
938
|
set$(ctx, "totalSize", state.totalSize);
|
|
931
939
|
if (alignItemsAtEnd) {
|
|
@@ -1484,265 +1492,267 @@ function setDidLayout(ctx, state) {
|
|
|
1484
1492
|
|
|
1485
1493
|
// src/core/calculateItemsInView.ts
|
|
1486
1494
|
function calculateItemsInView(ctx, state, params = {}) {
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
}
|
|
1506
|
-
const totalSize = peek$(ctx, "totalSize");
|
|
1507
|
-
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1508
|
-
const numColumns = peek$(ctx, "numColumns");
|
|
1509
|
-
const previousScrollAdjust = 0;
|
|
1510
|
-
const { dataChanged, doMVCP } = params;
|
|
1511
|
-
const speed = getScrollVelocity(state);
|
|
1512
|
-
if (doMVCP || dataChanged) {
|
|
1513
|
-
const checkMVCP = doMVCP ? prepareMVCP(ctx, state) : void 0;
|
|
1514
|
-
updateAllPositions(ctx, state, dataChanged);
|
|
1515
|
-
checkMVCP == null ? void 0 : checkMVCP();
|
|
1516
|
-
}
|
|
1517
|
-
const scrollExtra = 0;
|
|
1518
|
-
const { queuedInitialLayout } = state;
|
|
1519
|
-
let { scroll: scrollState } = state;
|
|
1520
|
-
const initialScroll = state.props.initialScroll;
|
|
1521
|
-
if (!queuedInitialLayout && initialScroll) {
|
|
1522
|
-
const updatedOffset = calculateOffsetWithOffsetPosition(
|
|
1523
|
-
state,
|
|
1524
|
-
calculateOffsetForIndex(ctx, state, initialScroll.index),
|
|
1525
|
-
initialScroll
|
|
1526
|
-
);
|
|
1527
|
-
scrollState = updatedOffset;
|
|
1528
|
-
}
|
|
1529
|
-
const scrollAdjustPad = -previousScrollAdjust - topPad;
|
|
1530
|
-
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1531
|
-
if (scroll + scrollLength > totalSize) {
|
|
1532
|
-
scroll = totalSize - scrollLength;
|
|
1533
|
-
}
|
|
1534
|
-
if (ENABLE_DEBUG_VIEW) {
|
|
1535
|
-
set$(ctx, "debugRawScroll", scrollState);
|
|
1536
|
-
set$(ctx, "debugComputedScroll", scroll);
|
|
1537
|
-
}
|
|
1538
|
-
const scrollBuffer = state.props.scrollBuffer;
|
|
1539
|
-
let scrollBufferTop = scrollBuffer;
|
|
1540
|
-
let scrollBufferBottom = scrollBuffer;
|
|
1541
|
-
if (speed > 0) {
|
|
1542
|
-
scrollBufferTop = scrollBuffer * 0.5;
|
|
1543
|
-
scrollBufferBottom = scrollBuffer * 1.5;
|
|
1544
|
-
} else {
|
|
1545
|
-
scrollBufferTop = scrollBuffer * 1.5;
|
|
1546
|
-
scrollBufferBottom = scrollBuffer * 0.5;
|
|
1547
|
-
}
|
|
1548
|
-
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1549
|
-
const scrollBottom = scroll + scrollLength;
|
|
1550
|
-
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1551
|
-
if (scrollForNextCalculateItemsInView) {
|
|
1552
|
-
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
1553
|
-
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
1495
|
+
reactNative.unstable_batchedUpdates(() => {
|
|
1496
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1497
|
+
const {
|
|
1498
|
+
scrollLength,
|
|
1499
|
+
startBufferedId: startBufferedIdOrig,
|
|
1500
|
+
positions,
|
|
1501
|
+
columns,
|
|
1502
|
+
containerItemKeys,
|
|
1503
|
+
idCache,
|
|
1504
|
+
sizes,
|
|
1505
|
+
indexByKey,
|
|
1506
|
+
scrollForNextCalculateItemsInView,
|
|
1507
|
+
enableScrollForNextCalculateItemsInView,
|
|
1508
|
+
minIndexSizeChanged
|
|
1509
|
+
} = state;
|
|
1510
|
+
const data = state.props.data;
|
|
1511
|
+
const prevNumContainers = peek$(ctx, "numContainers");
|
|
1512
|
+
if (!data || scrollLength === 0 || !prevNumContainers) {
|
|
1554
1513
|
return;
|
|
1555
1514
|
}
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1570
|
-
const
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1515
|
+
const totalSize = peek$(ctx, "totalSize");
|
|
1516
|
+
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1517
|
+
const numColumns = peek$(ctx, "numColumns");
|
|
1518
|
+
const previousScrollAdjust = 0;
|
|
1519
|
+
const { dataChanged, doMVCP } = params;
|
|
1520
|
+
const speed = getScrollVelocity(state);
|
|
1521
|
+
if (doMVCP || dataChanged) {
|
|
1522
|
+
const checkMVCP = doMVCP ? prepareMVCP(ctx, state) : void 0;
|
|
1523
|
+
updateAllPositions(ctx, state, dataChanged);
|
|
1524
|
+
checkMVCP == null ? void 0 : checkMVCP();
|
|
1525
|
+
}
|
|
1526
|
+
const scrollExtra = 0;
|
|
1527
|
+
const { queuedInitialLayout } = state;
|
|
1528
|
+
let { scroll: scrollState } = state;
|
|
1529
|
+
const initialScroll = state.props.initialScroll;
|
|
1530
|
+
if (!queuedInitialLayout && initialScroll) {
|
|
1531
|
+
const updatedOffset = calculateOffsetWithOffsetPosition(
|
|
1532
|
+
state,
|
|
1533
|
+
calculateOffsetForIndex(ctx, state, initialScroll.index),
|
|
1534
|
+
initialScroll
|
|
1535
|
+
);
|
|
1536
|
+
scrollState = updatedOffset;
|
|
1537
|
+
}
|
|
1538
|
+
const scrollAdjustPad = -previousScrollAdjust - topPad;
|
|
1539
|
+
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1540
|
+
if (scroll + scrollLength > totalSize) {
|
|
1541
|
+
scroll = totalSize - scrollLength;
|
|
1542
|
+
}
|
|
1543
|
+
if (ENABLE_DEBUG_VIEW) {
|
|
1544
|
+
set$(ctx, "debugRawScroll", scrollState);
|
|
1545
|
+
set$(ctx, "debugComputedScroll", scroll);
|
|
1546
|
+
}
|
|
1547
|
+
const scrollBuffer = state.props.scrollBuffer;
|
|
1548
|
+
let scrollBufferTop = scrollBuffer;
|
|
1549
|
+
let scrollBufferBottom = scrollBuffer;
|
|
1550
|
+
if (speed > 0) {
|
|
1551
|
+
scrollBufferTop = scrollBuffer * 0.5;
|
|
1552
|
+
scrollBufferBottom = scrollBuffer * 1.5;
|
|
1574
1553
|
} else {
|
|
1575
|
-
|
|
1554
|
+
scrollBufferTop = scrollBuffer * 1.5;
|
|
1555
|
+
scrollBufferBottom = scrollBuffer * 0.5;
|
|
1556
|
+
}
|
|
1557
|
+
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1558
|
+
const scrollBottom = scroll + scrollLength;
|
|
1559
|
+
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1560
|
+
if (scrollForNextCalculateItemsInView) {
|
|
1561
|
+
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
1562
|
+
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
1563
|
+
return;
|
|
1564
|
+
}
|
|
1576
1565
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1566
|
+
let startNoBuffer = null;
|
|
1567
|
+
let startBuffered = null;
|
|
1568
|
+
let startBufferedId = null;
|
|
1569
|
+
let endNoBuffer = null;
|
|
1570
|
+
let endBuffered = null;
|
|
1571
|
+
let loopStart = startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
1572
|
+
if (minIndexSizeChanged !== void 0) {
|
|
1573
|
+
loopStart = Math.min(minIndexSizeChanged, loopStart);
|
|
1574
|
+
state.minIndexSizeChanged = void 0;
|
|
1575
|
+
}
|
|
1576
|
+
for (let i = loopStart; i >= 0; i--) {
|
|
1577
|
+
const id = (_a = idCache.get(i)) != null ? _a : getId(state, i);
|
|
1578
|
+
const top = positions.get(id);
|
|
1579
|
+
const size = (_b = sizes.get(id)) != null ? _b : getItemSize(state, id, i, data[i]);
|
|
1580
|
+
const bottom = top + size;
|
|
1581
|
+
if (bottom > scroll - scrollBuffer) {
|
|
1582
|
+
loopStart = i;
|
|
1583
|
+
} else {
|
|
1584
|
+
break;
|
|
1585
|
+
}
|
|
1591
1586
|
}
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1587
|
+
const loopStartMod = loopStart % numColumns;
|
|
1588
|
+
if (loopStartMod > 0) {
|
|
1589
|
+
loopStart -= loopStartMod;
|
|
1590
|
+
}
|
|
1591
|
+
let foundEnd = false;
|
|
1592
|
+
let nextTop;
|
|
1593
|
+
let nextBottom;
|
|
1594
|
+
let maxIndexRendered = 0;
|
|
1595
|
+
for (let i = 0; i < prevNumContainers; i++) {
|
|
1596
|
+
const key = peek$(ctx, `containerItemKey${i}`);
|
|
1597
|
+
if (key !== void 0) {
|
|
1598
|
+
const index = indexByKey.get(key);
|
|
1599
|
+
maxIndexRendered = Math.max(maxIndexRendered, index);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
let firstFullyOnScreenIndex;
|
|
1603
|
+
const dataLength = data.length;
|
|
1604
|
+
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
1605
|
+
const id = (_c = idCache.get(i)) != null ? _c : getId(state, i);
|
|
1606
|
+
const size = (_d = sizes.get(id)) != null ? _d : getItemSize(state, id, i, data[i]);
|
|
1607
|
+
const top = positions.get(id);
|
|
1608
|
+
if (!foundEnd) {
|
|
1609
|
+
if (startNoBuffer === null && top + size > scroll) {
|
|
1610
|
+
startNoBuffer = i;
|
|
1611
|
+
}
|
|
1612
|
+
if (firstFullyOnScreenIndex === void 0 && top >= scroll - 10) {
|
|
1613
|
+
firstFullyOnScreenIndex = i;
|
|
1614
1614
|
}
|
|
1615
|
-
if (top
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1615
|
+
if (startBuffered === null && top + size > scrollTopBuffered) {
|
|
1616
|
+
startBuffered = i;
|
|
1617
|
+
startBufferedId = id;
|
|
1618
|
+
nextTop = top;
|
|
1619
|
+
}
|
|
1620
|
+
if (startNoBuffer !== null) {
|
|
1621
|
+
if (top <= scrollBottom) {
|
|
1622
|
+
endNoBuffer = i;
|
|
1623
|
+
}
|
|
1624
|
+
if (top <= scrollBottomBuffered) {
|
|
1625
|
+
endBuffered = i;
|
|
1626
|
+
nextBottom = top + size;
|
|
1627
|
+
} else {
|
|
1628
|
+
foundEnd = true;
|
|
1629
|
+
}
|
|
1620
1630
|
}
|
|
1621
1631
|
}
|
|
1622
1632
|
}
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
idsInView.push(id);
|
|
1628
|
-
}
|
|
1629
|
-
Object.assign(state, {
|
|
1630
|
-
endBuffered,
|
|
1631
|
-
endNoBuffer,
|
|
1632
|
-
firstFullyOnScreenIndex,
|
|
1633
|
-
idsInView,
|
|
1634
|
-
startBuffered,
|
|
1635
|
-
startBufferedId,
|
|
1636
|
-
startNoBuffer
|
|
1637
|
-
});
|
|
1638
|
-
if (enableScrollForNextCalculateItemsInView && nextTop !== void 0 && nextBottom !== void 0) {
|
|
1639
|
-
state.scrollForNextCalculateItemsInView = nextTop !== void 0 && nextBottom !== void 0 ? {
|
|
1640
|
-
bottom: nextBottom,
|
|
1641
|
-
top: nextTop
|
|
1642
|
-
} : void 0;
|
|
1643
|
-
}
|
|
1644
|
-
const numContainers = peek$(ctx, "numContainers");
|
|
1645
|
-
const pendingRemoval = [];
|
|
1646
|
-
if (dataChanged) {
|
|
1647
|
-
for (let i = 0; i < numContainers; i++) {
|
|
1648
|
-
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1649
|
-
if (!state.props.keyExtractor || itemKey && indexByKey.get(itemKey) === void 0) {
|
|
1650
|
-
pendingRemoval.push(i);
|
|
1651
|
-
}
|
|
1633
|
+
const idsInView = [];
|
|
1634
|
+
for (let i = firstFullyOnScreenIndex; i <= endNoBuffer; i++) {
|
|
1635
|
+
const id = (_e = idCache.get(i)) != null ? _e : getId(state, i);
|
|
1636
|
+
idsInView.push(id);
|
|
1652
1637
|
}
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1638
|
+
Object.assign(state, {
|
|
1639
|
+
endBuffered,
|
|
1640
|
+
endNoBuffer,
|
|
1641
|
+
firstFullyOnScreenIndex,
|
|
1642
|
+
idsInView,
|
|
1643
|
+
startBuffered,
|
|
1644
|
+
startBufferedId,
|
|
1645
|
+
startNoBuffer
|
|
1646
|
+
});
|
|
1647
|
+
if (enableScrollForNextCalculateItemsInView && nextTop !== void 0 && nextBottom !== void 0) {
|
|
1648
|
+
state.scrollForNextCalculateItemsInView = nextTop !== void 0 && nextBottom !== void 0 ? {
|
|
1649
|
+
bottom: nextBottom,
|
|
1650
|
+
top: nextTop
|
|
1651
|
+
} : void 0;
|
|
1662
1652
|
}
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
pendingRemoval
|
|
1671
|
-
);
|
|
1672
|
-
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
1673
|
-
const i = needNewContainers[idx];
|
|
1674
|
-
const containerIndex = availableContainers[idx];
|
|
1675
|
-
const id = (_g = idCache.get(i)) != null ? _g : getId(state, i);
|
|
1676
|
-
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
1677
|
-
if (oldKey && oldKey !== id) {
|
|
1678
|
-
containerItemKeys.delete(oldKey);
|
|
1679
|
-
}
|
|
1680
|
-
set$(ctx, `containerItemKey${containerIndex}`, id);
|
|
1681
|
-
set$(ctx, `containerItemData${containerIndex}`, data[i]);
|
|
1682
|
-
containerItemKeys.add(id);
|
|
1683
|
-
if (containerIndex >= numContainers2) {
|
|
1684
|
-
numContainers2 = containerIndex + 1;
|
|
1685
|
-
}
|
|
1686
|
-
}
|
|
1687
|
-
if (numContainers2 !== prevNumContainers) {
|
|
1688
|
-
set$(ctx, "numContainers", numContainers2);
|
|
1689
|
-
if (numContainers2 > peek$(ctx, "numContainersPooled")) {
|
|
1690
|
-
set$(ctx, "numContainersPooled", Math.ceil(numContainers2 * 1.5));
|
|
1653
|
+
const numContainers = peek$(ctx, "numContainers");
|
|
1654
|
+
const pendingRemoval = [];
|
|
1655
|
+
if (dataChanged) {
|
|
1656
|
+
for (let i = 0; i < numContainers; i++) {
|
|
1657
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1658
|
+
if (!state.props.keyExtractor || itemKey && indexByKey.get(itemKey) === void 0) {
|
|
1659
|
+
pendingRemoval.push(i);
|
|
1691
1660
|
}
|
|
1692
1661
|
}
|
|
1693
1662
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
containerItemKeys.
|
|
1663
|
+
if (startBuffered !== null && endBuffered !== null) {
|
|
1664
|
+
let numContainers2 = prevNumContainers;
|
|
1665
|
+
const needNewContainers = [];
|
|
1666
|
+
for (let i = startBuffered; i <= endBuffered; i++) {
|
|
1667
|
+
const id = (_f = idCache.get(i)) != null ? _f : getId(state, i);
|
|
1668
|
+
if (!containerItemKeys.has(id)) {
|
|
1669
|
+
needNewContainers.push(i);
|
|
1670
|
+
}
|
|
1700
1671
|
}
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
const
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
1718
|
-
if (position > POSITION_OUT_OF_VIEW && position !== prevPos) {
|
|
1719
|
-
set$(ctx, `containerPosition${i}`, position);
|
|
1672
|
+
if (needNewContainers.length > 0) {
|
|
1673
|
+
const availableContainers = findAvailableContainers(
|
|
1674
|
+
ctx,
|
|
1675
|
+
state,
|
|
1676
|
+
needNewContainers.length,
|
|
1677
|
+
startBuffered,
|
|
1678
|
+
endBuffered,
|
|
1679
|
+
pendingRemoval
|
|
1680
|
+
);
|
|
1681
|
+
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
1682
|
+
const i = needNewContainers[idx];
|
|
1683
|
+
const containerIndex = availableContainers[idx];
|
|
1684
|
+
const id = (_g = idCache.get(i)) != null ? _g : getId(state, i);
|
|
1685
|
+
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
1686
|
+
if (oldKey && oldKey !== id) {
|
|
1687
|
+
containerItemKeys.delete(oldKey);
|
|
1720
1688
|
}
|
|
1721
|
-
|
|
1722
|
-
|
|
1689
|
+
set$(ctx, `containerItemKey${containerIndex}`, id);
|
|
1690
|
+
set$(ctx, `containerItemData${containerIndex}`, data[i]);
|
|
1691
|
+
containerItemKeys.add(id);
|
|
1692
|
+
if (containerIndex >= numContainers2) {
|
|
1693
|
+
numContainers2 = containerIndex + 1;
|
|
1723
1694
|
}
|
|
1724
|
-
|
|
1725
|
-
|
|
1695
|
+
}
|
|
1696
|
+
if (numContainers2 !== prevNumContainers) {
|
|
1697
|
+
set$(ctx, "numContainers", numContainers2);
|
|
1698
|
+
if (numContainers2 > peek$(ctx, "numContainersPooled")) {
|
|
1699
|
+
set$(ctx, "numContainersPooled", Math.ceil(numContainers2 * 1.5));
|
|
1726
1700
|
}
|
|
1727
1701
|
}
|
|
1728
1702
|
}
|
|
1729
1703
|
}
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1704
|
+
for (let i = 0; i < numContainers; i++) {
|
|
1705
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1706
|
+
if (pendingRemoval.includes(i)) {
|
|
1707
|
+
if (itemKey) {
|
|
1708
|
+
containerItemKeys.delete(itemKey);
|
|
1709
|
+
}
|
|
1710
|
+
set$(ctx, `containerItemKey${i}`, void 0);
|
|
1711
|
+
set$(ctx, `containerItemData${i}`, void 0);
|
|
1712
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1713
|
+
set$(ctx, `containerColumn${i}`, -1);
|
|
1714
|
+
} else {
|
|
1715
|
+
const itemIndex = indexByKey.get(itemKey);
|
|
1716
|
+
const item = data[itemIndex];
|
|
1717
|
+
if (item !== void 0) {
|
|
1718
|
+
const id = (_h = idCache.get(itemIndex)) != null ? _h : getId(state, itemIndex);
|
|
1719
|
+
const position = positions.get(id);
|
|
1720
|
+
if (position === void 0) {
|
|
1721
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1722
|
+
} else {
|
|
1723
|
+
const column = columns.get(id) || 1;
|
|
1724
|
+
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
1725
|
+
const prevColumn = peek$(ctx, `containerColumn${i}`);
|
|
1726
|
+
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
1727
|
+
if (position > POSITION_OUT_OF_VIEW && position !== prevPos) {
|
|
1728
|
+
set$(ctx, `containerPosition${i}`, position);
|
|
1729
|
+
}
|
|
1730
|
+
if (column >= 0 && column !== prevColumn) {
|
|
1731
|
+
set$(ctx, `containerColumn${i}`, column);
|
|
1732
|
+
}
|
|
1733
|
+
if (prevData !== item) {
|
|
1734
|
+
set$(ctx, `containerItemData${i}`, data[itemIndex]);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1734
1739
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1740
|
+
if (!queuedInitialLayout && endBuffered !== null) {
|
|
1741
|
+
if (checkAllSizesKnown(state)) {
|
|
1742
|
+
setDidLayout(ctx, state);
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
if (state.props.viewabilityConfigCallbackPairs) {
|
|
1746
|
+
updateViewableItems(
|
|
1747
|
+
state,
|
|
1748
|
+
ctx,
|
|
1749
|
+
state.props.viewabilityConfigCallbackPairs,
|
|
1750
|
+
scrollLength,
|
|
1751
|
+
startNoBuffer,
|
|
1752
|
+
endNoBuffer
|
|
1753
|
+
);
|
|
1754
|
+
}
|
|
1755
|
+
});
|
|
1746
1756
|
}
|
|
1747
1757
|
|
|
1748
1758
|
// src/core/doInitialAllocateContainers.ts
|
|
@@ -2016,32 +2026,20 @@ function updateItemSizes(ctx, state, itemUpdates) {
|
|
|
2016
2026
|
}
|
|
2017
2027
|
}
|
|
2018
2028
|
function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
let measured;
|
|
2031
|
-
containerRef.current.measure((x, y, width, height) => {
|
|
2032
|
-
measured = { height, width, x, y };
|
|
2033
|
-
});
|
|
2034
|
-
if (measured) {
|
|
2035
|
-
changes.push({ itemKey: containerItemKey, sizeObj: measured });
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
if (changes.length > 0) {
|
|
2041
|
-
updateItemSizes(ctx, state, changes);
|
|
2029
|
+
const { queuedItemSizeUpdates, queuedItemSizeUpdatesWaiting } = state;
|
|
2030
|
+
const containersDidLayout = peek$(ctx, "containersDidLayout");
|
|
2031
|
+
if (!containersDidLayout || !queuedItemSizeUpdatesWaiting) {
|
|
2032
|
+
updateItemSizes(ctx, state, [{ itemKey, sizeObj }]);
|
|
2033
|
+
if (containersDidLayout) {
|
|
2034
|
+
state.queuedItemSizeUpdatesWaiting = true;
|
|
2035
|
+
requestAnimationFrame(() => {
|
|
2036
|
+
state.queuedItemSizeUpdatesWaiting = false;
|
|
2037
|
+
updateItemSizes(ctx, state, queuedItemSizeUpdates);
|
|
2038
|
+
queuedItemSizeUpdates.length = 0;
|
|
2039
|
+
});
|
|
2042
2040
|
}
|
|
2043
2041
|
} else {
|
|
2044
|
-
|
|
2042
|
+
queuedItemSizeUpdates.push({ itemKey, sizeObj });
|
|
2045
2043
|
}
|
|
2046
2044
|
}
|
|
2047
2045
|
function updateOneItemSize(state, itemKey, sizeObj) {
|
|
@@ -2222,6 +2220,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2222
2220
|
positions: /* @__PURE__ */ new Map(),
|
|
2223
2221
|
props: {},
|
|
2224
2222
|
queuedCalculateItemsInView: 0,
|
|
2223
|
+
queuedItemSizeUpdates: [],
|
|
2225
2224
|
refScroller: void 0,
|
|
2226
2225
|
scroll: 0,
|
|
2227
2226
|
scrollAdjustHandler: new ScrollAdjustHandler(ctx),
|
|
@@ -2306,10 +2305,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2306
2305
|
set$(ctx, "lastItemKeys", memoizedLastItemKeys);
|
|
2307
2306
|
set$(ctx, "numColumns", numColumnsProp);
|
|
2308
2307
|
const prevPaddingTop = peek$(ctx, "stylePaddingTop");
|
|
2309
|
-
setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
|
|
2308
|
+
setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
|
|
2310
2309
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
2311
|
-
|
|
2310
|
+
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
2312
2311
|
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 && reactNative.Platform.OS === "ios") {
|
|
2312
|
+
if (state.scroll < 0) {
|
|
2313
|
+
paddingDiff += state.scroll;
|
|
2314
|
+
}
|
|
2313
2315
|
requestAdjust(ctx, state, paddingDiff);
|
|
2314
2316
|
}
|
|
2315
2317
|
};
|