@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.mjs
CHANGED
|
@@ -483,13 +483,17 @@ function useOnLayoutSync({
|
|
|
483
483
|
};
|
|
484
484
|
const rect = element.getBoundingClientRect();
|
|
485
485
|
emit(toLayout(rect), true);
|
|
486
|
+
let prevRect = rect;
|
|
486
487
|
return createResizeObserver(element, (entry) => {
|
|
487
488
|
var _a4;
|
|
488
489
|
const target = entry.target instanceof HTMLElement ? entry.target : void 0;
|
|
489
490
|
const rect2 = (_a4 = entry.contentRect) != null ? _a4 : target == null ? void 0 : target.getBoundingClientRect();
|
|
490
|
-
|
|
491
|
+
if (rect2.width !== prevRect.width || rect2.height !== prevRect.height) {
|
|
492
|
+
prevRect = rect2;
|
|
493
|
+
emit(toLayout(rect2), false);
|
|
494
|
+
}
|
|
491
495
|
});
|
|
492
|
-
}, deps);
|
|
496
|
+
}, deps || []);
|
|
493
497
|
return {};
|
|
494
498
|
}
|
|
495
499
|
function toLayout(rect) {
|
|
@@ -1037,8 +1041,26 @@ function ScrollAdjust() {
|
|
|
1037
1041
|
if (scrollView && scrollOffset !== lastScrollOffsetRef.current) {
|
|
1038
1042
|
const scrollDelta = scrollOffset - lastScrollOffsetRef.current;
|
|
1039
1043
|
if (scrollDelta !== 0) {
|
|
1040
|
-
scrollView.
|
|
1041
|
-
|
|
1044
|
+
const el = scrollView.getScrollableNode();
|
|
1045
|
+
const prevScroll = el.scrollTop;
|
|
1046
|
+
const nextScroll = prevScroll + scrollDelta;
|
|
1047
|
+
const totalSize = el.scrollHeight;
|
|
1048
|
+
if (scrollDelta > 0 && !ctx.internalState.adjustingFromInitialMount && totalSize < nextScroll + el.clientHeight) {
|
|
1049
|
+
const child = el.firstElementChild;
|
|
1050
|
+
const prevPaddingBottom = child.style.paddingBottom;
|
|
1051
|
+
const pad = (nextScroll + el.clientHeight - totalSize) * 2;
|
|
1052
|
+
child.style.paddingBottom = `${pad}px`;
|
|
1053
|
+
void el.offsetHeight;
|
|
1054
|
+
scrollView.scrollBy(0, scrollDelta);
|
|
1055
|
+
setTimeout(() => {
|
|
1056
|
+
child.style.paddingBottom = prevPaddingBottom;
|
|
1057
|
+
}, 100);
|
|
1058
|
+
} else {
|
|
1059
|
+
scrollView.scrollBy(0, scrollDelta);
|
|
1060
|
+
}
|
|
1061
|
+
if (IS_DEV) {
|
|
1062
|
+
console.log("ScrollAdjust (web scrollBy)", scrollDelta, "total offset:", scrollOffset);
|
|
1063
|
+
}
|
|
1042
1064
|
}
|
|
1043
1065
|
lastScrollOffsetRef.current = scrollOffset;
|
|
1044
1066
|
}
|
|
@@ -1092,7 +1114,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1092
1114
|
scrollAdjustHandler,
|
|
1093
1115
|
onLayoutHeader,
|
|
1094
1116
|
snapToIndices,
|
|
1095
|
-
|
|
1117
|
+
stickyHeaderIndices,
|
|
1096
1118
|
...rest
|
|
1097
1119
|
}) {
|
|
1098
1120
|
const ctx = useStateContext();
|
|
@@ -1127,7 +1149,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1127
1149
|
ScrollComponent: snapToIndices ? ScrollComponent : void 0,
|
|
1128
1150
|
style
|
|
1129
1151
|
},
|
|
1130
|
-
|
|
1152
|
+
/* @__PURE__ */ React3.createElement(ScrollAdjust, null),
|
|
1131
1153
|
ENABLE_DEVMODE ? /* @__PURE__ */ React3.createElement(PaddingDevMode, null) : /* @__PURE__ */ React3.createElement(Padding, null),
|
|
1132
1154
|
ListHeaderComponent && /* @__PURE__ */ React3.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
1133
1155
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
@@ -1318,6 +1340,67 @@ function calculateOffsetWithOffsetPosition(ctx, state, offsetParam, params) {
|
|
|
1318
1340
|
return offset;
|
|
1319
1341
|
}
|
|
1320
1342
|
|
|
1343
|
+
// src/core/finishScrollTo.ts
|
|
1344
|
+
function finishScrollTo(ctx, state) {
|
|
1345
|
+
var _a3, _b;
|
|
1346
|
+
if (state) {
|
|
1347
|
+
state.scrollHistory.length = 0;
|
|
1348
|
+
state.initialScroll = void 0;
|
|
1349
|
+
state.initialAnchor = void 0;
|
|
1350
|
+
set$(ctx, "scrollingTo", void 0);
|
|
1351
|
+
if (state.pendingTotalSize !== void 0) {
|
|
1352
|
+
addTotalSize(ctx, state, null, state.pendingTotalSize);
|
|
1353
|
+
}
|
|
1354
|
+
if ((_a3 = state.props) == null ? void 0 : _a3.data) {
|
|
1355
|
+
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
// src/core/scrollTo.ts
|
|
1361
|
+
function scrollTo(ctx, state, params) {
|
|
1362
|
+
var _a3;
|
|
1363
|
+
const { noScrollingTo, ...scrollTarget } = params;
|
|
1364
|
+
const { animated, isInitialScroll, offset: scrollTargetOffset, precomputedWithViewOffset } = scrollTarget;
|
|
1365
|
+
const {
|
|
1366
|
+
refScroller,
|
|
1367
|
+
props: { horizontal }
|
|
1368
|
+
} = state;
|
|
1369
|
+
let offset = precomputedWithViewOffset ? scrollTargetOffset : calculateOffsetWithOffsetPosition(ctx, state, scrollTargetOffset, scrollTarget);
|
|
1370
|
+
if (Number.isFinite(state.scrollLength) && Number.isFinite(state.totalSize)) {
|
|
1371
|
+
const maxOffset = Math.max(0, getContentSize(ctx) - state.scrollLength);
|
|
1372
|
+
offset = Math.min(offset, maxOffset);
|
|
1373
|
+
}
|
|
1374
|
+
state.scrollHistory.length = 0;
|
|
1375
|
+
if (!noScrollingTo) {
|
|
1376
|
+
set$(ctx, "scrollingTo", scrollTarget);
|
|
1377
|
+
}
|
|
1378
|
+
state.scrollPending = offset;
|
|
1379
|
+
if (!isInitialScroll || Platform.OS === "android") {
|
|
1380
|
+
(_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
|
|
1381
|
+
animated: !!animated,
|
|
1382
|
+
x: horizontal ? offset : 0,
|
|
1383
|
+
y: horizontal ? 0 : offset
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
if (!animated) {
|
|
1387
|
+
state.scroll = offset;
|
|
1388
|
+
{
|
|
1389
|
+
const unlisten = listen$(ctx, "containersDidLayout", (value) => {
|
|
1390
|
+
if (value && peek$(ctx, "scrollingTo")) {
|
|
1391
|
+
finishScrollTo(ctx, state);
|
|
1392
|
+
unlisten();
|
|
1393
|
+
}
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
if (isInitialScroll) {
|
|
1397
|
+
setTimeout(() => {
|
|
1398
|
+
state.initialScroll = void 0;
|
|
1399
|
+
}, 500);
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1321
1404
|
// src/utils/checkThreshold.ts
|
|
1322
1405
|
var HYSTERESIS_MULTIPLIER = 1.3;
|
|
1323
1406
|
var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
|
|
@@ -1428,24 +1511,7 @@ function checkAtTop(state) {
|
|
|
1428
1511
|
);
|
|
1429
1512
|
}
|
|
1430
1513
|
|
|
1431
|
-
// src/core/
|
|
1432
|
-
function onScroll(ctx, state, event) {
|
|
1433
|
-
var _a3, _b, _c;
|
|
1434
|
-
const {
|
|
1435
|
-
scrollProcessingEnabled,
|
|
1436
|
-
props: { onScroll: onScrollProp }
|
|
1437
|
-
} = state;
|
|
1438
|
-
if (scrollProcessingEnabled === false) {
|
|
1439
|
-
return;
|
|
1440
|
-
}
|
|
1441
|
-
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) {
|
|
1442
|
-
return;
|
|
1443
|
-
}
|
|
1444
|
-
const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
1445
|
-
state.scrollPending = newScroll;
|
|
1446
|
-
updateScroll(ctx, state, newScroll);
|
|
1447
|
-
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
1448
|
-
}
|
|
1514
|
+
// src/core/updateScroll.ts
|
|
1449
1515
|
function updateScroll(ctx, state, newScroll, forceUpdate) {
|
|
1450
1516
|
var _a3;
|
|
1451
1517
|
const scrollingTo = peek$(ctx, "scrollingTo");
|
|
@@ -1488,66 +1554,15 @@ function updateScroll(ctx, state, newScroll, forceUpdate) {
|
|
|
1488
1554
|
}
|
|
1489
1555
|
}
|
|
1490
1556
|
|
|
1491
|
-
// src/core/finishScrollTo.ts
|
|
1492
|
-
function finishScrollTo(ctx, state) {
|
|
1493
|
-
var _a3, _b;
|
|
1494
|
-
if (state) {
|
|
1495
|
-
state.scrollHistory.length = 0;
|
|
1496
|
-
state.initialScroll = void 0;
|
|
1497
|
-
state.initialAnchor = void 0;
|
|
1498
|
-
set$(ctx, "scrollingTo", void 0);
|
|
1499
|
-
if (state.pendingTotalSize !== void 0) {
|
|
1500
|
-
addTotalSize(ctx, state, null, state.pendingTotalSize);
|
|
1501
|
-
}
|
|
1502
|
-
if ((_a3 = state.props) == null ? void 0 : _a3.data) {
|
|
1503
|
-
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
// src/core/scrollTo.ts
|
|
1509
|
-
function scrollTo(ctx, state, params) {
|
|
1510
|
-
var _a3;
|
|
1511
|
-
const { noScrollingTo, ...scrollTarget } = params;
|
|
1512
|
-
const { animated, isInitialScroll, offset: scrollTargetOffset, precomputedWithViewOffset } = scrollTarget;
|
|
1513
|
-
const {
|
|
1514
|
-
refScroller,
|
|
1515
|
-
props: { horizontal }
|
|
1516
|
-
} = state;
|
|
1517
|
-
let offset = precomputedWithViewOffset ? scrollTargetOffset : calculateOffsetWithOffsetPosition(ctx, state, scrollTargetOffset, scrollTarget);
|
|
1518
|
-
if (Number.isFinite(state.scrollLength) && Number.isFinite(state.totalSize)) {
|
|
1519
|
-
const maxOffset = Math.max(0, getContentSize(ctx) - state.scrollLength);
|
|
1520
|
-
offset = Math.min(offset, maxOffset);
|
|
1521
|
-
}
|
|
1522
|
-
state.scrollHistory.length = 0;
|
|
1523
|
-
if (!noScrollingTo) {
|
|
1524
|
-
set$(ctx, "scrollingTo", scrollTarget);
|
|
1525
|
-
}
|
|
1526
|
-
state.scrollPending = offset;
|
|
1527
|
-
if (!isInitialScroll || Platform.OS === "android") {
|
|
1528
|
-
(_a3 = refScroller.current) == null ? void 0 : _a3.scrollTo({
|
|
1529
|
-
animated: !!animated,
|
|
1530
|
-
x: horizontal ? offset : 0,
|
|
1531
|
-
y: horizontal ? 0 : offset
|
|
1532
|
-
});
|
|
1533
|
-
}
|
|
1534
|
-
if (!animated) {
|
|
1535
|
-
state.scroll = offset;
|
|
1536
|
-
setTimeout(() => finishScrollTo(ctx, state), 100);
|
|
1537
|
-
if (isInitialScroll) {
|
|
1538
|
-
setTimeout(() => {
|
|
1539
|
-
state.initialScroll = void 0;
|
|
1540
|
-
}, 500);
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
1557
|
// src/utils/requestAdjust.ts
|
|
1546
1558
|
function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
1547
1559
|
if (Math.abs(positionDiff) > 0.1) {
|
|
1548
1560
|
const doit = () => {
|
|
1549
1561
|
{
|
|
1550
1562
|
state.scrollAdjustHandler.requestAdjust(positionDiff);
|
|
1563
|
+
if (state.adjustingFromInitialMount) {
|
|
1564
|
+
state.adjustingFromInitialMount--;
|
|
1565
|
+
}
|
|
1551
1566
|
}
|
|
1552
1567
|
};
|
|
1553
1568
|
state.scroll += positionDiff;
|
|
@@ -1556,6 +1571,7 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
|
1556
1571
|
if (didLayout) {
|
|
1557
1572
|
doit();
|
|
1558
1573
|
} else {
|
|
1574
|
+
state.adjustingFromInitialMount = (state.adjustingFromInitialMount || 0) + 1;
|
|
1559
1575
|
requestAnimationFrame(doit);
|
|
1560
1576
|
}
|
|
1561
1577
|
}
|
|
@@ -1615,18 +1631,16 @@ function ensureInitialAnchor(ctx, state) {
|
|
|
1615
1631
|
|
|
1616
1632
|
// src/core/mvcp.ts
|
|
1617
1633
|
function prepareMVCP(ctx, state, dataChanged) {
|
|
1618
|
-
const {
|
|
1619
|
-
|
|
1620
|
-
positions,
|
|
1621
|
-
props: { maintainVisibleContentPosition }
|
|
1622
|
-
} = state;
|
|
1634
|
+
const { idsInView, positions, props } = state;
|
|
1635
|
+
const { maintainVisibleContentPosition } = props;
|
|
1623
1636
|
const scrollingTo = peek$(ctx, "scrollingTo");
|
|
1624
1637
|
let prevPosition;
|
|
1625
1638
|
let targetId;
|
|
1626
1639
|
const idsInViewWithPositions = [];
|
|
1627
1640
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1628
|
-
|
|
1629
|
-
|
|
1641
|
+
const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
|
|
1642
|
+
const indexByKey = state.indexByKey;
|
|
1643
|
+
if (shouldMVCP) {
|
|
1630
1644
|
if (scrollTarget !== void 0) {
|
|
1631
1645
|
targetId = getId(state, scrollTarget);
|
|
1632
1646
|
} else if (idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
|
|
@@ -1639,44 +1653,44 @@ function prepareMVCP(ctx, state, dataChanged) {
|
|
|
1639
1653
|
}
|
|
1640
1654
|
}
|
|
1641
1655
|
} else {
|
|
1642
|
-
targetId =
|
|
1656
|
+
targetId = idsInView.find((id) => indexByKey.get(id) !== void 0);
|
|
1643
1657
|
}
|
|
1644
1658
|
}
|
|
1645
1659
|
if (targetId !== void 0) {
|
|
1646
1660
|
prevPosition = positions.get(targetId);
|
|
1647
1661
|
}
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1662
|
+
return () => {
|
|
1663
|
+
let positionDiff;
|
|
1664
|
+
if (dataChanged && targetId === void 0 && maintainVisibleContentPosition) {
|
|
1665
|
+
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1666
|
+
const { id, position } = idsInViewWithPositions[i];
|
|
1667
|
+
const newPosition = positions.get(id);
|
|
1668
|
+
if (newPosition !== void 0) {
|
|
1669
|
+
positionDiff = newPosition - position;
|
|
1670
|
+
break;
|
|
1671
|
+
}
|
|
1658
1672
|
}
|
|
1659
1673
|
}
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1674
|
+
if (targetId !== void 0 && prevPosition !== void 0) {
|
|
1675
|
+
const newPosition = positions.get(targetId);
|
|
1676
|
+
if (newPosition !== void 0) {
|
|
1677
|
+
const totalSize = getContentSize(ctx);
|
|
1678
|
+
let diff = newPosition - prevPosition;
|
|
1679
|
+
if (diff !== 0 && state.scroll + state.scrollLength > totalSize) {
|
|
1680
|
+
if (diff > 0) {
|
|
1681
|
+
diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
|
|
1682
|
+
} else {
|
|
1683
|
+
diff = 0;
|
|
1684
|
+
}
|
|
1671
1685
|
}
|
|
1686
|
+
positionDiff = diff;
|
|
1672
1687
|
}
|
|
1673
|
-
positionDiff = diff;
|
|
1674
1688
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1689
|
+
if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
|
|
1690
|
+
requestAdjust(ctx, state, positionDiff);
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1680
1694
|
}
|
|
1681
1695
|
|
|
1682
1696
|
// src/core/prepareColumnStartState.ts
|
|
@@ -1818,7 +1832,8 @@ function updateSnapToOffsets(ctx, state) {
|
|
|
1818
1832
|
}
|
|
1819
1833
|
|
|
1820
1834
|
// src/core/updateItemPositions.ts
|
|
1821
|
-
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false } = {
|
|
1835
|
+
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false, doMVCP } = {
|
|
1836
|
+
doMVCP: false,
|
|
1822
1837
|
forceFullUpdate: false,
|
|
1823
1838
|
scrollBottomBuffered: -1,
|
|
1824
1839
|
startIndex: 0
|
|
@@ -1830,7 +1845,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1830
1845
|
positions,
|
|
1831
1846
|
idCache,
|
|
1832
1847
|
sizesKnown,
|
|
1833
|
-
props: { getEstimatedItemSize, snapToIndices, enableAverages
|
|
1848
|
+
props: { getEstimatedItemSize, snapToIndices, enableAverages }
|
|
1834
1849
|
} = state;
|
|
1835
1850
|
const data = state.props.data;
|
|
1836
1851
|
const dataLength = data.length;
|
|
@@ -1841,7 +1856,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1841
1856
|
const shouldOptimize = !forceFullUpdate && !dataChanged && Math.abs(getScrollVelocity(state)) > 0;
|
|
1842
1857
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
1843
1858
|
const useAverageSize = enableAverages && !getEstimatedItemSize;
|
|
1844
|
-
const preferCachedSize =
|
|
1859
|
+
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0) !== 0;
|
|
1845
1860
|
let currentRowTop = 0;
|
|
1846
1861
|
let column = 1;
|
|
1847
1862
|
let maxSizeInRow = 0;
|
|
@@ -2296,14 +2311,14 @@ function findCurrentStickyIndex(stickyArray, scroll, state) {
|
|
|
2296
2311
|
}
|
|
2297
2312
|
return -1;
|
|
2298
2313
|
}
|
|
2299
|
-
function getActiveStickyIndices(ctx, state,
|
|
2314
|
+
function getActiveStickyIndices(ctx, state, stickyHeaderIndices) {
|
|
2300
2315
|
return new Set(
|
|
2301
|
-
Array.from(state.stickyContainerPool).map((i) => peek$(ctx, `containerItemKey${i}`)).map((key) => key ? state.indexByKey.get(key) : void 0).filter((idx) => idx !== void 0 &&
|
|
2316
|
+
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))
|
|
2302
2317
|
);
|
|
2303
2318
|
}
|
|
2304
|
-
function handleStickyActivation(ctx, state,
|
|
2319
|
+
function handleStickyActivation(ctx, state, stickyHeaderIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
|
|
2305
2320
|
var _a3;
|
|
2306
|
-
const activeIndices = getActiveStickyIndices(ctx, state,
|
|
2321
|
+
const activeIndices = getActiveStickyIndices(ctx, state, stickyHeaderIndices);
|
|
2307
2322
|
state.activeStickyIndex = currentStickyIdx >= 0 ? stickyArray[currentStickyIdx] : void 0;
|
|
2308
2323
|
for (let offset = 0; offset <= 1; offset++) {
|
|
2309
2324
|
const idx = currentStickyIdx - offset;
|
|
@@ -2439,6 +2454,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2439
2454
|
}
|
|
2440
2455
|
const startIndex = dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
|
|
2441
2456
|
updateItemPositions(ctx, state, dataChanged, {
|
|
2457
|
+
doMVCP,
|
|
2442
2458
|
forceFullUpdate: !!forceFullItemPositions,
|
|
2443
2459
|
scrollBottomBuffered,
|
|
2444
2460
|
startIndex
|
|
@@ -2733,6 +2749,7 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
|
|
|
2733
2749
|
});
|
|
2734
2750
|
return true;
|
|
2735
2751
|
}
|
|
2752
|
+
return false;
|
|
2736
2753
|
}
|
|
2737
2754
|
|
|
2738
2755
|
// src/utils/updateAveragesOnDataChange.ts
|
|
@@ -2901,6 +2918,25 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2901
2918
|
setCanRender(true);
|
|
2902
2919
|
}
|
|
2903
2920
|
|
|
2921
|
+
// src/core/onScroll.ts
|
|
2922
|
+
function onScroll(ctx, state, event) {
|
|
2923
|
+
var _a3, _b, _c;
|
|
2924
|
+
const {
|
|
2925
|
+
scrollProcessingEnabled,
|
|
2926
|
+
props: { onScroll: onScrollProp }
|
|
2927
|
+
} = state;
|
|
2928
|
+
if (scrollProcessingEnabled === false) {
|
|
2929
|
+
return;
|
|
2930
|
+
}
|
|
2931
|
+
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) {
|
|
2932
|
+
return;
|
|
2933
|
+
}
|
|
2934
|
+
const newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
2935
|
+
state.scrollPending = newScroll;
|
|
2936
|
+
updateScroll(ctx, state, newScroll);
|
|
2937
|
+
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
2938
|
+
}
|
|
2939
|
+
|
|
2904
2940
|
// src/core/ScrollAdjustHandler.ts
|
|
2905
2941
|
var ScrollAdjustHandler = class {
|
|
2906
2942
|
constructor(ctx) {
|
|
@@ -2936,12 +2972,7 @@ var ScrollAdjustHandler = class {
|
|
|
2936
2972
|
set$(this.context, "scrollAdjustPending", this.pendingAdjust);
|
|
2937
2973
|
} else {
|
|
2938
2974
|
this.appliedAdjust += add;
|
|
2939
|
-
|
|
2940
|
-
if (this.mounted) {
|
|
2941
|
-
setter();
|
|
2942
|
-
} else {
|
|
2943
|
-
requestAnimationFrame(setter);
|
|
2944
|
-
}
|
|
2975
|
+
set$(this.context, "scrollAdjust", this.appliedAdjust);
|
|
2945
2976
|
}
|
|
2946
2977
|
}
|
|
2947
2978
|
setMounted() {
|
|
@@ -3102,7 +3133,7 @@ function RefreshControl(_props) {
|
|
|
3102
3133
|
}
|
|
3103
3134
|
|
|
3104
3135
|
// src/platform/useStickyScrollHandler.ts
|
|
3105
|
-
function useStickyScrollHandler(
|
|
3136
|
+
function useStickyScrollHandler(_stickyHeaderIndices, _horizontal, _ctx, onScroll2) {
|
|
3106
3137
|
return onScroll2;
|
|
3107
3138
|
}
|
|
3108
3139
|
|
|
@@ -3325,7 +3356,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3325
3356
|
ListHeaderComponent,
|
|
3326
3357
|
maintainScrollAtEnd = false,
|
|
3327
3358
|
maintainScrollAtEndThreshold = 0.1,
|
|
3328
|
-
maintainVisibleContentPosition =
|
|
3359
|
+
maintainVisibleContentPosition = false,
|
|
3329
3360
|
numColumns: numColumnsProp = 1,
|
|
3330
3361
|
onEndReached,
|
|
3331
3362
|
onEndReachedThreshold = 0.5,
|
|
@@ -3347,7 +3378,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3347
3378
|
renderItem,
|
|
3348
3379
|
scrollEventThrottle,
|
|
3349
3380
|
snapToIndices,
|
|
3350
|
-
|
|
3381
|
+
stickyHeaderIndices: stickyHeaderIndicesProp,
|
|
3382
|
+
stickyIndices: stickyIndicesDeprecated,
|
|
3351
3383
|
style: styleProp,
|
|
3352
3384
|
suggestEstimatedItemSize,
|
|
3353
3385
|
viewabilityConfig,
|
|
@@ -3369,6 +3401,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3369
3401
|
const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
|
|
3370
3402
|
const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
|
|
3371
3403
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (_item, index) => index.toString();
|
|
3404
|
+
const stickyHeaderIndices = stickyHeaderIndicesProp != null ? stickyHeaderIndicesProp : stickyIndicesDeprecated;
|
|
3405
|
+
if (IS_DEV && stickyIndicesDeprecated && !stickyHeaderIndicesProp) {
|
|
3406
|
+
warnDevOnce(
|
|
3407
|
+
"stickyIndices",
|
|
3408
|
+
"stickyIndices has been renamed to stickyHeaderIndices. Please update your props to use stickyHeaderIndices."
|
|
3409
|
+
);
|
|
3410
|
+
}
|
|
3372
3411
|
const refState = useRef();
|
|
3373
3412
|
if (!refState.current) {
|
|
3374
3413
|
if (!ctx.internalState) {
|
|
@@ -3480,8 +3519,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3480
3519
|
renderItem,
|
|
3481
3520
|
scrollBuffer,
|
|
3482
3521
|
snapToIndices,
|
|
3483
|
-
stickyIndicesArr:
|
|
3484
|
-
stickyIndicesSet: useMemo(() => new Set(
|
|
3522
|
+
stickyIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
|
|
3523
|
+
stickyIndicesSet: useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
|
|
3485
3524
|
stylePaddingBottom: stylePaddingBottomState,
|
|
3486
3525
|
stylePaddingTop: stylePaddingTopState,
|
|
3487
3526
|
suggestEstimatedItemSize: !!suggestEstimatedItemSize
|
|
@@ -3501,7 +3540,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3501
3540
|
setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
|
|
3502
3541
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
3503
3542
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
3504
|
-
if (
|
|
3543
|
+
if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3505
3544
|
if (state.scroll < 0) {
|
|
3506
3545
|
paddingDiff += state.scroll;
|
|
3507
3546
|
}
|
|
@@ -3549,7 +3588,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3549
3588
|
state.initialScroll = updatedInitialScroll;
|
|
3550
3589
|
refState.current.isStartReached = clampedOffset < refState.current.scrollLength * onStartReachedThreshold;
|
|
3551
3590
|
return clampedOffset;
|
|
3552
|
-
}, [renderNum
|
|
3591
|
+
}, [renderNum]);
|
|
3553
3592
|
if (isFirstLocal || didDataChangeLocal || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
3554
3593
|
refState.current.lastBatchingAction = Date.now();
|
|
3555
3594
|
if (!keyExtractorProp && !isFirstLocal && didDataChangeLocal) {
|
|
@@ -3587,7 +3626,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3587
3626
|
precomputedWithViewOffset: true
|
|
3588
3627
|
});
|
|
3589
3628
|
}
|
|
3590
|
-
}, [initialContentOffset
|
|
3629
|
+
}, [initialContentOffset]);
|
|
3591
3630
|
const onLayoutChange = useCallback((layout) => {
|
|
3592
3631
|
doInitialScroll();
|
|
3593
3632
|
handleLayout(ctx, state, layout, setCanRender);
|
|
@@ -3649,7 +3688,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3649
3688
|
}),
|
|
3650
3689
|
[]
|
|
3651
3690
|
);
|
|
3652
|
-
const onScrollHandler = useStickyScrollHandler(
|
|
3691
|
+
const onScrollHandler = useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, fns.onScroll);
|
|
3653
3692
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
3654
3693
|
ListComponent,
|
|
3655
3694
|
{
|
|
@@ -3691,7 +3730,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3691
3730
|
scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
|
|
3692
3731
|
scrollEventThrottle: 16 ,
|
|
3693
3732
|
snapToIndices,
|
|
3694
|
-
|
|
3733
|
+
stickyHeaderIndices,
|
|
3695
3734
|
style,
|
|
3696
3735
|
updateItemSize: fns.updateItemSize,
|
|
3697
3736
|
waitForInitialLayout
|