@legendapp/list 2.0.0-next.5 → 2.0.0-next.7
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 +9 -1
- package/index.d.ts +9 -1
- package/index.js +280 -284
- package/index.mjs +281 -285
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -332,16 +332,18 @@ function useListScrollSize() {
|
|
|
332
332
|
const [scrollSize] = useArr$(["scrollSize"]);
|
|
333
333
|
return scrollSize;
|
|
334
334
|
}
|
|
335
|
+
var typedForwardRef = React3.forwardRef;
|
|
336
|
+
var typedMemo = React3.memo;
|
|
335
337
|
|
|
336
338
|
// src/components/Container.tsx
|
|
337
|
-
var Container = ({
|
|
339
|
+
var Container = typedMemo(function Container2({
|
|
338
340
|
id,
|
|
339
341
|
recycleItems,
|
|
340
342
|
horizontal,
|
|
341
343
|
getRenderedItem: getRenderedItem2,
|
|
342
344
|
updateItemSize: updateItemSize2,
|
|
343
345
|
ItemSeparatorComponent
|
|
344
|
-
})
|
|
346
|
+
}) {
|
|
345
347
|
const ctx = useStateContext();
|
|
346
348
|
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
347
349
|
const [column = 0, data, itemKey, position = POSITION_OUT_OF_VIEW, numColumns, extraData] = useArr$([
|
|
@@ -393,12 +395,17 @@ var Container = ({
|
|
|
393
395
|
[itemKey, data, extraData]
|
|
394
396
|
);
|
|
395
397
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
396
|
-
const triggerLayout = React3.useCallback(() => {
|
|
397
|
-
forceLayoutRender((v) => v + 1);
|
|
398
|
-
}, []);
|
|
399
398
|
const contextValue = React3.useMemo(() => {
|
|
400
399
|
ctx.viewRefs.set(id, ref);
|
|
401
|
-
return {
|
|
400
|
+
return {
|
|
401
|
+
containerId: id,
|
|
402
|
+
index,
|
|
403
|
+
itemKey,
|
|
404
|
+
triggerLayout: () => {
|
|
405
|
+
forceLayoutRender((v) => v + 1);
|
|
406
|
+
},
|
|
407
|
+
value: data
|
|
408
|
+
};
|
|
402
409
|
}, [id, itemKey, index, data]);
|
|
403
410
|
const onLayout = (event) => {
|
|
404
411
|
var _a, _b;
|
|
@@ -455,7 +462,7 @@ var Container = ({
|
|
|
455
462
|
leadingItem: renderedItemInfo.item
|
|
456
463
|
}
|
|
457
464
|
)));
|
|
458
|
-
};
|
|
465
|
+
});
|
|
459
466
|
var useAnimatedValue = (initialValue) => {
|
|
460
467
|
return React3.useRef(new reactNative.Animated.Value(initialValue)).current;
|
|
461
468
|
};
|
|
@@ -496,8 +503,6 @@ function useValue$(key, params) {
|
|
|
496
503
|
}, []);
|
|
497
504
|
return animValue;
|
|
498
505
|
}
|
|
499
|
-
var typedForwardRef = React3.forwardRef;
|
|
500
|
-
var typedMemo = React3.memo;
|
|
501
506
|
|
|
502
507
|
// src/components/Containers.tsx
|
|
503
508
|
var Containers = typedMemo(function Containers2({
|
|
@@ -590,13 +595,15 @@ function useSyncLayout({
|
|
|
590
595
|
},
|
|
591
596
|
[onChange]
|
|
592
597
|
);
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
ref.current
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
598
|
+
if (IsNewArchitecture) {
|
|
599
|
+
React3.useLayoutEffect(() => {
|
|
600
|
+
if (ref.current) {
|
|
601
|
+
ref.current.measure((x, y, width, height) => {
|
|
602
|
+
onChange({ height, width, x, y }, true);
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
}, []);
|
|
606
|
+
}
|
|
600
607
|
return { onLayout, ref };
|
|
601
608
|
}
|
|
602
609
|
|
|
@@ -763,7 +770,7 @@ function getItemSize(state, key, index, data, useAverageSize) {
|
|
|
763
770
|
return sizeKnown;
|
|
764
771
|
}
|
|
765
772
|
let size;
|
|
766
|
-
if (
|
|
773
|
+
if (useAverageSize !== void 0 && sizeKnown === void 0 && !getEstimatedItemSize && !scrollingTo) {
|
|
767
774
|
size = useAverageSize;
|
|
768
775
|
}
|
|
769
776
|
if (size === void 0) {
|
|
@@ -1479,266 +1486,267 @@ function setDidLayout(ctx, state) {
|
|
|
1479
1486
|
|
|
1480
1487
|
// src/core/calculateItemsInView.ts
|
|
1481
1488
|
function calculateItemsInView(ctx, state, params = {}) {
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
}
|
|
1501
|
-
const totalSize = peek$(ctx, "totalSize");
|
|
1502
|
-
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1503
|
-
const numColumns = peek$(ctx, "numColumns");
|
|
1504
|
-
const previousScrollAdjust = 0;
|
|
1505
|
-
const { dataChanged, doMVCP } = params;
|
|
1506
|
-
const speed = getScrollVelocity(state);
|
|
1507
|
-
if (doMVCP || dataChanged) {
|
|
1508
|
-
const checkMVCP = doMVCP ? prepareMVCP(ctx, state) : void 0;
|
|
1509
|
-
updateAllPositions(ctx, state, dataChanged);
|
|
1510
|
-
checkMVCP == null ? void 0 : checkMVCP();
|
|
1511
|
-
}
|
|
1512
|
-
const scrollExtra = 0;
|
|
1513
|
-
const { queuedInitialLayout } = state;
|
|
1514
|
-
let { scroll: scrollState } = state;
|
|
1515
|
-
const initialScroll = state.props.initialScroll;
|
|
1516
|
-
if (!queuedInitialLayout && initialScroll) {
|
|
1517
|
-
const updatedOffset = calculateOffsetWithOffsetPosition(
|
|
1518
|
-
state,
|
|
1519
|
-
calculateOffsetForIndex(ctx, state, initialScroll.index),
|
|
1520
|
-
initialScroll
|
|
1521
|
-
);
|
|
1522
|
-
scrollState = updatedOffset;
|
|
1523
|
-
}
|
|
1524
|
-
const scrollAdjustPad = -previousScrollAdjust - topPad;
|
|
1525
|
-
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1526
|
-
if (scroll + scrollLength > totalSize) {
|
|
1527
|
-
scroll = totalSize - scrollLength;
|
|
1528
|
-
}
|
|
1529
|
-
if (ENABLE_DEBUG_VIEW) {
|
|
1530
|
-
set$(ctx, "debugRawScroll", scrollState);
|
|
1531
|
-
set$(ctx, "debugComputedScroll", scroll);
|
|
1532
|
-
}
|
|
1533
|
-
const scrollBuffer = state.props.scrollBuffer;
|
|
1534
|
-
let scrollBufferTop = scrollBuffer;
|
|
1535
|
-
let scrollBufferBottom = scrollBuffer;
|
|
1536
|
-
if (speed > 0) {
|
|
1537
|
-
scrollBufferTop = scrollBuffer * 0.5;
|
|
1538
|
-
scrollBufferBottom = scrollBuffer * 1.5;
|
|
1539
|
-
} else {
|
|
1540
|
-
scrollBufferTop = scrollBuffer * 1.5;
|
|
1541
|
-
scrollBufferBottom = scrollBuffer * 0.5;
|
|
1542
|
-
}
|
|
1543
|
-
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1544
|
-
const scrollBottom = scroll + scrollLength;
|
|
1545
|
-
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1546
|
-
if (scrollForNextCalculateItemsInView) {
|
|
1547
|
-
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
1548
|
-
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
1489
|
+
reactNative.unstable_batchedUpdates(() => {
|
|
1490
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1491
|
+
const {
|
|
1492
|
+
scrollLength,
|
|
1493
|
+
startBufferedId: startBufferedIdOrig,
|
|
1494
|
+
positions,
|
|
1495
|
+
columns,
|
|
1496
|
+
containerItemKeys,
|
|
1497
|
+
idCache,
|
|
1498
|
+
sizes,
|
|
1499
|
+
indexByKey,
|
|
1500
|
+
scrollForNextCalculateItemsInView,
|
|
1501
|
+
enableScrollForNextCalculateItemsInView,
|
|
1502
|
+
minIndexSizeChanged
|
|
1503
|
+
} = state;
|
|
1504
|
+
const data = state.props.data;
|
|
1505
|
+
const prevNumContainers = peek$(ctx, "numContainers");
|
|
1506
|
+
if (!data || scrollLength === 0 || !prevNumContainers) {
|
|
1549
1507
|
return;
|
|
1550
1508
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1565
|
-
const
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1509
|
+
const totalSize = peek$(ctx, "totalSize");
|
|
1510
|
+
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1511
|
+
const numColumns = peek$(ctx, "numColumns");
|
|
1512
|
+
const previousScrollAdjust = 0;
|
|
1513
|
+
const { dataChanged, doMVCP } = params;
|
|
1514
|
+
const speed = getScrollVelocity(state);
|
|
1515
|
+
if (doMVCP || dataChanged) {
|
|
1516
|
+
const checkMVCP = doMVCP ? prepareMVCP(ctx, state) : void 0;
|
|
1517
|
+
updateAllPositions(ctx, state, dataChanged);
|
|
1518
|
+
checkMVCP == null ? void 0 : checkMVCP();
|
|
1519
|
+
}
|
|
1520
|
+
const scrollExtra = 0;
|
|
1521
|
+
const { queuedInitialLayout } = state;
|
|
1522
|
+
let { scroll: scrollState } = state;
|
|
1523
|
+
const initialScroll = state.props.initialScroll;
|
|
1524
|
+
if (!queuedInitialLayout && initialScroll) {
|
|
1525
|
+
const updatedOffset = calculateOffsetWithOffsetPosition(
|
|
1526
|
+
state,
|
|
1527
|
+
calculateOffsetForIndex(ctx, state, initialScroll.index),
|
|
1528
|
+
initialScroll
|
|
1529
|
+
);
|
|
1530
|
+
scrollState = updatedOffset;
|
|
1531
|
+
}
|
|
1532
|
+
const scrollAdjustPad = -previousScrollAdjust - topPad;
|
|
1533
|
+
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1534
|
+
if (scroll + scrollLength > totalSize) {
|
|
1535
|
+
scroll = totalSize - scrollLength;
|
|
1536
|
+
}
|
|
1537
|
+
if (ENABLE_DEBUG_VIEW) {
|
|
1538
|
+
set$(ctx, "debugRawScroll", scrollState);
|
|
1539
|
+
set$(ctx, "debugComputedScroll", scroll);
|
|
1540
|
+
}
|
|
1541
|
+
const scrollBuffer = state.props.scrollBuffer;
|
|
1542
|
+
let scrollBufferTop = scrollBuffer;
|
|
1543
|
+
let scrollBufferBottom = scrollBuffer;
|
|
1544
|
+
if (speed > 0) {
|
|
1545
|
+
scrollBufferTop = scrollBuffer * 0.5;
|
|
1546
|
+
scrollBufferBottom = scrollBuffer * 1.5;
|
|
1569
1547
|
} else {
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
let maxIndexRendered = 0;
|
|
1581
|
-
for (let i = 0; i < prevNumContainers; i++) {
|
|
1582
|
-
const key = peek$(ctx, `containerItemKey${i}`);
|
|
1583
|
-
if (key !== void 0) {
|
|
1584
|
-
const index = indexByKey.get(key);
|
|
1585
|
-
maxIndexRendered = Math.max(maxIndexRendered, index);
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
1588
|
-
let firstFullyOnScreenIndex;
|
|
1589
|
-
const dataLength = data.length;
|
|
1590
|
-
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
1591
|
-
const id = (_c = idCache.get(i)) != null ? _c : getId(state, i);
|
|
1592
|
-
const size = (_d = sizes.get(id)) != null ? _d : getItemSize(state, id, i, data[i]);
|
|
1593
|
-
const top = positions.get(id);
|
|
1594
|
-
if (!foundEnd) {
|
|
1595
|
-
if (startNoBuffer === null && top + size > scroll) {
|
|
1596
|
-
startNoBuffer = i;
|
|
1597
|
-
}
|
|
1598
|
-
if (firstFullyOnScreenIndex === void 0 && top >= scroll - 10) {
|
|
1599
|
-
firstFullyOnScreenIndex = i;
|
|
1548
|
+
scrollBufferTop = scrollBuffer * 1.5;
|
|
1549
|
+
scrollBufferBottom = scrollBuffer * 0.5;
|
|
1550
|
+
}
|
|
1551
|
+
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1552
|
+
const scrollBottom = scroll + scrollLength;
|
|
1553
|
+
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1554
|
+
if (scrollForNextCalculateItemsInView) {
|
|
1555
|
+
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
1556
|
+
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
1557
|
+
return;
|
|
1600
1558
|
}
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1559
|
+
}
|
|
1560
|
+
let startNoBuffer = null;
|
|
1561
|
+
let startBuffered = null;
|
|
1562
|
+
let startBufferedId = null;
|
|
1563
|
+
let endNoBuffer = null;
|
|
1564
|
+
let endBuffered = null;
|
|
1565
|
+
let loopStart = startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
1566
|
+
if (minIndexSizeChanged !== void 0) {
|
|
1567
|
+
loopStart = Math.min(minIndexSizeChanged, loopStart);
|
|
1568
|
+
state.minIndexSizeChanged = void 0;
|
|
1569
|
+
}
|
|
1570
|
+
for (let i = loopStart; i >= 0; i--) {
|
|
1571
|
+
const id = (_a = idCache.get(i)) != null ? _a : getId(state, i);
|
|
1572
|
+
const top = positions.get(id);
|
|
1573
|
+
const size = (_b = sizes.get(id)) != null ? _b : getItemSize(state, id, i, data[i]);
|
|
1574
|
+
const bottom = top + size;
|
|
1575
|
+
if (bottom > scroll - scrollBuffer) {
|
|
1576
|
+
loopStart = i;
|
|
1577
|
+
} else {
|
|
1578
|
+
break;
|
|
1605
1579
|
}
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1580
|
+
}
|
|
1581
|
+
const loopStartMod = loopStart % numColumns;
|
|
1582
|
+
if (loopStartMod > 0) {
|
|
1583
|
+
loopStart -= loopStartMod;
|
|
1584
|
+
}
|
|
1585
|
+
let foundEnd = false;
|
|
1586
|
+
let nextTop;
|
|
1587
|
+
let nextBottom;
|
|
1588
|
+
let maxIndexRendered = 0;
|
|
1589
|
+
for (let i = 0; i < prevNumContainers; i++) {
|
|
1590
|
+
const key = peek$(ctx, `containerItemKey${i}`);
|
|
1591
|
+
if (key !== void 0) {
|
|
1592
|
+
const index = indexByKey.get(key);
|
|
1593
|
+
maxIndexRendered = Math.max(maxIndexRendered, index);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
let firstFullyOnScreenIndex;
|
|
1597
|
+
const dataLength = data.length;
|
|
1598
|
+
for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
|
|
1599
|
+
const id = (_c = idCache.get(i)) != null ? _c : getId(state, i);
|
|
1600
|
+
const size = (_d = sizes.get(id)) != null ? _d : getItemSize(state, id, i, data[i]);
|
|
1601
|
+
const top = positions.get(id);
|
|
1602
|
+
if (!foundEnd) {
|
|
1603
|
+
if (startNoBuffer === null && top + size > scroll) {
|
|
1604
|
+
startNoBuffer = i;
|
|
1605
|
+
}
|
|
1606
|
+
if (firstFullyOnScreenIndex === void 0 && top >= scroll - 10) {
|
|
1607
|
+
firstFullyOnScreenIndex = i;
|
|
1609
1608
|
}
|
|
1610
|
-
if (top
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1609
|
+
if (startBuffered === null && top + size > scrollTopBuffered) {
|
|
1610
|
+
startBuffered = i;
|
|
1611
|
+
startBufferedId = id;
|
|
1612
|
+
nextTop = top;
|
|
1613
|
+
}
|
|
1614
|
+
if (startNoBuffer !== null) {
|
|
1615
|
+
if (top <= scrollBottom) {
|
|
1616
|
+
endNoBuffer = i;
|
|
1617
|
+
}
|
|
1618
|
+
if (top <= scrollBottomBuffered) {
|
|
1619
|
+
endBuffered = i;
|
|
1620
|
+
nextBottom = top + size;
|
|
1621
|
+
} else {
|
|
1622
|
+
foundEnd = true;
|
|
1623
|
+
}
|
|
1615
1624
|
}
|
|
1616
1625
|
}
|
|
1617
1626
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
idsInView.push(id);
|
|
1623
|
-
}
|
|
1624
|
-
Object.assign(state, {
|
|
1625
|
-
endBuffered,
|
|
1626
|
-
endNoBuffer,
|
|
1627
|
-
firstFullyOnScreenIndex,
|
|
1628
|
-
idsInView,
|
|
1629
|
-
startBuffered,
|
|
1630
|
-
startBufferedId,
|
|
1631
|
-
startNoBuffer
|
|
1632
|
-
});
|
|
1633
|
-
if (enableScrollForNextCalculateItemsInView && nextTop !== void 0 && nextBottom !== void 0) {
|
|
1634
|
-
state.scrollForNextCalculateItemsInView = nextTop !== void 0 && nextBottom !== void 0 ? {
|
|
1635
|
-
bottom: nextBottom,
|
|
1636
|
-
top: nextTop
|
|
1637
|
-
} : void 0;
|
|
1638
|
-
}
|
|
1639
|
-
const numContainers = peek$(ctx, "numContainers");
|
|
1640
|
-
const pendingRemoval = [];
|
|
1641
|
-
if (dataChanged) {
|
|
1642
|
-
for (let i = 0; i < numContainers; i++) {
|
|
1643
|
-
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1644
|
-
if (!state.props.keyExtractor || itemKey && indexByKey.get(itemKey) === void 0) {
|
|
1645
|
-
pendingRemoval.push(i);
|
|
1646
|
-
}
|
|
1627
|
+
const idsInView = [];
|
|
1628
|
+
for (let i = firstFullyOnScreenIndex; i <= endNoBuffer; i++) {
|
|
1629
|
+
const id = (_e = idCache.get(i)) != null ? _e : getId(state, i);
|
|
1630
|
+
idsInView.push(id);
|
|
1647
1631
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1632
|
+
Object.assign(state, {
|
|
1633
|
+
endBuffered,
|
|
1634
|
+
endNoBuffer,
|
|
1635
|
+
firstFullyOnScreenIndex,
|
|
1636
|
+
idsInView,
|
|
1637
|
+
startBuffered,
|
|
1638
|
+
startBufferedId,
|
|
1639
|
+
startNoBuffer
|
|
1640
|
+
});
|
|
1641
|
+
if (enableScrollForNextCalculateItemsInView && nextTop !== void 0 && nextBottom !== void 0) {
|
|
1642
|
+
state.scrollForNextCalculateItemsInView = nextTop !== void 0 && nextBottom !== void 0 ? {
|
|
1643
|
+
bottom: nextBottom,
|
|
1644
|
+
top: nextTop
|
|
1645
|
+
} : void 0;
|
|
1657
1646
|
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
pendingRemoval
|
|
1666
|
-
);
|
|
1667
|
-
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
1668
|
-
const i = needNewContainers[idx];
|
|
1669
|
-
const containerIndex = availableContainers[idx];
|
|
1670
|
-
const id = (_g = idCache.get(i)) != null ? _g : getId(state, i);
|
|
1671
|
-
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
1672
|
-
if (oldKey && oldKey !== id) {
|
|
1673
|
-
containerItemKeys.delete(oldKey);
|
|
1674
|
-
}
|
|
1675
|
-
set$(ctx, `containerItemKey${containerIndex}`, id);
|
|
1676
|
-
set$(ctx, `containerItemData${containerIndex}`, data[i]);
|
|
1677
|
-
containerItemKeys.add(id);
|
|
1678
|
-
if (containerIndex >= numContainers2) {
|
|
1679
|
-
numContainers2 = containerIndex + 1;
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
if (numContainers2 !== prevNumContainers) {
|
|
1683
|
-
set$(ctx, "numContainers", numContainers2);
|
|
1684
|
-
if (numContainers2 > peek$(ctx, "numContainersPooled")) {
|
|
1685
|
-
set$(ctx, "numContainersPooled", Math.ceil(numContainers2 * 1.5));
|
|
1647
|
+
const numContainers = peek$(ctx, "numContainers");
|
|
1648
|
+
const pendingRemoval = [];
|
|
1649
|
+
if (dataChanged) {
|
|
1650
|
+
for (let i = 0; i < numContainers; i++) {
|
|
1651
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1652
|
+
if (!state.props.keyExtractor || itemKey && indexByKey.get(itemKey) === void 0) {
|
|
1653
|
+
pendingRemoval.push(i);
|
|
1686
1654
|
}
|
|
1687
1655
|
}
|
|
1688
1656
|
}
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
containerItemKeys.
|
|
1657
|
+
if (startBuffered !== null && endBuffered !== null) {
|
|
1658
|
+
let numContainers2 = prevNumContainers;
|
|
1659
|
+
const needNewContainers = [];
|
|
1660
|
+
for (let i = startBuffered; i <= endBuffered; i++) {
|
|
1661
|
+
const id = (_f = idCache.get(i)) != null ? _f : getId(state, i);
|
|
1662
|
+
if (!containerItemKeys.has(id)) {
|
|
1663
|
+
needNewContainers.push(i);
|
|
1664
|
+
}
|
|
1695
1665
|
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
const
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
const prevColumn = peek$(ctx, `containerColumn${i}`);
|
|
1713
|
-
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
1714
|
-
if (!prevPos || pos > POSITION_OUT_OF_VIEW && pos !== prevPos) {
|
|
1715
|
-
set$(ctx, `containerPosition${i}`, pos);
|
|
1666
|
+
if (needNewContainers.length > 0) {
|
|
1667
|
+
const availableContainers = findAvailableContainers(
|
|
1668
|
+
ctx,
|
|
1669
|
+
state,
|
|
1670
|
+
needNewContainers.length,
|
|
1671
|
+
startBuffered,
|
|
1672
|
+
endBuffered,
|
|
1673
|
+
pendingRemoval
|
|
1674
|
+
);
|
|
1675
|
+
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
1676
|
+
const i = needNewContainers[idx];
|
|
1677
|
+
const containerIndex = availableContainers[idx];
|
|
1678
|
+
const id = (_g = idCache.get(i)) != null ? _g : getId(state, i);
|
|
1679
|
+
const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
1680
|
+
if (oldKey && oldKey !== id) {
|
|
1681
|
+
containerItemKeys.delete(oldKey);
|
|
1716
1682
|
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1683
|
+
set$(ctx, `containerItemKey${containerIndex}`, id);
|
|
1684
|
+
set$(ctx, `containerItemData${containerIndex}`, data[i]);
|
|
1685
|
+
containerItemKeys.add(id);
|
|
1686
|
+
if (containerIndex >= numContainers2) {
|
|
1687
|
+
numContainers2 = containerIndex + 1;
|
|
1719
1688
|
}
|
|
1720
|
-
|
|
1721
|
-
|
|
1689
|
+
}
|
|
1690
|
+
if (numContainers2 !== prevNumContainers) {
|
|
1691
|
+
set$(ctx, "numContainers", numContainers2);
|
|
1692
|
+
if (numContainers2 > peek$(ctx, "numContainersPooled")) {
|
|
1693
|
+
set$(ctx, "numContainersPooled", Math.ceil(numContainers2 * 1.5));
|
|
1722
1694
|
}
|
|
1723
1695
|
}
|
|
1724
1696
|
}
|
|
1725
1697
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1698
|
+
for (let i = 0; i < numContainers; i++) {
|
|
1699
|
+
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1700
|
+
if (pendingRemoval.includes(i)) {
|
|
1701
|
+
if (itemKey) {
|
|
1702
|
+
containerItemKeys.delete(itemKey);
|
|
1703
|
+
}
|
|
1704
|
+
set$(ctx, `containerItemKey${i}`, void 0);
|
|
1705
|
+
set$(ctx, `containerItemData${i}`, void 0);
|
|
1706
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1707
|
+
set$(ctx, `containerColumn${i}`, -1);
|
|
1708
|
+
} else {
|
|
1709
|
+
const itemIndex = indexByKey.get(itemKey);
|
|
1710
|
+
const item = data[itemIndex];
|
|
1711
|
+
if (item !== void 0) {
|
|
1712
|
+
const id = (_h = idCache.get(itemIndex)) != null ? _h : getId(state, itemIndex);
|
|
1713
|
+
const position = positions.get(id);
|
|
1714
|
+
if (position === void 0) {
|
|
1715
|
+
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1716
|
+
} else {
|
|
1717
|
+
const column = columns.get(id) || 1;
|
|
1718
|
+
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
1719
|
+
const prevColumn = peek$(ctx, `containerColumn${i}`);
|
|
1720
|
+
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
1721
|
+
if (position > POSITION_OUT_OF_VIEW && position !== prevPos) {
|
|
1722
|
+
set$(ctx, `containerPosition${i}`, position);
|
|
1723
|
+
}
|
|
1724
|
+
if (column >= 0 && column !== prevColumn) {
|
|
1725
|
+
set$(ctx, `containerColumn${i}`, column);
|
|
1726
|
+
}
|
|
1727
|
+
if (prevData !== item) {
|
|
1728
|
+
set$(ctx, `containerItemData${i}`, data[itemIndex]);
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1730
1733
|
}
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1734
|
+
if (!queuedInitialLayout && endBuffered !== null) {
|
|
1735
|
+
if (checkAllSizesKnown(state)) {
|
|
1736
|
+
setDidLayout(ctx, state);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
if (state.props.viewabilityConfigCallbackPairs) {
|
|
1740
|
+
updateViewableItems(
|
|
1741
|
+
state,
|
|
1742
|
+
ctx,
|
|
1743
|
+
state.props.viewabilityConfigCallbackPairs,
|
|
1744
|
+
scrollLength,
|
|
1745
|
+
startNoBuffer,
|
|
1746
|
+
endNoBuffer
|
|
1747
|
+
);
|
|
1748
|
+
}
|
|
1749
|
+
});
|
|
1742
1750
|
}
|
|
1743
1751
|
|
|
1744
1752
|
// src/core/doInitialAllocateContainers.ts
|
|
@@ -2012,32 +2020,20 @@ function updateItemSizes(ctx, state, itemUpdates) {
|
|
|
2012
2020
|
}
|
|
2013
2021
|
}
|
|
2014
2022
|
function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
let measured;
|
|
2027
|
-
containerRef.current.measure((x, y, width, height) => {
|
|
2028
|
-
measured = { height, width, x, y };
|
|
2029
|
-
});
|
|
2030
|
-
if (measured) {
|
|
2031
|
-
changes.push({ itemKey: containerItemKey, sizeObj: measured });
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
if (changes.length > 0) {
|
|
2037
|
-
updateItemSizes(ctx, state, changes);
|
|
2023
|
+
const { queuedItemSizeUpdates, queuedItemSizeUpdatesWaiting } = state;
|
|
2024
|
+
const containersDidLayout = peek$(ctx, "containersDidLayout");
|
|
2025
|
+
if (!containersDidLayout || !queuedItemSizeUpdatesWaiting) {
|
|
2026
|
+
updateItemSizes(ctx, state, [{ itemKey, sizeObj }]);
|
|
2027
|
+
if (containersDidLayout) {
|
|
2028
|
+
state.queuedItemSizeUpdatesWaiting = true;
|
|
2029
|
+
requestAnimationFrame(() => {
|
|
2030
|
+
state.queuedItemSizeUpdatesWaiting = false;
|
|
2031
|
+
updateItemSizes(ctx, state, queuedItemSizeUpdates);
|
|
2032
|
+
queuedItemSizeUpdates.length = 0;
|
|
2033
|
+
});
|
|
2038
2034
|
}
|
|
2039
2035
|
} else {
|
|
2040
|
-
|
|
2036
|
+
queuedItemSizeUpdates.push({ itemKey, sizeObj });
|
|
2041
2037
|
}
|
|
2042
2038
|
}
|
|
2043
2039
|
function updateOneItemSize(state, itemKey, sizeObj) {
|
|
@@ -2218,6 +2214,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2218
2214
|
positions: /* @__PURE__ */ new Map(),
|
|
2219
2215
|
props: {},
|
|
2220
2216
|
queuedCalculateItemsInView: 0,
|
|
2217
|
+
queuedItemSizeUpdates: [],
|
|
2221
2218
|
refScroller: void 0,
|
|
2222
2219
|
scroll: 0,
|
|
2223
2220
|
scrollAdjustHandler: new ScrollAdjustHandler(ctx),
|
|
@@ -2298,20 +2295,19 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2298
2295
|
(_, i) => getId(state, dataProp.length - 1 - i)
|
|
2299
2296
|
);
|
|
2300
2297
|
}, [dataProp, numColumnsProp]);
|
|
2301
|
-
const
|
|
2298
|
+
const initializeStateVars = () => {
|
|
2302
2299
|
set$(ctx, "lastItemKeys", memoizedLastItemKeys);
|
|
2303
2300
|
set$(ctx, "numColumns", numColumnsProp);
|
|
2304
2301
|
const prevPaddingTop = peek$(ctx, "stylePaddingTop");
|
|
2305
2302
|
setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
|
|
2306
2303
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
2307
2304
|
const paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
2308
|
-
if (paddingDiff && prevPaddingTop !== void 0 && reactNative.Platform.OS === "ios") {
|
|
2309
|
-
calculateItemsInView(ctx, state, { doMVCP: true });
|
|
2305
|
+
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 && reactNative.Platform.OS === "ios") {
|
|
2310
2306
|
requestAdjust(ctx, state, paddingDiff);
|
|
2311
2307
|
}
|
|
2312
2308
|
};
|
|
2313
2309
|
if (isFirst) {
|
|
2314
|
-
|
|
2310
|
+
initializeStateVars();
|
|
2315
2311
|
updateAllPositions(ctx, state);
|
|
2316
2312
|
}
|
|
2317
2313
|
const initialContentOffset = React3.useMemo(() => {
|
|
@@ -2382,7 +2378,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2382
2378
|
React3.useLayoutEffect(() => {
|
|
2383
2379
|
set$(ctx, "extraData", extraData);
|
|
2384
2380
|
}, [extraData]);
|
|
2385
|
-
React3.useLayoutEffect(
|
|
2381
|
+
React3.useLayoutEffect(initializeStateVars, [
|
|
2386
2382
|
memoizedLastItemKeys.join(","),
|
|
2387
2383
|
numColumnsProp,
|
|
2388
2384
|
stylePaddingTopState,
|