@legendapp/list 3.3.5 → 3.3.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/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/react-native.js +291 -170
- package/react-native.mjs +291 -170
- package/react-native.web.js +272 -152
- package/react-native.web.mjs +272 -152
- package/react.js +272 -152
- package/react.mjs +272 -152
- package/.DS_Store +0 -0
package/react-native.js
CHANGED
|
@@ -68,10 +68,6 @@ function getStylePaddingEnd(props) {
|
|
|
68
68
|
}
|
|
69
69
|
return (isHorizontalRTLProps(props) ? props.stylePaddingLeft : props.stylePaddingRight) || 0;
|
|
70
70
|
}
|
|
71
|
-
function getLogicalHorizontalMaxOffset(state, contentWidth) {
|
|
72
|
-
var _a3;
|
|
73
|
-
return (_a3 = getHorizontalMaxOffset(state, contentWidth)) != null ? _a3 : 0;
|
|
74
|
-
}
|
|
75
71
|
function getHorizontalInsetEnd(state, inset) {
|
|
76
72
|
if (!inset) {
|
|
77
73
|
return 0;
|
|
@@ -405,6 +401,7 @@ var IsNewArchitecture = f !== void 0 && f != null;
|
|
|
405
401
|
// src/core/containerItemMetadata.ts
|
|
406
402
|
function createContainerItemMetadata(state, itemIndex, itemData, itemType) {
|
|
407
403
|
return {
|
|
404
|
+
data: state.props.data,
|
|
408
405
|
dataChangeEpoch: state.dataChangeEpoch,
|
|
409
406
|
getFixedItemSize: state.props.getFixedItemSize,
|
|
410
407
|
getItemType: state.props.getItemType,
|
|
@@ -413,25 +410,29 @@ function createContainerItemMetadata(state, itemIndex, itemData, itemType) {
|
|
|
413
410
|
itemType
|
|
414
411
|
};
|
|
415
412
|
}
|
|
416
|
-
function
|
|
417
|
-
var _a3
|
|
418
|
-
const {
|
|
413
|
+
function updateContainerItemMetadata(state, containerId, itemIndex, itemData, itemType) {
|
|
414
|
+
var _a3;
|
|
415
|
+
const { getItemType } = state.props;
|
|
419
416
|
const previousMetadata = state.containerItemMetadata.get(containerId);
|
|
420
|
-
let metadata;
|
|
421
417
|
if ((previousMetadata == null ? void 0 : previousMetadata.dataChangeEpoch) === state.dataChangeEpoch && previousMetadata.getItemType === getItemType && previousMetadata.itemData === itemData && previousMetadata.itemIndex === itemIndex) {
|
|
422
|
-
|
|
423
|
-
} else {
|
|
424
|
-
const itemType = getItemType ? (_a3 = getItemType(itemData, itemIndex)) != null ? _a3 : "" : void 0;
|
|
425
|
-
metadata = createContainerItemMetadata(state, itemIndex, itemData, itemType);
|
|
426
|
-
state.containerItemMetadata.set(containerId, metadata);
|
|
418
|
+
return previousMetadata;
|
|
427
419
|
}
|
|
420
|
+
const resolvedItemType = getItemType ? (_a3 = getItemType(itemData, itemIndex)) != null ? _a3 : "" : void 0;
|
|
421
|
+
const metadata = createContainerItemMetadata(state, itemIndex, itemData, resolvedItemType);
|
|
422
|
+
state.containerItemMetadata.set(containerId, metadata);
|
|
423
|
+
return metadata;
|
|
424
|
+
}
|
|
425
|
+
function resolveContainerItemMetadata(state, containerId, itemIndex, itemData) {
|
|
426
|
+
var _a3;
|
|
427
|
+
const { getFixedItemSize } = state.props;
|
|
428
|
+
const metadata = updateContainerItemMetadata(state, containerId, itemIndex, itemData);
|
|
428
429
|
if (metadata.getFixedItemSize !== getFixedItemSize) {
|
|
429
430
|
metadata.didResolveFixedItemSize = false;
|
|
430
431
|
metadata.fixedItemSize = void 0;
|
|
431
432
|
metadata.getFixedItemSize = getFixedItemSize;
|
|
432
433
|
}
|
|
433
434
|
if (getFixedItemSize && !metadata.didResolveFixedItemSize) {
|
|
434
|
-
metadata.fixedItemSize = getFixedItemSize(itemData, itemIndex, (
|
|
435
|
+
metadata.fixedItemSize = getFixedItemSize(itemData, itemIndex, (_a3 = metadata.itemType) != null ? _a3 : "");
|
|
435
436
|
metadata.didResolveFixedItemSize = true;
|
|
436
437
|
}
|
|
437
438
|
return metadata;
|
|
@@ -733,6 +734,12 @@ function checkAtBottom(ctx, allowedEdge, allowGateCreatedInCurrentCheck) {
|
|
|
733
734
|
} = state;
|
|
734
735
|
const contentSize = getContentSize(ctx);
|
|
735
736
|
resetSharedEdgeGateIfOutsideHysteresis(ctx);
|
|
737
|
+
if (state.props.data.length === 0 && scrollLength > 0 && contentSize <= scrollLength) {
|
|
738
|
+
set$(ctx, "isAtEnd", true);
|
|
739
|
+
set$(ctx, "isNearEnd", true);
|
|
740
|
+
set$(ctx, "isWithinMaintainScrollAtEndThreshold", true);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
736
743
|
if (contentSize > 0 && queuedInitialLayout) {
|
|
737
744
|
const insetEnd = getContentInsetEnd(ctx);
|
|
738
745
|
const distanceFromEnd = contentSize - scroll - scrollLength - insetEnd;
|
|
@@ -742,7 +749,7 @@ function checkAtBottom(ctx, allowedEdge, allowGateCreatedInCurrentCheck) {
|
|
|
742
749
|
set$(
|
|
743
750
|
ctx,
|
|
744
751
|
"isWithinMaintainScrollAtEndThreshold",
|
|
745
|
-
isContentLess || distanceFromEnd <= maintainScrollAtEndThreshold * scrollLength
|
|
752
|
+
isContentLess || distanceFromEnd <= maintainScrollAtEndThreshold * scrollLength || state.pendingMaintainScrollAtEnd || maintainingScrollAtEnd === "animated" || maintainingScrollAtEnd === "instant"
|
|
746
753
|
);
|
|
747
754
|
const shouldSkipThresholdChecks = hasActiveInitialScroll(state) || maintainingScrollAtEnd;
|
|
748
755
|
if (!shouldSkipThresholdChecks) {
|
|
@@ -1093,10 +1100,22 @@ function getAlignItemsAtEndPadding(ctx) {
|
|
|
1093
1100
|
return shouldPad ? Math.max(0, state.scrollLength - getRawContentLength(ctx) - getContentInsetEnd(ctx)) : 0;
|
|
1094
1101
|
}
|
|
1095
1102
|
function updateContentMetricsState(ctx) {
|
|
1103
|
+
var _a3;
|
|
1104
|
+
const { state } = ctx;
|
|
1096
1105
|
const previousPadding = peek$(ctx, "alignItemsAtEndPadding") || 0;
|
|
1097
1106
|
const nextPadding = getAlignItemsAtEndPadding(ctx);
|
|
1098
1107
|
if (previousPadding !== nextPadding) {
|
|
1099
|
-
|
|
1108
|
+
const isAnimatedMaintainActive = state.maintainingScrollAtEnd === "pending-animated" || state.maintainingScrollAtEnd === "animated";
|
|
1109
|
+
const isMaintainExpected = state.didContainersLayout && ((_a3 = state.props.maintainScrollAtEnd) == null ? void 0 : _a3.animated) && (isAnimatedMaintainActive || previousPadding > nextPadding && peek$(ctx, "isWithinMaintainScrollAtEndThreshold"));
|
|
1110
|
+
if (isMaintainExpected && !isAnimatedMaintainActive && !state.pendingMaintainScrollAtEnd) {
|
|
1111
|
+
state.scheduledWork.microtask(() => {
|
|
1112
|
+
if (!state.maintainingScrollAtEnd && !state.pendingMaintainScrollAtEnd) {
|
|
1113
|
+
set$(ctx, "alignItemsAtEndPadding", getAlignItemsAtEndPadding(ctx));
|
|
1114
|
+
}
|
|
1115
|
+
}, "alignItemsAtEndPaddingFallback");
|
|
1116
|
+
} else if (!isMaintainExpected) {
|
|
1117
|
+
set$(ctx, "alignItemsAtEndPadding", nextPadding);
|
|
1118
|
+
}
|
|
1100
1119
|
}
|
|
1101
1120
|
}
|
|
1102
1121
|
|
|
@@ -1549,81 +1568,55 @@ function doScrollTo(ctx, params) {
|
|
|
1549
1568
|
}
|
|
1550
1569
|
}
|
|
1551
1570
|
|
|
1552
|
-
// src/core/
|
|
1553
|
-
function
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
if (!state.maintainingScrollAtEnd) {
|
|
1574
|
-
const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
|
|
1575
|
-
const activeState = maintainScrollAtEnd.animated ? "animated" : "instant";
|
|
1576
|
-
const scrollAtRequest = state.scroll;
|
|
1577
|
-
state.maintainingScrollAtEnd = pendingState;
|
|
1578
|
-
requestAnimationFrame(() => {
|
|
1579
|
-
const isStillWithinThreshold = peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
|
|
1580
|
-
const didScrollSinceRequest = state.scroll !== scrollAtRequest;
|
|
1581
|
-
if (isStillWithinThreshold || !didScrollSinceRequest) {
|
|
1582
|
-
state.maintainingScrollAtEnd = activeState;
|
|
1583
|
-
const scroller = refScroller.current;
|
|
1584
|
-
if (state.props.horizontal && isHorizontalRTL(state)) {
|
|
1585
|
-
const currentContentSize = getContentSize(ctx);
|
|
1586
|
-
const logicalEndOffset = getLogicalHorizontalMaxOffset(state, currentContentSize);
|
|
1587
|
-
const nativeOffset = toNativeHorizontalOffset(state, logicalEndOffset, currentContentSize);
|
|
1588
|
-
scroller == null ? void 0 : scroller.scrollTo({
|
|
1589
|
-
animated: maintainScrollAtEnd.animated,
|
|
1590
|
-
x: nativeOffset,
|
|
1591
|
-
y: 0
|
|
1592
|
-
});
|
|
1593
|
-
} else {
|
|
1594
|
-
scroller == null ? void 0 : scroller.scrollToEnd({
|
|
1595
|
-
animated: maintainScrollAtEnd.animated
|
|
1596
|
-
});
|
|
1597
|
-
}
|
|
1598
|
-
setTimeout(
|
|
1599
|
-
() => {
|
|
1600
|
-
if (state.maintainingScrollAtEnd === activeState) {
|
|
1601
|
-
state.maintainingScrollAtEnd = void 0;
|
|
1602
|
-
if (state.pendingMaintainScrollAtEnd) {
|
|
1603
|
-
doMaintainScrollAtEnd(ctx);
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
},
|
|
1607
|
-
maintainScrollAtEnd.animated ? 500 : 0
|
|
1608
|
-
);
|
|
1609
|
-
} else if (state.maintainingScrollAtEnd === pendingState) {
|
|
1610
|
-
state.maintainingScrollAtEnd = void 0;
|
|
1611
|
-
state.pendingMaintainScrollAtEnd = false;
|
|
1571
|
+
// src/core/scrollRequestTracker.ts
|
|
1572
|
+
function getScrollRequestTracker(ctx) {
|
|
1573
|
+
if (!ctx.scrollRequestTracker) {
|
|
1574
|
+
let currentToken = 0;
|
|
1575
|
+
const start = (resolve) => {
|
|
1576
|
+
const state = ctx.state;
|
|
1577
|
+
state.scheduledWork.cancel("imperativeScrollReady");
|
|
1578
|
+
const token = ++currentToken;
|
|
1579
|
+
settlePendingImperativeScroll(state);
|
|
1580
|
+
state.pendingScrollResolve = resolve;
|
|
1581
|
+
return token;
|
|
1582
|
+
};
|
|
1583
|
+
const runNow = (token, resolve, run) => {
|
|
1584
|
+
const state = ctx.state;
|
|
1585
|
+
if (token !== currentToken) {
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1588
|
+
const didStartScroll = run();
|
|
1589
|
+
if (!didStartScroll || !state.scrollingTo) {
|
|
1590
|
+
if (state.pendingScrollResolve === resolve) {
|
|
1591
|
+
state.pendingScrollResolve = void 0;
|
|
1612
1592
|
}
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1593
|
+
resolve();
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
ctx.scrollRequestTracker = {
|
|
1597
|
+
isCurrent: (token) => token === currentToken,
|
|
1598
|
+
runNow,
|
|
1599
|
+
runNowIfIdle: (run) => {
|
|
1600
|
+
const state = ctx.state;
|
|
1601
|
+
if (state.pendingScrollResolve || state.scrollingTo) {
|
|
1602
|
+
return Promise.resolve();
|
|
1603
|
+
}
|
|
1604
|
+
return new Promise((resolve) => {
|
|
1605
|
+
const token = start(resolve);
|
|
1606
|
+
runNow(token, resolve, run);
|
|
1607
|
+
});
|
|
1608
|
+
},
|
|
1609
|
+
start
|
|
1610
|
+
};
|
|
1618
1611
|
}
|
|
1619
|
-
|
|
1620
|
-
return false;
|
|
1612
|
+
return ctx.scrollRequestTracker;
|
|
1621
1613
|
}
|
|
1622
1614
|
|
|
1623
1615
|
// src/utils/requestAdjust.ts
|
|
1624
|
-
function requestAdjust(ctx, positionDiff,
|
|
1616
|
+
function requestAdjust(ctx, positionDiff, source) {
|
|
1625
1617
|
const state = ctx.state;
|
|
1626
1618
|
if (Math.abs(positionDiff) > 0.1) {
|
|
1619
|
+
const dataChanged = source === "data";
|
|
1627
1620
|
const needsScrollWorkaround = Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
|
|
1628
1621
|
const doit = () => {
|
|
1629
1622
|
if (needsScrollWorkaround) {
|
|
@@ -1640,7 +1633,7 @@ function requestAdjust(ctx, positionDiff, dataChanged) {
|
|
|
1640
1633
|
const readyToRender = peek$(ctx, "readyToRender");
|
|
1641
1634
|
if (readyToRender) {
|
|
1642
1635
|
doit();
|
|
1643
|
-
if (Platform.OS !== "web") {
|
|
1636
|
+
if (Platform.OS !== "web" && source !== "item-size") {
|
|
1644
1637
|
const threshold = state.scroll - positionDiff / 2;
|
|
1645
1638
|
if (!state.ignoreScrollFromMVCP) {
|
|
1646
1639
|
state.ignoreScrollFromMVCP = {};
|
|
@@ -1673,6 +1666,87 @@ function requestAdjust(ctx, positionDiff, dataChanged) {
|
|
|
1673
1666
|
}
|
|
1674
1667
|
}
|
|
1675
1668
|
|
|
1669
|
+
// src/core/doMaintainScrollAtEnd.ts
|
|
1670
|
+
function finishMaintainScrollAtEnd(ctx) {
|
|
1671
|
+
var _a3;
|
|
1672
|
+
const { state } = ctx;
|
|
1673
|
+
const currentPadding = peek$(ctx, "alignItemsAtEndPadding") || 0;
|
|
1674
|
+
const nextPadding = getAlignItemsAtEndPadding(ctx);
|
|
1675
|
+
state.maintainingScrollAtEnd = void 0;
|
|
1676
|
+
state.pendingMaintainScrollAtEnd = false;
|
|
1677
|
+
if (currentPadding !== nextPadding) {
|
|
1678
|
+
set$(ctx, "alignItemsAtEndPadding", nextPadding);
|
|
1679
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
1680
|
+
(_a3 = state.triggerCalculateItemsInView) == null ? void 0 : _a3.call(state, { forceFullItemPositions: true });
|
|
1681
|
+
const nextScroll = clampScrollOffset(ctx, state.scroll + nextPadding - currentPadding);
|
|
1682
|
+
requestAdjust(ctx, nextScroll - state.scroll);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
function doMaintainScrollAtEnd(ctx) {
|
|
1686
|
+
const state = ctx.state;
|
|
1687
|
+
const {
|
|
1688
|
+
didContainersLayout,
|
|
1689
|
+
didFinishInitialScroll,
|
|
1690
|
+
pendingNativeMVCPAdjust,
|
|
1691
|
+
props: { maintainScrollAtEnd }
|
|
1692
|
+
} = state;
|
|
1693
|
+
const isWithinMaintainScrollAtEndThreshold = peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
|
|
1694
|
+
const isReplayingPendingMaintain = !!state.pendingMaintainScrollAtEnd;
|
|
1695
|
+
const shouldMaintainScrollAtEnd = !!((isWithinMaintainScrollAtEndThreshold || isReplayingPendingMaintain) && maintainScrollAtEnd && didFinishInitialScroll);
|
|
1696
|
+
if (shouldMaintainScrollAtEnd && !didContainersLayout) {
|
|
1697
|
+
state.pendingMaintainScrollAtEnd = true;
|
|
1698
|
+
return false;
|
|
1699
|
+
}
|
|
1700
|
+
if (pendingNativeMVCPAdjust) {
|
|
1701
|
+
state.pendingMaintainScrollAtEnd = shouldMaintainScrollAtEnd;
|
|
1702
|
+
return false;
|
|
1703
|
+
}
|
|
1704
|
+
if (shouldMaintainScrollAtEnd && didContainersLayout) {
|
|
1705
|
+
state.pendingMaintainScrollAtEnd = false;
|
|
1706
|
+
const contentSize = getContentSize(ctx);
|
|
1707
|
+
if (contentSize < state.scrollLength) {
|
|
1708
|
+
state.scroll = 0;
|
|
1709
|
+
}
|
|
1710
|
+
if (!state.maintainingScrollAtEnd) {
|
|
1711
|
+
const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
|
|
1712
|
+
const activeState = maintainScrollAtEnd.animated ? "animated" : "instant";
|
|
1713
|
+
const scrollAtRequest = state.scroll;
|
|
1714
|
+
state.maintainingScrollAtEnd = pendingState;
|
|
1715
|
+
requestAnimationFrame(() => {
|
|
1716
|
+
if (state.maintainingScrollAtEnd !== pendingState) {
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
const isStillWithinThreshold = peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
|
|
1720
|
+
const didScrollSinceRequest = state.scroll !== scrollAtRequest;
|
|
1721
|
+
if (isReplayingPendingMaintain || isStillWithinThreshold || !didScrollSinceRequest) {
|
|
1722
|
+
state.maintainingScrollAtEnd = activeState;
|
|
1723
|
+
const scrollPromise = getScrollRequestTracker(ctx).runNowIfIdle(
|
|
1724
|
+
() => ctx.scrollToEnd({ animated: maintainScrollAtEnd.animated })
|
|
1725
|
+
);
|
|
1726
|
+
void scrollPromise.then(() => {
|
|
1727
|
+
if (state.maintainingScrollAtEnd !== activeState) {
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
1730
|
+
if (state.pendingMaintainScrollAtEnd) {
|
|
1731
|
+
state.maintainingScrollAtEnd = void 0;
|
|
1732
|
+
doMaintainScrollAtEnd(ctx);
|
|
1733
|
+
} else {
|
|
1734
|
+
finishMaintainScrollAtEnd(ctx);
|
|
1735
|
+
}
|
|
1736
|
+
});
|
|
1737
|
+
} else if (state.maintainingScrollAtEnd === pendingState) {
|
|
1738
|
+
finishMaintainScrollAtEnd(ctx);
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1741
|
+
} else {
|
|
1742
|
+
state.pendingMaintainScrollAtEnd = true;
|
|
1743
|
+
}
|
|
1744
|
+
return true;
|
|
1745
|
+
}
|
|
1746
|
+
finishMaintainScrollAtEnd(ctx);
|
|
1747
|
+
return false;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1676
1750
|
// src/core/mvcp.ts
|
|
1677
1751
|
var MVCP_POSITION_EPSILON = 0.1;
|
|
1678
1752
|
var MVCP_ANCHOR_LOCK_TTL_MS = 300;
|
|
@@ -1746,7 +1820,7 @@ function settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta) {
|
|
|
1746
1820
|
state.pendingNativeMVCPAdjust = void 0;
|
|
1747
1821
|
const remaining = remainingAfterManual - nativeDelta;
|
|
1748
1822
|
if (Math.abs(remaining) > MVCP_POSITION_EPSILON) {
|
|
1749
|
-
requestAdjust(ctx, remaining,
|
|
1823
|
+
requestAdjust(ctx, remaining, "data");
|
|
1750
1824
|
}
|
|
1751
1825
|
}
|
|
1752
1826
|
function maybeApplyPredictedNativeMVCPAdjust(ctx) {
|
|
@@ -1765,7 +1839,7 @@ function maybeApplyPredictedNativeMVCPAdjust(ctx) {
|
|
|
1765
1839
|
return;
|
|
1766
1840
|
}
|
|
1767
1841
|
pending.manualApplied = manualDesired;
|
|
1768
|
-
requestAdjust(ctx, manualDesired,
|
|
1842
|
+
requestAdjust(ctx, manualDesired, "data");
|
|
1769
1843
|
pending.furthestProgressTowardAmount = 0;
|
|
1770
1844
|
}
|
|
1771
1845
|
function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
|
|
@@ -1811,7 +1885,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
|
|
|
1811
1885
|
}
|
|
1812
1886
|
return false;
|
|
1813
1887
|
}
|
|
1814
|
-
function prepareMVCP(ctx, dataChanged) {
|
|
1888
|
+
function prepareMVCP(ctx, dataChanged, adjustmentSource) {
|
|
1815
1889
|
const state = ctx.state;
|
|
1816
1890
|
const { idsInView, positions, props } = state;
|
|
1817
1891
|
const {
|
|
@@ -1965,7 +2039,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1965
2039
|
if (Math.abs(positionDiff) > MVCP_POSITION_EPSILON) {
|
|
1966
2040
|
const shouldSkipAdjustForMaintainedEnd = (state.maintainingScrollAtEnd === "pending-animated" || state.maintainingScrollAtEnd === "animated") && peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
|
|
1967
2041
|
if (!shouldSkipAdjustForMaintainedEnd) {
|
|
1968
|
-
requestAdjust(ctx, positionDiff, dataChanged && mvcpData);
|
|
2042
|
+
requestAdjust(ctx, positionDiff, dataChanged && mvcpData ? "data" : adjustmentSource);
|
|
1969
2043
|
}
|
|
1970
2044
|
}
|
|
1971
2045
|
};
|
|
@@ -2063,6 +2137,10 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
|
|
|
2063
2137
|
state.scrollTime = currentTime;
|
|
2064
2138
|
const scrollDelta = Math.abs(newScroll - prevScroll);
|
|
2065
2139
|
const isUserScrollEvent = !!(options == null ? void 0 : options.fromNativeScrollEvent) && scrollDelta > 0.1 && !adjustChanged && scrollingTo === void 0 && !state.pendingNativeMVCPAdjust;
|
|
2140
|
+
const didCancelMaintainScrollAtEnd = isUserScrollEvent && newScroll < prevScroll && !!(state.maintainingScrollAtEnd || state.pendingMaintainScrollAtEnd);
|
|
2141
|
+
if (didCancelMaintainScrollAtEnd) {
|
|
2142
|
+
finishMaintainScrollAtEnd(ctx);
|
|
2143
|
+
}
|
|
2066
2144
|
const allowedEdge = isUserScrollEvent ? beginReachedEdgeUserScroll(ctx, newScroll - prevScroll) : void 0;
|
|
2067
2145
|
const didResolvePendingNativeMVCPAdjust = resolvePendingNativeMVCPAdjust(ctx, newScroll);
|
|
2068
2146
|
const scrollLength = state.scrollLength;
|
|
@@ -2071,7 +2149,7 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
|
|
|
2071
2149
|
updateAdaptiveRender(ctx, scrollVelocity, { forceLight: isLargeUserScrollJump });
|
|
2072
2150
|
const lastCalculated = state.scrollLastCalculate;
|
|
2073
2151
|
const useAggressiveItemRecalculation = isInMVCPActiveMode(state);
|
|
2074
|
-
const shouldUpdate = useAggressiveItemRecalculation || didResolvePendingNativeMVCPAdjust || allowedEdge !== void 0 || forceUpdate || lastCalculated === void 0 || Math.abs(state.scroll - lastCalculated) > 2;
|
|
2152
|
+
const shouldUpdate = useAggressiveItemRecalculation || didResolvePendingNativeMVCPAdjust || didCancelMaintainScrollAtEnd || allowedEdge !== void 0 || forceUpdate || lastCalculated === void 0 || Math.abs(state.scroll - lastCalculated) > 2;
|
|
2075
2153
|
if (shouldUpdate) {
|
|
2076
2154
|
state.scrollLastCalculate = state.scroll;
|
|
2077
2155
|
state.ignoreScrollFromMVCPIgnored = false;
|
|
@@ -2900,7 +2978,7 @@ function handleBootstrapInitialScrollFooterLayout(ctx, options) {
|
|
|
2900
2978
|
}
|
|
2901
2979
|
}
|
|
2902
2980
|
function handleBootstrapInitialScrollLayoutChange(ctx) {
|
|
2903
|
-
var _a3, _b
|
|
2981
|
+
var _a3, _b;
|
|
2904
2982
|
const state = ctx.state;
|
|
2905
2983
|
const initialScroll = state.initialScroll;
|
|
2906
2984
|
const bootstrapInitialScroll = getBootstrapInitialScrollSession(state);
|
|
@@ -2914,19 +2992,15 @@ function handleBootstrapInitialScrollLayoutChange(ctx) {
|
|
|
2914
2992
|
if (state.didFinishInitialScroll) {
|
|
2915
2993
|
schedulePreservedEndAnchorCorrection(ctx);
|
|
2916
2994
|
} else if (scrollingTo) {
|
|
2917
|
-
const existingWatchdog = initialScrollWatchdog.get(state);
|
|
2918
|
-
scrollingTo.offset = resolvedOffset;
|
|
2919
|
-
scrollingTo.targetOffset = resolvedOffset;
|
|
2920
2995
|
state.initialScroll = {
|
|
2921
2996
|
...initialScroll,
|
|
2922
2997
|
contentOffset: resolvedOffset
|
|
2923
2998
|
};
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2999
|
+
dispatchInitialScroll(ctx, {
|
|
3000
|
+
forceScroll: true,
|
|
3001
|
+
resolvedOffset,
|
|
3002
|
+
target: state.initialScroll
|
|
2928
3003
|
});
|
|
2929
|
-
requestAdjust(ctx, offsetDiff);
|
|
2930
3004
|
}
|
|
2931
3005
|
}
|
|
2932
3006
|
} else {
|
|
@@ -3225,6 +3299,7 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
|
|
|
3225
3299
|
return { didChangePosition: false, didRefreshData: false };
|
|
3226
3300
|
}
|
|
3227
3301
|
const itemKey = (_a3 = state.idCache[itemIndex]) != null ? _a3 : getId(state, itemIndex);
|
|
3302
|
+
const metadata = updateContainerItemMetadata(state, containerIndex, itemIndex, item);
|
|
3228
3303
|
const updateLayout = (_b = options == null ? void 0 : options.updateLayout) != null ? _b : true;
|
|
3229
3304
|
let didChangePosition = false;
|
|
3230
3305
|
let didRefreshData = false;
|
|
@@ -3235,7 +3310,7 @@ function syncMountedContainer(ctx, containerIndex, itemIndex, options) {
|
|
|
3235
3310
|
return { didChangePosition: false, didRefreshData: false };
|
|
3236
3311
|
}
|
|
3237
3312
|
const logicalPosition = (positionValue || 0) - ((_c = options == null ? void 0 : options.scrollAdjustPending) != null ? _c : 0);
|
|
3238
|
-
const itemSize = (_d = state.sizes.get(itemKey)) != null ? _d : getItemSize(ctx, itemKey, itemIndex, item);
|
|
3313
|
+
const itemSize = (_d = state.sizes.get(itemKey)) != null ? _d : getItemSize(ctx, itemKey, itemIndex, item, void 0, void 0, void 0, metadata);
|
|
3239
3314
|
const position = toPhysicalHorizontalItemPosition(state, logicalPosition, itemSize, peek$(ctx, "totalSize"));
|
|
3240
3315
|
const column = columns[itemIndex] || 1;
|
|
3241
3316
|
const span = columnSpans[itemIndex] || 1;
|
|
@@ -3968,6 +4043,9 @@ function setDidLayout(ctx) {
|
|
|
3968
4043
|
state.queuedInitialLayout = true;
|
|
3969
4044
|
checkAtBottom(ctx);
|
|
3970
4045
|
setInitialRenderState(ctx, { didLayout: true });
|
|
4046
|
+
if (state.pendingMaintainScrollAtEnd) {
|
|
4047
|
+
doMaintainScrollAtEnd(ctx);
|
|
4048
|
+
}
|
|
3971
4049
|
}
|
|
3972
4050
|
|
|
3973
4051
|
// src/core/calculateItemsInView.ts
|
|
@@ -4204,7 +4282,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4204
4282
|
const stickyHeaderIndicesArr = state.props.stickyHeaderIndicesArr || [];
|
|
4205
4283
|
const stickyHeaderIndicesSet = state.props.stickyHeaderIndicesSet || /* @__PURE__ */ new Set();
|
|
4206
4284
|
const drawDistance = getEffectiveDrawDistance(ctx, params.drawDistanceMode);
|
|
4207
|
-
const { dataChanged, doMVCP, forceFullItemPositions } = params;
|
|
4285
|
+
const { dataChanged, doMVCP, forceFullItemPositions, mvcpAdjustmentSource } = params;
|
|
4208
4286
|
const bootstrapInitialScrollState = ((_a3 = state.initialScrollSession) == null ? void 0 : _a3.kind) === "bootstrap" ? state.initialScrollSession.bootstrap : void 0;
|
|
4209
4287
|
const suppressInitialScrollSideEffects = !!bootstrapInitialScrollState;
|
|
4210
4288
|
const prevNumContainers = peek$(ctx, "numContainers");
|
|
@@ -4305,7 +4383,7 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4305
4383
|
}
|
|
4306
4384
|
}
|
|
4307
4385
|
}
|
|
4308
|
-
const checkMVCP = doMVCP && !suppressInitialScrollSideEffects ? prepareMVCP(ctx, dataChanged) : void 0;
|
|
4386
|
+
const checkMVCP = doMVCP && !suppressInitialScrollSideEffects ? prepareMVCP(ctx, dataChanged, mvcpAdjustmentSource) : void 0;
|
|
4309
4387
|
if (dataChanged) {
|
|
4310
4388
|
resetLayoutCachesForDataChange(state);
|
|
4311
4389
|
}
|
|
@@ -4523,13 +4601,13 @@ function calculateItemsInView(ctx, params = {}) {
|
|
|
4523
4601
|
changedContainerIds.add(containerIndex);
|
|
4524
4602
|
state.containerItemGenerations[containerIndex] = ((_p = state.containerItemGenerations[containerIndex]) != null ? _p : 0) + 1;
|
|
4525
4603
|
}
|
|
4526
|
-
set$(ctx, `containerItemKey${containerIndex}`, id);
|
|
4527
|
-
set$(ctx, `containerItemIndex${containerIndex}`, i);
|
|
4528
|
-
set$(ctx, `containerItemData${containerIndex}`, data[i]);
|
|
4529
4604
|
state.containerItemMetadata.set(
|
|
4530
4605
|
containerIndex,
|
|
4531
4606
|
createContainerItemMetadata(state, i, data[i], allocation.itemType)
|
|
4532
4607
|
);
|
|
4608
|
+
set$(ctx, `containerItemKey${containerIndex}`, id);
|
|
4609
|
+
set$(ctx, `containerItemIndex${containerIndex}`, i);
|
|
4610
|
+
set$(ctx, `containerItemData${containerIndex}`, data[i]);
|
|
4533
4611
|
containerItemKeys.set(id, containerIndex);
|
|
4534
4612
|
(_q = state.userScrollAnchorReset) == null ? void 0 : _q.keys.add(id);
|
|
4535
4613
|
const containerSticky = `containerSticky${containerIndex}`;
|
|
@@ -4719,12 +4797,15 @@ function runOrScheduleMVCPRecalculate(ctx) {
|
|
|
4719
4797
|
} else if (Platform.OS === "web") {
|
|
4720
4798
|
if (!state.mvcpAnchorLock) {
|
|
4721
4799
|
state.scheduledWork.cancel("mvcpRecalculate");
|
|
4722
|
-
calculateItemsInView(ctx, { doMVCP: true });
|
|
4800
|
+
calculateItemsInView(ctx, { doMVCP: true, mvcpAdjustmentSource: "item-size" });
|
|
4723
4801
|
} else if (!state.scheduledWork.has("mvcpRecalculate")) {
|
|
4724
|
-
state.scheduledWork.frame(
|
|
4802
|
+
state.scheduledWork.frame(
|
|
4803
|
+
() => calculateItemsInView(ctx, { doMVCP: true, mvcpAdjustmentSource: "item-size" }),
|
|
4804
|
+
"mvcpRecalculate"
|
|
4805
|
+
);
|
|
4725
4806
|
}
|
|
4726
4807
|
} else {
|
|
4727
|
-
calculateItemsInView(ctx, { doMVCP: true });
|
|
4808
|
+
calculateItemsInView(ctx, { doMVCP: true, mvcpAdjustmentSource: "item-size" });
|
|
4728
4809
|
}
|
|
4729
4810
|
}
|
|
4730
4811
|
function updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal) {
|
|
@@ -5213,6 +5294,30 @@ function useContainerItemSignals(containerContext) {
|
|
|
5213
5294
|
itemKey
|
|
5214
5295
|
};
|
|
5215
5296
|
}
|
|
5297
|
+
function scheduleViewabilityConfigWarning(ctx, hookName, configId) {
|
|
5298
|
+
let cancelled = false;
|
|
5299
|
+
Promise.resolve().then(() => {
|
|
5300
|
+
var _a3;
|
|
5301
|
+
const viewabilityConfigCallbackPairs = (_a3 = ctx.state) == null ? void 0 : _a3.viewabilityConfigCallbackPairs;
|
|
5302
|
+
if (!cancelled && ctx.state) {
|
|
5303
|
+
if (!(viewabilityConfigCallbackPairs == null ? void 0 : viewabilityConfigCallbackPairs.length)) {
|
|
5304
|
+
warnDevOnce(
|
|
5305
|
+
`${hookName}-missing-viewability-config`,
|
|
5306
|
+
`${hookName} requires viewability to be configured on the owning LegendList. Add viewabilityConfig with a visibility threshold.`
|
|
5307
|
+
);
|
|
5308
|
+
} else if (hookName === "useViewability" && !viewabilityConfigCallbackPairs.some((pair) => pair.viewabilityConfig.id === (configId != null ? configId : ""))) {
|
|
5309
|
+
const configDescription = configId ? ` for configId "${configId}"` : "";
|
|
5310
|
+
warnDevOnce(
|
|
5311
|
+
`${hookName}-missing-viewability-config-${configId != null ? configId : "default"}`,
|
|
5312
|
+
`${hookName}${configDescription} requires a matching viewabilityConfig.id on the owning LegendList. Add an id to viewabilityConfig and pass the same id to useViewability.`
|
|
5313
|
+
);
|
|
5314
|
+
}
|
|
5315
|
+
}
|
|
5316
|
+
});
|
|
5317
|
+
return () => {
|
|
5318
|
+
cancelled = true;
|
|
5319
|
+
};
|
|
5320
|
+
}
|
|
5216
5321
|
function useAdaptiveRender() {
|
|
5217
5322
|
const [mode] = useArr$(["adaptiveRender"]);
|
|
5218
5323
|
return mode;
|
|
@@ -5252,7 +5357,9 @@ function useViewability(callback, configId) {
|
|
|
5252
5357
|
const { containerId } = containerContext;
|
|
5253
5358
|
const key = containerId + (configId != null ? configId : "");
|
|
5254
5359
|
ctx.mapViewabilityCallbacks.set(key, callback);
|
|
5360
|
+
const cancelConfigWarning = IS_DEV ? scheduleViewabilityConfigWarning(ctx, "useViewability", configId) : void 0;
|
|
5255
5361
|
return () => {
|
|
5362
|
+
cancelConfigWarning == null ? void 0 : cancelConfigWarning();
|
|
5256
5363
|
ctx.mapViewabilityCallbacks.delete(key);
|
|
5257
5364
|
};
|
|
5258
5365
|
}, [ctx, callback, configId, containerContext]);
|
|
@@ -5276,7 +5383,9 @@ function useViewabilityAmount(callback) {
|
|
|
5276
5383
|
}
|
|
5277
5384
|
const { containerId } = containerContext;
|
|
5278
5385
|
ctx.mapViewabilityAmountCallbacks.set(containerId, callback);
|
|
5386
|
+
const cancelConfigWarning = IS_DEV ? scheduleViewabilityConfigWarning(ctx, "useViewabilityAmount") : void 0;
|
|
5279
5387
|
return () => {
|
|
5388
|
+
cancelConfigWarning == null ? void 0 : cancelConfigWarning();
|
|
5280
5389
|
ctx.mapViewabilityAmountCallbacks.delete(containerId);
|
|
5281
5390
|
};
|
|
5282
5391
|
}, [ctx, callback, containerContext]);
|
|
@@ -5641,7 +5750,7 @@ var Container = typedMemo(function Container2({
|
|
|
5641
5750
|
]
|
|
5642
5751
|
);
|
|
5643
5752
|
const renderedItemInfo = React2.useMemo(
|
|
5644
|
-
() => itemKey !== void 0 ? getRenderedItem2(itemKey) : null,
|
|
5753
|
+
() => itemKey !== void 0 ? getRenderedItem2(itemKey, id) : null,
|
|
5645
5754
|
[itemKey, data, extraData]
|
|
5646
5755
|
);
|
|
5647
5756
|
const { renderedItem } = renderedItemInfo || {};
|
|
@@ -6383,11 +6492,29 @@ var ScheduledWork = class {
|
|
|
6383
6492
|
constructor() {
|
|
6384
6493
|
this.work = /* @__PURE__ */ new Map();
|
|
6385
6494
|
}
|
|
6495
|
+
microtask(callback, key) {
|
|
6496
|
+
const pendingWork = this.work.get(key);
|
|
6497
|
+
if (pendingWork == null ? void 0 : pendingWork.callback) {
|
|
6498
|
+
pendingWork.callback = callback;
|
|
6499
|
+
} else {
|
|
6500
|
+
this.cancel(key);
|
|
6501
|
+
const work = { callback, cancel: () => {
|
|
6502
|
+
} };
|
|
6503
|
+
this.work.set(key, work);
|
|
6504
|
+
queueMicrotask(() => {
|
|
6505
|
+
var _a3;
|
|
6506
|
+
if (this.work.get(key) === work) {
|
|
6507
|
+
this.work.delete(key);
|
|
6508
|
+
(_a3 = work.callback) == null ? void 0 : _a3.call(work);
|
|
6509
|
+
}
|
|
6510
|
+
});
|
|
6511
|
+
}
|
|
6512
|
+
}
|
|
6386
6513
|
timeout(callback, delay, key) {
|
|
6387
6514
|
if (key) {
|
|
6388
6515
|
this.cancel(key);
|
|
6389
6516
|
}
|
|
6390
|
-
const work =
|
|
6517
|
+
const work = { cancel: () => clearTimeout(handle) };
|
|
6391
6518
|
const handle = setTimeout(() => {
|
|
6392
6519
|
const workKey = key != null ? key : handle;
|
|
6393
6520
|
if (this.work.get(workKey) === work) {
|
|
@@ -6395,14 +6522,13 @@ var ScheduledWork = class {
|
|
|
6395
6522
|
callback();
|
|
6396
6523
|
}
|
|
6397
6524
|
}, delay);
|
|
6398
|
-
work[0] = handle;
|
|
6399
6525
|
this.work.set(key != null ? key : handle, work);
|
|
6400
6526
|
}
|
|
6401
6527
|
frame(callback, key) {
|
|
6402
6528
|
this.cancel(key);
|
|
6403
|
-
const work =
|
|
6529
|
+
const work = { cancel: () => cancelAnimationFrame(handle) };
|
|
6404
6530
|
this.work.set(key, work);
|
|
6405
|
-
|
|
6531
|
+
const handle = requestAnimationFrame(() => {
|
|
6406
6532
|
if (this.work.get(key) === work) {
|
|
6407
6533
|
this.work.delete(key);
|
|
6408
6534
|
callback();
|
|
@@ -6411,22 +6537,21 @@ var ScheduledWork = class {
|
|
|
6411
6537
|
}
|
|
6412
6538
|
register(key, cancel) {
|
|
6413
6539
|
this.cancel(key);
|
|
6414
|
-
this.work.set(key,
|
|
6540
|
+
this.work.set(key, { cancel });
|
|
6415
6541
|
}
|
|
6416
6542
|
cancel(key) {
|
|
6417
6543
|
const work = this.work.get(key);
|
|
6418
6544
|
if (work) {
|
|
6419
6545
|
this.work.delete(key);
|
|
6420
|
-
|
|
6421
|
-
cancel(handle);
|
|
6546
|
+
work.cancel();
|
|
6422
6547
|
}
|
|
6423
6548
|
}
|
|
6424
6549
|
has(key) {
|
|
6425
6550
|
return this.work.has(key);
|
|
6426
6551
|
}
|
|
6427
6552
|
dispose() {
|
|
6428
|
-
for (const
|
|
6429
|
-
cancel(
|
|
6553
|
+
for (const work of this.work.values()) {
|
|
6554
|
+
work.cancel();
|
|
6430
6555
|
}
|
|
6431
6556
|
this.work.clear();
|
|
6432
6557
|
}
|
|
@@ -6483,6 +6608,25 @@ var ScrollAdjustHandler = class {
|
|
|
6483
6608
|
}
|
|
6484
6609
|
};
|
|
6485
6610
|
|
|
6611
|
+
// src/core/scrollToEnd.ts
|
|
6612
|
+
function scrollToEnd(ctx, options) {
|
|
6613
|
+
const state = ctx.state;
|
|
6614
|
+
const data = state.props.data;
|
|
6615
|
+
const index = data.length - 1;
|
|
6616
|
+
if (index === -1) {
|
|
6617
|
+
return false;
|
|
6618
|
+
}
|
|
6619
|
+
const paddingBottom = state.props.stylePaddingBottom || 0;
|
|
6620
|
+
const footerSize = peek$(ctx, "footerSize") || 0;
|
|
6621
|
+
scrollToIndex(ctx, {
|
|
6622
|
+
...options,
|
|
6623
|
+
index,
|
|
6624
|
+
viewOffset: -paddingBottom - footerSize + ((options == null ? void 0 : options.viewOffset) || 0),
|
|
6625
|
+
viewPosition: 1
|
|
6626
|
+
});
|
|
6627
|
+
return true;
|
|
6628
|
+
}
|
|
6629
|
+
|
|
6486
6630
|
// src/core/updateContentInsetEndAdjustment.ts
|
|
6487
6631
|
function updateContentInsetEndAdjustment(ctx, previousContentInsetEndAdjustment) {
|
|
6488
6632
|
const state = ctx.state;
|
|
@@ -6557,25 +6701,6 @@ function createColumnWrapperStyle(contentContainerStyle) {
|
|
|
6557
6701
|
}
|
|
6558
6702
|
}
|
|
6559
6703
|
|
|
6560
|
-
// src/core/scrollToEnd.ts
|
|
6561
|
-
function scrollToEnd(ctx, options) {
|
|
6562
|
-
const state = ctx.state;
|
|
6563
|
-
const data = state.props.data;
|
|
6564
|
-
const index = data.length - 1;
|
|
6565
|
-
if (index === -1) {
|
|
6566
|
-
return false;
|
|
6567
|
-
}
|
|
6568
|
-
const paddingBottom = state.props.stylePaddingBottom || 0;
|
|
6569
|
-
const footerSize = peek$(ctx, "footerSize") || 0;
|
|
6570
|
-
scrollToIndex(ctx, {
|
|
6571
|
-
...options,
|
|
6572
|
-
index,
|
|
6573
|
-
viewOffset: -paddingBottom - footerSize + ((options == null ? void 0 : options.viewOffset) || 0),
|
|
6574
|
-
viewPosition: 1
|
|
6575
|
-
});
|
|
6576
|
-
return true;
|
|
6577
|
-
}
|
|
6578
|
-
|
|
6579
6704
|
// src/utils/createImperativeHandle.ts
|
|
6580
6705
|
var DEFAULT_AVERAGE_ITEM_SIZE_TYPE = "default";
|
|
6581
6706
|
function getAverageItemSizes(state) {
|
|
@@ -6602,9 +6727,9 @@ function triggerMountedContainerLayouts(ctx) {
|
|
|
6602
6727
|
}
|
|
6603
6728
|
function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
|
|
6604
6729
|
const state = ctx.state;
|
|
6730
|
+
const scrollRequestTracker = getScrollRequestTracker(ctx);
|
|
6605
6731
|
const IMPERATIVE_SCROLL_SETTLE_MAX_WAIT_MS = 800;
|
|
6606
6732
|
const IMPERATIVE_SCROLL_SETTLE_STABLE_FRAMES = 2;
|
|
6607
|
-
let imperativeScrollToken = 0;
|
|
6608
6733
|
const isSettlingAfterDataChange = () => !!state.didDataChange || !!state.didColumnsChange || state.scheduledWork.has("mvcpRecalculate") || state.ignoreScrollFromMVCP !== void 0;
|
|
6609
6734
|
const isScrollToIndexReady = (targetIndex, allowEmpty = false) => {
|
|
6610
6735
|
var _a3;
|
|
@@ -6626,7 +6751,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
|
|
|
6626
6751
|
const startedAt = Date.now();
|
|
6627
6752
|
let stableFrames = 0;
|
|
6628
6753
|
const check = () => {
|
|
6629
|
-
if (token
|
|
6754
|
+
if (!scrollRequestTracker.isCurrent(token)) {
|
|
6630
6755
|
return;
|
|
6631
6756
|
}
|
|
6632
6757
|
if (isSettlingAfterDataChange() || !isReady()) {
|
|
@@ -6644,33 +6769,15 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
|
|
|
6644
6769
|
state.scheduledWork.frame(check, "imperativeScrollReady");
|
|
6645
6770
|
};
|
|
6646
6771
|
const runScrollRequest = (token, resolve, run, isReady = () => true) => {
|
|
6647
|
-
const runNow = () =>
|
|
6648
|
-
if (token !== imperativeScrollToken) {
|
|
6649
|
-
return;
|
|
6650
|
-
}
|
|
6651
|
-
const didStartScroll = run();
|
|
6652
|
-
if (!didStartScroll || !state.scrollingTo) {
|
|
6653
|
-
if (state.pendingScrollResolve === resolve) {
|
|
6654
|
-
state.pendingScrollResolve = void 0;
|
|
6655
|
-
}
|
|
6656
|
-
resolve();
|
|
6657
|
-
}
|
|
6658
|
-
};
|
|
6772
|
+
const runNow = () => scrollRequestTracker.runNow(token, resolve, run);
|
|
6659
6773
|
if (isSettlingAfterDataChange() || !isReady()) {
|
|
6660
6774
|
runWhenReady(token, runNow, isReady);
|
|
6661
6775
|
} else {
|
|
6662
6776
|
runNow();
|
|
6663
6777
|
}
|
|
6664
6778
|
};
|
|
6665
|
-
const startImperativeScroll = (resolve) => {
|
|
6666
|
-
state.scheduledWork.cancel("imperativeScrollReady");
|
|
6667
|
-
const token = ++imperativeScrollToken;
|
|
6668
|
-
settlePendingImperativeScroll(state);
|
|
6669
|
-
state.pendingScrollResolve = resolve;
|
|
6670
|
-
return token;
|
|
6671
|
-
};
|
|
6672
6779
|
const runScrollWithPromise = (run, isReady = () => true) => new Promise((resolve) => {
|
|
6673
|
-
const token =
|
|
6780
|
+
const token = scrollRequestTracker.start(resolve);
|
|
6674
6781
|
supersedeInitialScroll(ctx);
|
|
6675
6782
|
runScrollRequest(token, resolve, run, isReady);
|
|
6676
6783
|
});
|
|
@@ -6678,7 +6785,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
|
|
|
6678
6785
|
const pendingScroll = state.pendingScrollToEnd;
|
|
6679
6786
|
if (pendingScroll) {
|
|
6680
6787
|
state.pendingScrollToEnd = void 0;
|
|
6681
|
-
if (pendingScroll.token
|
|
6788
|
+
if (scrollRequestTracker.isCurrent(pendingScroll.token)) {
|
|
6682
6789
|
runScrollRequest(
|
|
6683
6790
|
pendingScroll.token,
|
|
6684
6791
|
pendingScroll.resolve,
|
|
@@ -6792,7 +6899,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
|
|
|
6792
6899
|
}),
|
|
6793
6900
|
scrollToEnd: (options) => new Promise((resolve) => {
|
|
6794
6901
|
var _a3;
|
|
6795
|
-
const token =
|
|
6902
|
+
const token = scrollRequestTracker.start(resolve);
|
|
6796
6903
|
state.pendingScrollToEnd = {
|
|
6797
6904
|
options,
|
|
6798
6905
|
resolve,
|
|
@@ -6894,34 +7001,37 @@ function getAlwaysRenderIndices(config, data, keyExtractor, anchoredEndSpaceAnch
|
|
|
6894
7001
|
}
|
|
6895
7002
|
|
|
6896
7003
|
// src/utils/getRenderedItem.ts
|
|
6897
|
-
function getRenderedItem(ctx, key) {
|
|
6898
|
-
var _a3;
|
|
7004
|
+
function getRenderedItem(ctx, key, containerId) {
|
|
7005
|
+
var _a3, _b, _c;
|
|
6899
7006
|
const state = ctx.state;
|
|
6900
7007
|
if (!state) {
|
|
6901
7008
|
return null;
|
|
6902
7009
|
}
|
|
7010
|
+
const metadata = state.containerItemMetadata.get(containerId);
|
|
7011
|
+
const useAssignedGeneration = metadata && metadata.dataChangeEpoch !== state.dataChangeEpoch;
|
|
6903
7012
|
const {
|
|
6904
7013
|
indexByKey,
|
|
6905
|
-
props: { data, getItemType, renderItem }
|
|
7014
|
+
props: { data: currentData, getItemType, renderItem }
|
|
6906
7015
|
} = state;
|
|
6907
|
-
const
|
|
7016
|
+
const data = useAssignedGeneration ? metadata.data : currentData;
|
|
7017
|
+
const index = (_a3 = metadata == null ? void 0 : metadata.itemIndex) != null ? _a3 : indexByKey.get(key);
|
|
6908
7018
|
if (index === void 0) {
|
|
6909
7019
|
return null;
|
|
6910
7020
|
}
|
|
6911
7021
|
let renderedItem = null;
|
|
6912
7022
|
const extraData = peek$(ctx, "extraData");
|
|
6913
|
-
const item = data[index];
|
|
7023
|
+
const item = useAssignedGeneration ? metadata.itemData : data[index];
|
|
6914
7024
|
if (renderItem && !isNullOrUndefined(item)) {
|
|
6915
7025
|
const itemProps = {
|
|
6916
7026
|
data,
|
|
6917
7027
|
extraData,
|
|
6918
7028
|
index,
|
|
6919
7029
|
item,
|
|
6920
|
-
type: getItemType ? (
|
|
7030
|
+
type: useAssignedGeneration ? (_b = metadata.itemType) != null ? _b : "" : getItemType ? (_c = getItemType(item, index)) != null ? _c : "" : ""
|
|
6921
7031
|
};
|
|
6922
7032
|
renderedItem = renderItem(itemProps);
|
|
6923
7033
|
}
|
|
6924
|
-
return { index, item
|
|
7034
|
+
return { index, item, renderedItem };
|
|
6925
7035
|
}
|
|
6926
7036
|
|
|
6927
7037
|
// src/utils/normalizeMaintainScrollAtEnd.ts
|
|
@@ -7172,6 +7282,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
7172
7282
|
const shouldInitializeHorizontalRTL = !initialScrollAtEnd && !hasInitialScrollIndex && !hasInitialScrollOffset && isHorizontalRTLProps({ horizontal, rtl });
|
|
7173
7283
|
const initialScrollUsesOffsetOnly = !initialScrollAtEnd && !hasInitialScrollIndex && (hasInitialScrollOffset || shouldInitializeHorizontalRTL);
|
|
7174
7284
|
const usesBootstrapInitialScroll = initialScrollAtEnd || hasInitialScrollIndex;
|
|
7285
|
+
const shouldBottomAlignNumericInitialScrollIndex = typeof initialScrollIndexProp === "number" && !hasInitialScrollOffset && dataProp.length > 1 && initialScrollIndexProp >= dataProp.length - 1;
|
|
7175
7286
|
const initialScrollProp = initialScrollAtEnd ? {
|
|
7176
7287
|
index: Math.max(0, dataProp.length - 1),
|
|
7177
7288
|
preserveForBottomPadding: true,
|
|
@@ -7184,7 +7295,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
7184
7295
|
viewPosition: (_d = initialScrollIndexProp.viewPosition) != null ? _d : 0
|
|
7185
7296
|
} : {
|
|
7186
7297
|
index: initialScrollIndexProp != null ? initialScrollIndexProp : 0,
|
|
7187
|
-
|
|
7298
|
+
preserveForBottomPadding: shouldBottomAlignNumericInitialScrollIndex ? true : void 0,
|
|
7299
|
+
viewOffset: initialScrollOffsetProp != null ? initialScrollOffsetProp : shouldBottomAlignNumericInitialScrollIndex ? -stylePaddingEndState : 0,
|
|
7300
|
+
viewPosition: shouldBottomAlignNumericInitialScrollIndex ? 1 : void 0
|
|
7188
7301
|
} : initialScrollUsesOffsetOnly ? {
|
|
7189
7302
|
contentOffset: initialScrollOffsetProp != null ? initialScrollOffsetProp : 0,
|
|
7190
7303
|
index: 0,
|
|
@@ -7290,6 +7403,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
7290
7403
|
viewabilityConfigCallbackPairs: void 0
|
|
7291
7404
|
};
|
|
7292
7405
|
const internalState = ctx.state;
|
|
7406
|
+
ctx.scrollToEnd = (options) => scrollToEnd(ctx, options);
|
|
7293
7407
|
internalState.triggerCalculateItemsInView = (params) => calculateItemsInView(ctx, params);
|
|
7294
7408
|
internalState.reprocessCurrentScroll = () => updateScroll(ctx, internalState.scroll, true);
|
|
7295
7409
|
set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
|
|
@@ -7641,7 +7755,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
7641
7755
|
}, [ctx, usesBootstrapInitialScroll]);
|
|
7642
7756
|
const fns = React2.useMemo(
|
|
7643
7757
|
() => ({
|
|
7644
|
-
getRenderedItem: (key) => getRenderedItem(ctx, key),
|
|
7758
|
+
getRenderedItem: (key, containerId) => getRenderedItem(ctx, key, containerId),
|
|
7645
7759
|
onMomentumScrollEnd: (event) => {
|
|
7646
7760
|
checkFinishedScrollFallback(ctx);
|
|
7647
7761
|
if (state.props.onMomentumScrollEnd) {
|
|
@@ -7651,6 +7765,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
7651
7765
|
onScroll: (event) => onScroll(ctx, event),
|
|
7652
7766
|
onScrollBeginDrag: (event) => {
|
|
7653
7767
|
var _a4, _b2;
|
|
7768
|
+
const maintainingScrollAtEnd = state.maintainingScrollAtEnd;
|
|
7769
|
+
if (maintainingScrollAtEnd === "animated" || maintainingScrollAtEnd === "instant") {
|
|
7770
|
+
cancelImperativeScroll(state);
|
|
7771
|
+
}
|
|
7772
|
+
if (maintainingScrollAtEnd) {
|
|
7773
|
+
finishMaintainScrollAtEnd(ctx);
|
|
7774
|
+
}
|
|
7654
7775
|
prepareReachedEdgeForNextUserScroll(ctx);
|
|
7655
7776
|
(_b2 = (_a4 = state.props).onScrollBeginDrag) == null ? void 0 : _b2.call(_a4, event);
|
|
7656
7777
|
},
|