@legendapp/list 2.1.0-beta.11 → 2.1.0-beta.13
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 +8 -664
- package/index.d.ts +8 -664
- package/index.js +175 -136
- package/index.mjs +175 -136
- package/index.native.d.mts +8 -664
- package/index.native.d.ts +8 -664
- package/index.native.js +154 -135
- package/index.native.mjs +154 -135
- package/package.json +1 -1
- package/section-list.d.mts +113 -0
- package/section-list.d.ts +113 -0
- package/section-list.js +3924 -0
- package/section-list.mjs +3903 -0
- package/section-list.native.d.mts +113 -0
- package/section-list.native.d.ts +113 -0
- package/section-list.native.js +3703 -0
- package/section-list.native.mjs +3682 -0
- package/types-JPHClxiw.d.mts +670 -0
- package/types-JPHClxiw.d.ts +670 -0
- package/types-YNdphn_A.d.mts +670 -0
- package/types-YNdphn_A.d.ts +670 -0
package/index.js
CHANGED
|
@@ -504,13 +504,17 @@ function useOnLayoutSync({
|
|
|
504
504
|
};
|
|
505
505
|
const rect = element.getBoundingClientRect();
|
|
506
506
|
emit(toLayout(rect), true);
|
|
507
|
+
let prevRect = rect;
|
|
507
508
|
return createResizeObserver(element, (entry) => {
|
|
508
509
|
var _a4;
|
|
509
510
|
const target = entry.target instanceof HTMLElement ? entry.target : void 0;
|
|
510
511
|
const rect2 = (_a4 = entry.contentRect) != null ? _a4 : target == null ? void 0 : target.getBoundingClientRect();
|
|
511
|
-
|
|
512
|
+
if (rect2.width !== prevRect.width || rect2.height !== prevRect.height) {
|
|
513
|
+
prevRect = rect2;
|
|
514
|
+
emit(toLayout(rect2), false);
|
|
515
|
+
}
|
|
512
516
|
});
|
|
513
|
-
}, deps);
|
|
517
|
+
}, deps || []);
|
|
514
518
|
return {};
|
|
515
519
|
}
|
|
516
520
|
function toLayout(rect) {
|
|
@@ -1058,8 +1062,26 @@ function ScrollAdjust() {
|
|
|
1058
1062
|
if (scrollView && scrollOffset !== lastScrollOffsetRef.current) {
|
|
1059
1063
|
const scrollDelta = scrollOffset - lastScrollOffsetRef.current;
|
|
1060
1064
|
if (scrollDelta !== 0) {
|
|
1061
|
-
scrollView.
|
|
1062
|
-
|
|
1065
|
+
const el = scrollView.getScrollableNode();
|
|
1066
|
+
const prevScroll = el.scrollTop;
|
|
1067
|
+
const nextScroll = prevScroll + scrollDelta;
|
|
1068
|
+
const totalSize = el.scrollHeight;
|
|
1069
|
+
if (scrollDelta > 0 && !ctx.internalState.adjustingFromInitialMount && totalSize < nextScroll + el.clientHeight) {
|
|
1070
|
+
const child = el.firstElementChild;
|
|
1071
|
+
const prevPaddingBottom = child.style.paddingBottom;
|
|
1072
|
+
const pad = (nextScroll + el.clientHeight - totalSize) * 2;
|
|
1073
|
+
child.style.paddingBottom = `${pad}px`;
|
|
1074
|
+
void el.offsetHeight;
|
|
1075
|
+
scrollView.scrollBy(0, scrollDelta);
|
|
1076
|
+
setTimeout(() => {
|
|
1077
|
+
child.style.paddingBottom = prevPaddingBottom;
|
|
1078
|
+
}, 100);
|
|
1079
|
+
} else {
|
|
1080
|
+
scrollView.scrollBy(0, scrollDelta);
|
|
1081
|
+
}
|
|
1082
|
+
if (IS_DEV) {
|
|
1083
|
+
console.log("ScrollAdjust (web scrollBy)", scrollDelta, "total offset:", scrollOffset);
|
|
1084
|
+
}
|
|
1063
1085
|
}
|
|
1064
1086
|
lastScrollOffsetRef.current = scrollOffset;
|
|
1065
1087
|
}
|
|
@@ -1113,7 +1135,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1113
1135
|
scrollAdjustHandler,
|
|
1114
1136
|
onLayoutHeader,
|
|
1115
1137
|
snapToIndices,
|
|
1116
|
-
|
|
1138
|
+
stickyHeaderIndices,
|
|
1117
1139
|
...rest
|
|
1118
1140
|
}) {
|
|
1119
1141
|
const ctx = useStateContext();
|
|
@@ -1148,7 +1170,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1148
1170
|
ScrollComponent: snapToIndices ? ScrollComponent : void 0,
|
|
1149
1171
|
style
|
|
1150
1172
|
},
|
|
1151
|
-
|
|
1173
|
+
/* @__PURE__ */ React3__namespace.createElement(ScrollAdjust, null),
|
|
1152
1174
|
ENABLE_DEVMODE ? /* @__PURE__ */ React3__namespace.createElement(PaddingDevMode, null) : /* @__PURE__ */ React3__namespace.createElement(Padding, null),
|
|
1153
1175
|
ListHeaderComponent && /* @__PURE__ */ React3__namespace.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
1154
1176
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
@@ -1339,6 +1361,67 @@ function calculateOffsetWithOffsetPosition(ctx, state, offsetParam, params) {
|
|
|
1339
1361
|
return offset;
|
|
1340
1362
|
}
|
|
1341
1363
|
|
|
1364
|
+
// src/core/finishScrollTo.ts
|
|
1365
|
+
function finishScrollTo(ctx, state) {
|
|
1366
|
+
var _a3, _b;
|
|
1367
|
+
if (state) {
|
|
1368
|
+
state.scrollHistory.length = 0;
|
|
1369
|
+
state.initialScroll = void 0;
|
|
1370
|
+
state.initialAnchor = void 0;
|
|
1371
|
+
set$(ctx, "scrollingTo", void 0);
|
|
1372
|
+
if (state.pendingTotalSize !== void 0) {
|
|
1373
|
+
addTotalSize(ctx, state, null, state.pendingTotalSize);
|
|
1374
|
+
}
|
|
1375
|
+
if ((_a3 = state.props) == null ? void 0 : _a3.data) {
|
|
1376
|
+
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
// src/core/scrollTo.ts
|
|
1382
|
+
function scrollTo(ctx, state, params) {
|
|
1383
|
+
var _a3;
|
|
1384
|
+
const { noScrollingTo, ...scrollTarget } = params;
|
|
1385
|
+
const { animated, isInitialScroll, offset: scrollTargetOffset, precomputedWithViewOffset } = scrollTarget;
|
|
1386
|
+
const {
|
|
1387
|
+
refScroller,
|
|
1388
|
+
props: { horizontal }
|
|
1389
|
+
} = state;
|
|
1390
|
+
let offset = precomputedWithViewOffset ? scrollTargetOffset : calculateOffsetWithOffsetPosition(ctx, state, scrollTargetOffset, scrollTarget);
|
|
1391
|
+
if (Number.isFinite(state.scrollLength) && Number.isFinite(state.totalSize)) {
|
|
1392
|
+
const maxOffset = Math.max(0, getContentSize(ctx) - state.scrollLength);
|
|
1393
|
+
offset = Math.min(offset, maxOffset);
|
|
1394
|
+
}
|
|
1395
|
+
state.scrollHistory.length = 0;
|
|
1396
|
+
if (!noScrollingTo) {
|
|
1397
|
+
set$(ctx, "scrollingTo", scrollTarget);
|
|
1398
|
+
}
|
|
1399
|
+
state.scrollPending = offset;
|
|
1400
|
+
if (!isInitialScroll || Platform.OS === "android") {
|
|
1401
|
+
(_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
|
|
1402
|
+
animated: !!animated,
|
|
1403
|
+
x: horizontal ? offset : 0,
|
|
1404
|
+
y: horizontal ? 0 : offset
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
if (!animated) {
|
|
1408
|
+
state.scroll = offset;
|
|
1409
|
+
{
|
|
1410
|
+
const unlisten = listen$(ctx, "containersDidLayout", (value) => {
|
|
1411
|
+
if (value && peek$(ctx, "scrollingTo")) {
|
|
1412
|
+
finishScrollTo(ctx, state);
|
|
1413
|
+
unlisten();
|
|
1414
|
+
}
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
if (isInitialScroll) {
|
|
1418
|
+
setTimeout(() => {
|
|
1419
|
+
state.initialScroll = void 0;
|
|
1420
|
+
}, 500);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1342
1425
|
// src/utils/checkThreshold.ts
|
|
1343
1426
|
var HYSTERESIS_MULTIPLIER = 1.3;
|
|
1344
1427
|
var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
|
|
@@ -1449,24 +1532,7 @@ function checkAtTop(state) {
|
|
|
1449
1532
|
);
|
|
1450
1533
|
}
|
|
1451
1534
|
|
|
1452
|
-
// src/core/
|
|
1453
|
-
function onScroll(ctx, state, event) {
|
|
1454
|
-
var _a3, _b, _c;
|
|
1455
|
-
const {
|
|
1456
|
-
scrollProcessingEnabled,
|
|
1457
|
-
props: { onScroll: onScrollProp }
|
|
1458
|
-
} = state;
|
|
1459
|
-
if (scrollProcessingEnabled === false) {
|
|
1460
|
-
return;
|
|
1461
|
-
}
|
|
1462
|
-
if (((_b = (_a3 = event.nativeEvent) == null ? void 0 : _a3.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
|
|
1463
|
-
return;
|
|
1464
|
-
}
|
|
1465
|
-
const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
1466
|
-
state.scrollPending = newScroll;
|
|
1467
|
-
updateScroll(ctx, state, newScroll);
|
|
1468
|
-
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
1469
|
-
}
|
|
1535
|
+
// src/core/updateScroll.ts
|
|
1470
1536
|
function updateScroll(ctx, state, newScroll, forceUpdate) {
|
|
1471
1537
|
var _a3;
|
|
1472
1538
|
const scrollingTo = peek$(ctx, "scrollingTo");
|
|
@@ -1509,66 +1575,15 @@ function updateScroll(ctx, state, newScroll, forceUpdate) {
|
|
|
1509
1575
|
}
|
|
1510
1576
|
}
|
|
1511
1577
|
|
|
1512
|
-
// src/core/finishScrollTo.ts
|
|
1513
|
-
function finishScrollTo(ctx, state) {
|
|
1514
|
-
var _a3, _b;
|
|
1515
|
-
if (state) {
|
|
1516
|
-
state.scrollHistory.length = 0;
|
|
1517
|
-
state.initialScroll = void 0;
|
|
1518
|
-
state.initialAnchor = void 0;
|
|
1519
|
-
set$(ctx, "scrollingTo", void 0);
|
|
1520
|
-
if (state.pendingTotalSize !== void 0) {
|
|
1521
|
-
addTotalSize(ctx, state, null, state.pendingTotalSize);
|
|
1522
|
-
}
|
|
1523
|
-
if ((_a3 = state.props) == null ? void 0 : _a3.data) {
|
|
1524
|
-
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
// src/core/scrollTo.ts
|
|
1530
|
-
function scrollTo(ctx, state, params) {
|
|
1531
|
-
var _a3;
|
|
1532
|
-
const { noScrollingTo, ...scrollTarget } = params;
|
|
1533
|
-
const { animated, isInitialScroll, offset: scrollTargetOffset, precomputedWithViewOffset } = scrollTarget;
|
|
1534
|
-
const {
|
|
1535
|
-
refScroller,
|
|
1536
|
-
props: { horizontal }
|
|
1537
|
-
} = state;
|
|
1538
|
-
let offset = precomputedWithViewOffset ? scrollTargetOffset : calculateOffsetWithOffsetPosition(ctx, state, scrollTargetOffset, scrollTarget);
|
|
1539
|
-
if (Number.isFinite(state.scrollLength) && Number.isFinite(state.totalSize)) {
|
|
1540
|
-
const maxOffset = Math.max(0, getContentSize(ctx) - state.scrollLength);
|
|
1541
|
-
offset = Math.min(offset, maxOffset);
|
|
1542
|
-
}
|
|
1543
|
-
state.scrollHistory.length = 0;
|
|
1544
|
-
if (!noScrollingTo) {
|
|
1545
|
-
set$(ctx, "scrollingTo", scrollTarget);
|
|
1546
|
-
}
|
|
1547
|
-
state.scrollPending = offset;
|
|
1548
|
-
if (!isInitialScroll || Platform.OS === "android") {
|
|
1549
|
-
(_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
|
|
1550
|
-
animated: !!animated,
|
|
1551
|
-
x: horizontal ? offset : 0,
|
|
1552
|
-
y: horizontal ? 0 : offset
|
|
1553
|
-
});
|
|
1554
|
-
}
|
|
1555
|
-
if (!animated) {
|
|
1556
|
-
state.scroll = offset;
|
|
1557
|
-
setTimeout(() => finishScrollTo(ctx, state), 100);
|
|
1558
|
-
if (isInitialScroll) {
|
|
1559
|
-
setTimeout(() => {
|
|
1560
|
-
state.initialScroll = void 0;
|
|
1561
|
-
}, 500);
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
1578
|
// src/utils/requestAdjust.ts
|
|
1567
1579
|
function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
1568
1580
|
if (Math.abs(positionDiff) > 0.1) {
|
|
1569
1581
|
const doit = () => {
|
|
1570
1582
|
{
|
|
1571
1583
|
state.scrollAdjustHandler.requestAdjust(positionDiff);
|
|
1584
|
+
if (state.adjustingFromInitialMount) {
|
|
1585
|
+
state.adjustingFromInitialMount--;
|
|
1586
|
+
}
|
|
1572
1587
|
}
|
|
1573
1588
|
};
|
|
1574
1589
|
state.scroll += positionDiff;
|
|
@@ -1577,6 +1592,7 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
|
1577
1592
|
if (didLayout) {
|
|
1578
1593
|
doit();
|
|
1579
1594
|
} else {
|
|
1595
|
+
state.adjustingFromInitialMount = (state.adjustingFromInitialMount || 0) + 1;
|
|
1580
1596
|
requestAnimationFrame(doit);
|
|
1581
1597
|
}
|
|
1582
1598
|
}
|
|
@@ -1636,18 +1652,16 @@ function ensureInitialAnchor(ctx, state) {
|
|
|
1636
1652
|
|
|
1637
1653
|
// src/core/mvcp.ts
|
|
1638
1654
|
function prepareMVCP(ctx, state, dataChanged) {
|
|
1639
|
-
const {
|
|
1640
|
-
|
|
1641
|
-
positions,
|
|
1642
|
-
props: { maintainVisibleContentPosition }
|
|
1643
|
-
} = state;
|
|
1655
|
+
const { idsInView, positions, props } = state;
|
|
1656
|
+
const { maintainVisibleContentPosition } = props;
|
|
1644
1657
|
const scrollingTo = peek$(ctx, "scrollingTo");
|
|
1645
1658
|
let prevPosition;
|
|
1646
1659
|
let targetId;
|
|
1647
1660
|
const idsInViewWithPositions = [];
|
|
1648
1661
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1649
|
-
|
|
1650
|
-
|
|
1662
|
+
const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
|
|
1663
|
+
const indexByKey = state.indexByKey;
|
|
1664
|
+
if (shouldMVCP) {
|
|
1651
1665
|
if (scrollTarget !== void 0) {
|
|
1652
1666
|
targetId = getId(state, scrollTarget);
|
|
1653
1667
|
} else if (idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
|
|
@@ -1660,44 +1674,44 @@ function prepareMVCP(ctx, state, dataChanged) {
|
|
|
1660
1674
|
}
|
|
1661
1675
|
}
|
|
1662
1676
|
} else {
|
|
1663
|
-
targetId =
|
|
1677
|
+
targetId = idsInView.find((id) => indexByKey.get(id) !== void 0);
|
|
1664
1678
|
}
|
|
1665
1679
|
}
|
|
1666
1680
|
if (targetId !== void 0) {
|
|
1667
1681
|
prevPosition = positions.get(targetId);
|
|
1668
1682
|
}
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1683
|
+
return () => {
|
|
1684
|
+
let positionDiff;
|
|
1685
|
+
if (dataChanged && targetId === void 0 && maintainVisibleContentPosition) {
|
|
1686
|
+
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1687
|
+
const { id, position } = idsInViewWithPositions[i];
|
|
1688
|
+
const newPosition = positions.get(id);
|
|
1689
|
+
if (newPosition !== void 0) {
|
|
1690
|
+
positionDiff = newPosition - position;
|
|
1691
|
+
break;
|
|
1692
|
+
}
|
|
1679
1693
|
}
|
|
1680
1694
|
}
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1695
|
+
if (targetId !== void 0 && prevPosition !== void 0) {
|
|
1696
|
+
const newPosition = positions.get(targetId);
|
|
1697
|
+
if (newPosition !== void 0) {
|
|
1698
|
+
const totalSize = getContentSize(ctx);
|
|
1699
|
+
let diff = newPosition - prevPosition;
|
|
1700
|
+
if (diff !== 0 && state.scroll + state.scrollLength > totalSize) {
|
|
1701
|
+
if (diff > 0) {
|
|
1702
|
+
diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
|
|
1703
|
+
} else {
|
|
1704
|
+
diff = 0;
|
|
1705
|
+
}
|
|
1692
1706
|
}
|
|
1707
|
+
positionDiff = diff;
|
|
1693
1708
|
}
|
|
1694
|
-
positionDiff = diff;
|
|
1695
1709
|
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1710
|
+
if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
|
|
1711
|
+
requestAdjust(ctx, state, positionDiff);
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1701
1715
|
}
|
|
1702
1716
|
|
|
1703
1717
|
// src/core/prepareColumnStartState.ts
|
|
@@ -1839,7 +1853,8 @@ function updateSnapToOffsets(ctx, state) {
|
|
|
1839
1853
|
}
|
|
1840
1854
|
|
|
1841
1855
|
// src/core/updateItemPositions.ts
|
|
1842
|
-
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false } = {
|
|
1856
|
+
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false, doMVCP } = {
|
|
1857
|
+
doMVCP: false,
|
|
1843
1858
|
forceFullUpdate: false,
|
|
1844
1859
|
scrollBottomBuffered: -1,
|
|
1845
1860
|
startIndex: 0
|
|
@@ -1851,7 +1866,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1851
1866
|
positions,
|
|
1852
1867
|
idCache,
|
|
1853
1868
|
sizesKnown,
|
|
1854
|
-
props: { getEstimatedItemSize, snapToIndices, enableAverages
|
|
1869
|
+
props: { getEstimatedItemSize, snapToIndices, enableAverages }
|
|
1855
1870
|
} = state;
|
|
1856
1871
|
const data = state.props.data;
|
|
1857
1872
|
const dataLength = data.length;
|
|
@@ -1862,7 +1877,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1862
1877
|
const shouldOptimize = !forceFullUpdate && !dataChanged && Math.abs(getScrollVelocity(state)) > 0;
|
|
1863
1878
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
1864
1879
|
const useAverageSize = enableAverages && !getEstimatedItemSize;
|
|
1865
|
-
const preferCachedSize =
|
|
1880
|
+
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0) !== 0;
|
|
1866
1881
|
let currentRowTop = 0;
|
|
1867
1882
|
let column = 1;
|
|
1868
1883
|
let maxSizeInRow = 0;
|
|
@@ -2317,14 +2332,14 @@ function findCurrentStickyIndex(stickyArray, scroll, state) {
|
|
|
2317
2332
|
}
|
|
2318
2333
|
return -1;
|
|
2319
2334
|
}
|
|
2320
|
-
function getActiveStickyIndices(ctx, state,
|
|
2335
|
+
function getActiveStickyIndices(ctx, state, stickyHeaderIndices) {
|
|
2321
2336
|
return new Set(
|
|
2322
|
-
Array.from(state.stickyContainerPool).map((i) => peek$(ctx, `containerItemKey${i}`)).map((key) => key ? state.indexByKey.get(key) : void 0).filter((idx) => idx !== void 0 &&
|
|
2337
|
+
Array.from(state.stickyContainerPool).map((i) => peek$(ctx, `containerItemKey${i}`)).map((key) => key ? state.indexByKey.get(key) : void 0).filter((idx) => idx !== void 0 && stickyHeaderIndices.has(idx))
|
|
2323
2338
|
);
|
|
2324
2339
|
}
|
|
2325
|
-
function handleStickyActivation(ctx, state,
|
|
2340
|
+
function handleStickyActivation(ctx, state, stickyHeaderIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
|
|
2326
2341
|
var _a3;
|
|
2327
|
-
const activeIndices = getActiveStickyIndices(ctx, state,
|
|
2342
|
+
const activeIndices = getActiveStickyIndices(ctx, state, stickyHeaderIndices);
|
|
2328
2343
|
state.activeStickyIndex = currentStickyIdx >= 0 ? stickyArray[currentStickyIdx] : void 0;
|
|
2329
2344
|
for (let offset = 0; offset <= 1; offset++) {
|
|
2330
2345
|
const idx = currentStickyIdx - offset;
|
|
@@ -2460,6 +2475,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2460
2475
|
}
|
|
2461
2476
|
const startIndex = dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
|
|
2462
2477
|
updateItemPositions(ctx, state, dataChanged, {
|
|
2478
|
+
doMVCP,
|
|
2463
2479
|
forceFullUpdate: !!forceFullItemPositions,
|
|
2464
2480
|
scrollBottomBuffered,
|
|
2465
2481
|
startIndex
|
|
@@ -2754,6 +2770,7 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
|
|
|
2754
2770
|
});
|
|
2755
2771
|
return true;
|
|
2756
2772
|
}
|
|
2773
|
+
return false;
|
|
2757
2774
|
}
|
|
2758
2775
|
|
|
2759
2776
|
// src/utils/updateAveragesOnDataChange.ts
|
|
@@ -2922,6 +2939,25 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2922
2939
|
setCanRender(true);
|
|
2923
2940
|
}
|
|
2924
2941
|
|
|
2942
|
+
// src/core/onScroll.ts
|
|
2943
|
+
function onScroll(ctx, state, event) {
|
|
2944
|
+
var _a3, _b, _c;
|
|
2945
|
+
const {
|
|
2946
|
+
scrollProcessingEnabled,
|
|
2947
|
+
props: { onScroll: onScrollProp }
|
|
2948
|
+
} = state;
|
|
2949
|
+
if (scrollProcessingEnabled === false) {
|
|
2950
|
+
return;
|
|
2951
|
+
}
|
|
2952
|
+
if (((_b = (_a3 = event.nativeEvent) == null ? void 0 : _a3.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
|
|
2953
|
+
return;
|
|
2954
|
+
}
|
|
2955
|
+
const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
2956
|
+
state.scrollPending = newScroll;
|
|
2957
|
+
updateScroll(ctx, state, newScroll);
|
|
2958
|
+
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
2959
|
+
}
|
|
2960
|
+
|
|
2925
2961
|
// src/core/ScrollAdjustHandler.ts
|
|
2926
2962
|
var ScrollAdjustHandler = class {
|
|
2927
2963
|
constructor(ctx) {
|
|
@@ -2957,12 +2993,7 @@ var ScrollAdjustHandler = class {
|
|
|
2957
2993
|
set$(this.context, "scrollAdjustPending", this.pendingAdjust);
|
|
2958
2994
|
} else {
|
|
2959
2995
|
this.appliedAdjust += add;
|
|
2960
|
-
|
|
2961
|
-
if (this.mounted) {
|
|
2962
|
-
setter();
|
|
2963
|
-
} else {
|
|
2964
|
-
requestAnimationFrame(setter);
|
|
2965
|
-
}
|
|
2996
|
+
set$(this.context, "scrollAdjust", this.appliedAdjust);
|
|
2966
2997
|
}
|
|
2967
2998
|
}
|
|
2968
2999
|
setMounted() {
|
|
@@ -3123,7 +3154,7 @@ function RefreshControl(_props) {
|
|
|
3123
3154
|
}
|
|
3124
3155
|
|
|
3125
3156
|
// src/platform/useStickyScrollHandler.ts
|
|
3126
|
-
function useStickyScrollHandler(
|
|
3157
|
+
function useStickyScrollHandler(_stickyHeaderIndices, _horizontal, _ctx, onScroll2) {
|
|
3127
3158
|
return onScroll2;
|
|
3128
3159
|
}
|
|
3129
3160
|
|
|
@@ -3346,7 +3377,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3346
3377
|
ListHeaderComponent,
|
|
3347
3378
|
maintainScrollAtEnd = false,
|
|
3348
3379
|
maintainScrollAtEndThreshold = 0.1,
|
|
3349
|
-
maintainVisibleContentPosition =
|
|
3380
|
+
maintainVisibleContentPosition = false,
|
|
3350
3381
|
numColumns: numColumnsProp = 1,
|
|
3351
3382
|
onEndReached,
|
|
3352
3383
|
onEndReachedThreshold = 0.5,
|
|
@@ -3368,7 +3399,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3368
3399
|
renderItem,
|
|
3369
3400
|
scrollEventThrottle,
|
|
3370
3401
|
snapToIndices,
|
|
3371
|
-
|
|
3402
|
+
stickyHeaderIndices: stickyHeaderIndicesProp,
|
|
3403
|
+
stickyIndices: stickyIndicesDeprecated,
|
|
3372
3404
|
style: styleProp,
|
|
3373
3405
|
suggestEstimatedItemSize,
|
|
3374
3406
|
viewabilityConfig,
|
|
@@ -3390,6 +3422,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3390
3422
|
const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
|
|
3391
3423
|
const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
|
|
3392
3424
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (_item, index) => index.toString();
|
|
3425
|
+
const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
|
|
3426
|
+
if (IS_DEV && stickyIndicesDeprecated && !stickyHeaderIndicesProp) {
|
|
3427
|
+
warnDevOnce(
|
|
3428
|
+
"stickyIndices",
|
|
3429
|
+
"stickyIndices has been renamed to stickyHeaderIndices. Please update your props to use stickyHeaderIndices."
|
|
3430
|
+
);
|
|
3431
|
+
}
|
|
3393
3432
|
const refState = React3.useRef();
|
|
3394
3433
|
if (!refState.current) {
|
|
3395
3434
|
if (!ctx.internalState) {
|
|
@@ -3501,8 +3540,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3501
3540
|
renderItem,
|
|
3502
3541
|
scrollBuffer,
|
|
3503
3542
|
snapToIndices,
|
|
3504
|
-
stickyIndicesArr:
|
|
3505
|
-
stickyIndicesSet: React3.useMemo(() => new Set(
|
|
3543
|
+
stickyIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
|
|
3544
|
+
stickyIndicesSet: React3.useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
|
|
3506
3545
|
stylePaddingBottom: stylePaddingBottomState,
|
|
3507
3546
|
stylePaddingTop: stylePaddingTopState,
|
|
3508
3547
|
suggestEstimatedItemSize: !!suggestEstimatedItemSize
|
|
@@ -3522,7 +3561,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3522
3561
|
setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
|
|
3523
3562
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
3524
3563
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
3525
|
-
if (
|
|
3564
|
+
if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3526
3565
|
if (state.scroll < 0) {
|
|
3527
3566
|
paddingDiff += state.scroll;
|
|
3528
3567
|
}
|
|
@@ -3570,7 +3609,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3570
3609
|
state.initialScroll = updatedInitialScroll;
|
|
3571
3610
|
refState.current.isStartReached = clampedOffset < refState.current.scrollLength * onStartReachedThreshold;
|
|
3572
3611
|
return clampedOffset;
|
|
3573
|
-
}, [renderNum
|
|
3612
|
+
}, [renderNum]);
|
|
3574
3613
|
if (isFirstLocal || didDataChangeLocal || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
3575
3614
|
refState.current.lastBatchingAction = Date.now();
|
|
3576
3615
|
if (!keyExtractorProp && !isFirstLocal && didDataChangeLocal) {
|
|
@@ -3608,7 +3647,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3608
3647
|
precomputedWithViewOffset: true
|
|
3609
3648
|
});
|
|
3610
3649
|
}
|
|
3611
|
-
}, [initialContentOffset
|
|
3650
|
+
}, [initialContentOffset]);
|
|
3612
3651
|
const onLayoutChange = React3.useCallback((layout) => {
|
|
3613
3652
|
doInitialScroll();
|
|
3614
3653
|
handleLayout(ctx, state, layout, setCanRender);
|
|
@@ -3670,7 +3709,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3670
3709
|
}),
|
|
3671
3710
|
[]
|
|
3672
3711
|
);
|
|
3673
|
-
const onScrollHandler = useStickyScrollHandler(
|
|
3712
|
+
const onScrollHandler = useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, fns.onScroll);
|
|
3674
3713
|
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
3675
3714
|
ListComponent,
|
|
3676
3715
|
{
|
|
@@ -3712,7 +3751,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3712
3751
|
scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
|
|
3713
3752
|
scrollEventThrottle: 16 ,
|
|
3714
3753
|
snapToIndices,
|
|
3715
|
-
|
|
3754
|
+
stickyHeaderIndices,
|
|
3716
3755
|
style,
|
|
3717
3756
|
updateItemSize: fns.updateItemSize,
|
|
3718
3757
|
waitForInitialLayout
|