@legendapp/list 2.1.0-beta.12 → 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 -143
- package/index.mjs +175 -143
- package/index.native.d.mts +8 -664
- package/index.native.d.ts +8 -664
- package/index.native.js +154 -144
- package/index.native.mjs +154 -144
- 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,73 +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
|
-
{
|
|
1558
|
-
const unlisten = listen$(ctx, "containersDidLayout", (value) => {
|
|
1559
|
-
if (value) {
|
|
1560
|
-
finishScrollTo(ctx, state);
|
|
1561
|
-
unlisten();
|
|
1562
|
-
}
|
|
1563
|
-
});
|
|
1564
|
-
}
|
|
1565
|
-
if (isInitialScroll) {
|
|
1566
|
-
setTimeout(() => {
|
|
1567
|
-
state.initialScroll = void 0;
|
|
1568
|
-
}, 500);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
1578
|
// src/utils/requestAdjust.ts
|
|
1574
1579
|
function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
1575
1580
|
if (Math.abs(positionDiff) > 0.1) {
|
|
1576
1581
|
const doit = () => {
|
|
1577
1582
|
{
|
|
1578
1583
|
state.scrollAdjustHandler.requestAdjust(positionDiff);
|
|
1584
|
+
if (state.adjustingFromInitialMount) {
|
|
1585
|
+
state.adjustingFromInitialMount--;
|
|
1586
|
+
}
|
|
1579
1587
|
}
|
|
1580
1588
|
};
|
|
1581
1589
|
state.scroll += positionDiff;
|
|
@@ -1584,6 +1592,7 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
|
1584
1592
|
if (didLayout) {
|
|
1585
1593
|
doit();
|
|
1586
1594
|
} else {
|
|
1595
|
+
state.adjustingFromInitialMount = (state.adjustingFromInitialMount || 0) + 1;
|
|
1587
1596
|
requestAnimationFrame(doit);
|
|
1588
1597
|
}
|
|
1589
1598
|
}
|
|
@@ -1643,18 +1652,16 @@ function ensureInitialAnchor(ctx, state) {
|
|
|
1643
1652
|
|
|
1644
1653
|
// src/core/mvcp.ts
|
|
1645
1654
|
function prepareMVCP(ctx, state, dataChanged) {
|
|
1646
|
-
const {
|
|
1647
|
-
|
|
1648
|
-
positions,
|
|
1649
|
-
props: { maintainVisibleContentPosition }
|
|
1650
|
-
} = state;
|
|
1655
|
+
const { idsInView, positions, props } = state;
|
|
1656
|
+
const { maintainVisibleContentPosition } = props;
|
|
1651
1657
|
const scrollingTo = peek$(ctx, "scrollingTo");
|
|
1652
1658
|
let prevPosition;
|
|
1653
1659
|
let targetId;
|
|
1654
1660
|
const idsInViewWithPositions = [];
|
|
1655
1661
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1656
|
-
|
|
1657
|
-
|
|
1662
|
+
const shouldMVCP = !dataChanged || maintainVisibleContentPosition;
|
|
1663
|
+
const indexByKey = state.indexByKey;
|
|
1664
|
+
if (shouldMVCP) {
|
|
1658
1665
|
if (scrollTarget !== void 0) {
|
|
1659
1666
|
targetId = getId(state, scrollTarget);
|
|
1660
1667
|
} else if (idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
|
|
@@ -1667,44 +1674,44 @@ function prepareMVCP(ctx, state, dataChanged) {
|
|
|
1667
1674
|
}
|
|
1668
1675
|
}
|
|
1669
1676
|
} else {
|
|
1670
|
-
targetId =
|
|
1677
|
+
targetId = idsInView.find((id) => indexByKey.get(id) !== void 0);
|
|
1671
1678
|
}
|
|
1672
1679
|
}
|
|
1673
1680
|
if (targetId !== void 0) {
|
|
1674
1681
|
prevPosition = positions.get(targetId);
|
|
1675
1682
|
}
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
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
|
+
}
|
|
1686
1693
|
}
|
|
1687
1694
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
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
|
+
}
|
|
1699
1706
|
}
|
|
1707
|
+
positionDiff = diff;
|
|
1700
1708
|
}
|
|
1701
|
-
positionDiff = diff;
|
|
1702
1709
|
}
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1710
|
+
if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
|
|
1711
|
+
requestAdjust(ctx, state, positionDiff);
|
|
1712
|
+
}
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1708
1715
|
}
|
|
1709
1716
|
|
|
1710
1717
|
// src/core/prepareColumnStartState.ts
|
|
@@ -1846,7 +1853,8 @@ function updateSnapToOffsets(ctx, state) {
|
|
|
1846
1853
|
}
|
|
1847
1854
|
|
|
1848
1855
|
// src/core/updateItemPositions.ts
|
|
1849
|
-
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false } = {
|
|
1856
|
+
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false, doMVCP } = {
|
|
1857
|
+
doMVCP: false,
|
|
1850
1858
|
forceFullUpdate: false,
|
|
1851
1859
|
scrollBottomBuffered: -1,
|
|
1852
1860
|
startIndex: 0
|
|
@@ -1858,7 +1866,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1858
1866
|
positions,
|
|
1859
1867
|
idCache,
|
|
1860
1868
|
sizesKnown,
|
|
1861
|
-
props: { getEstimatedItemSize, snapToIndices, enableAverages
|
|
1869
|
+
props: { getEstimatedItemSize, snapToIndices, enableAverages }
|
|
1862
1870
|
} = state;
|
|
1863
1871
|
const data = state.props.data;
|
|
1864
1872
|
const dataLength = data.length;
|
|
@@ -1869,7 +1877,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1869
1877
|
const shouldOptimize = !forceFullUpdate && !dataChanged && Math.abs(getScrollVelocity(state)) > 0;
|
|
1870
1878
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
1871
1879
|
const useAverageSize = enableAverages && !getEstimatedItemSize;
|
|
1872
|
-
const preferCachedSize =
|
|
1880
|
+
const preferCachedSize = !doMVCP || dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0) !== 0;
|
|
1873
1881
|
let currentRowTop = 0;
|
|
1874
1882
|
let column = 1;
|
|
1875
1883
|
let maxSizeInRow = 0;
|
|
@@ -2324,14 +2332,14 @@ function findCurrentStickyIndex(stickyArray, scroll, state) {
|
|
|
2324
2332
|
}
|
|
2325
2333
|
return -1;
|
|
2326
2334
|
}
|
|
2327
|
-
function getActiveStickyIndices(ctx, state,
|
|
2335
|
+
function getActiveStickyIndices(ctx, state, stickyHeaderIndices) {
|
|
2328
2336
|
return new Set(
|
|
2329
|
-
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))
|
|
2330
2338
|
);
|
|
2331
2339
|
}
|
|
2332
|
-
function handleStickyActivation(ctx, state,
|
|
2340
|
+
function handleStickyActivation(ctx, state, stickyHeaderIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
|
|
2333
2341
|
var _a3;
|
|
2334
|
-
const activeIndices = getActiveStickyIndices(ctx, state,
|
|
2342
|
+
const activeIndices = getActiveStickyIndices(ctx, state, stickyHeaderIndices);
|
|
2335
2343
|
state.activeStickyIndex = currentStickyIdx >= 0 ? stickyArray[currentStickyIdx] : void 0;
|
|
2336
2344
|
for (let offset = 0; offset <= 1; offset++) {
|
|
2337
2345
|
const idx = currentStickyIdx - offset;
|
|
@@ -2467,6 +2475,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2467
2475
|
}
|
|
2468
2476
|
const startIndex = dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
|
|
2469
2477
|
updateItemPositions(ctx, state, dataChanged, {
|
|
2478
|
+
doMVCP,
|
|
2470
2479
|
forceFullUpdate: !!forceFullItemPositions,
|
|
2471
2480
|
scrollBottomBuffered,
|
|
2472
2481
|
startIndex
|
|
@@ -2761,6 +2770,7 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
|
|
|
2761
2770
|
});
|
|
2762
2771
|
return true;
|
|
2763
2772
|
}
|
|
2773
|
+
return false;
|
|
2764
2774
|
}
|
|
2765
2775
|
|
|
2766
2776
|
// src/utils/updateAveragesOnDataChange.ts
|
|
@@ -2929,6 +2939,25 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2929
2939
|
setCanRender(true);
|
|
2930
2940
|
}
|
|
2931
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
|
+
|
|
2932
2961
|
// src/core/ScrollAdjustHandler.ts
|
|
2933
2962
|
var ScrollAdjustHandler = class {
|
|
2934
2963
|
constructor(ctx) {
|
|
@@ -2964,12 +2993,7 @@ var ScrollAdjustHandler = class {
|
|
|
2964
2993
|
set$(this.context, "scrollAdjustPending", this.pendingAdjust);
|
|
2965
2994
|
} else {
|
|
2966
2995
|
this.appliedAdjust += add;
|
|
2967
|
-
|
|
2968
|
-
if (this.mounted) {
|
|
2969
|
-
setter();
|
|
2970
|
-
} else {
|
|
2971
|
-
requestAnimationFrame(setter);
|
|
2972
|
-
}
|
|
2996
|
+
set$(this.context, "scrollAdjust", this.appliedAdjust);
|
|
2973
2997
|
}
|
|
2974
2998
|
}
|
|
2975
2999
|
setMounted() {
|
|
@@ -3130,7 +3154,7 @@ function RefreshControl(_props) {
|
|
|
3130
3154
|
}
|
|
3131
3155
|
|
|
3132
3156
|
// src/platform/useStickyScrollHandler.ts
|
|
3133
|
-
function useStickyScrollHandler(
|
|
3157
|
+
function useStickyScrollHandler(_stickyHeaderIndices, _horizontal, _ctx, onScroll2) {
|
|
3134
3158
|
return onScroll2;
|
|
3135
3159
|
}
|
|
3136
3160
|
|
|
@@ -3353,7 +3377,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3353
3377
|
ListHeaderComponent,
|
|
3354
3378
|
maintainScrollAtEnd = false,
|
|
3355
3379
|
maintainScrollAtEndThreshold = 0.1,
|
|
3356
|
-
maintainVisibleContentPosition =
|
|
3380
|
+
maintainVisibleContentPosition = false,
|
|
3357
3381
|
numColumns: numColumnsProp = 1,
|
|
3358
3382
|
onEndReached,
|
|
3359
3383
|
onEndReachedThreshold = 0.5,
|
|
@@ -3375,7 +3399,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3375
3399
|
renderItem,
|
|
3376
3400
|
scrollEventThrottle,
|
|
3377
3401
|
snapToIndices,
|
|
3378
|
-
|
|
3402
|
+
stickyHeaderIndices: stickyHeaderIndicesProp,
|
|
3403
|
+
stickyIndices: stickyIndicesDeprecated,
|
|
3379
3404
|
style: styleProp,
|
|
3380
3405
|
suggestEstimatedItemSize,
|
|
3381
3406
|
viewabilityConfig,
|
|
@@ -3397,6 +3422,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3397
3422
|
const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
|
|
3398
3423
|
const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
|
|
3399
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
|
+
}
|
|
3400
3432
|
const refState = React3.useRef();
|
|
3401
3433
|
if (!refState.current) {
|
|
3402
3434
|
if (!ctx.internalState) {
|
|
@@ -3508,8 +3540,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3508
3540
|
renderItem,
|
|
3509
3541
|
scrollBuffer,
|
|
3510
3542
|
snapToIndices,
|
|
3511
|
-
stickyIndicesArr:
|
|
3512
|
-
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(",")]),
|
|
3513
3545
|
stylePaddingBottom: stylePaddingBottomState,
|
|
3514
3546
|
stylePaddingTop: stylePaddingTopState,
|
|
3515
3547
|
suggestEstimatedItemSize: !!suggestEstimatedItemSize
|
|
@@ -3529,7 +3561,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3529
3561
|
setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
|
|
3530
3562
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
3531
3563
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
3532
|
-
if (
|
|
3564
|
+
if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3533
3565
|
if (state.scroll < 0) {
|
|
3534
3566
|
paddingDiff += state.scroll;
|
|
3535
3567
|
}
|
|
@@ -3577,7 +3609,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3577
3609
|
state.initialScroll = updatedInitialScroll;
|
|
3578
3610
|
refState.current.isStartReached = clampedOffset < refState.current.scrollLength * onStartReachedThreshold;
|
|
3579
3611
|
return clampedOffset;
|
|
3580
|
-
}, [renderNum
|
|
3612
|
+
}, [renderNum]);
|
|
3581
3613
|
if (isFirstLocal || didDataChangeLocal || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
3582
3614
|
refState.current.lastBatchingAction = Date.now();
|
|
3583
3615
|
if (!keyExtractorProp && !isFirstLocal && didDataChangeLocal) {
|
|
@@ -3615,7 +3647,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3615
3647
|
precomputedWithViewOffset: true
|
|
3616
3648
|
});
|
|
3617
3649
|
}
|
|
3618
|
-
}, [initialContentOffset
|
|
3650
|
+
}, [initialContentOffset]);
|
|
3619
3651
|
const onLayoutChange = React3.useCallback((layout) => {
|
|
3620
3652
|
doInitialScroll();
|
|
3621
3653
|
handleLayout(ctx, state, layout, setCanRender);
|
|
@@ -3677,7 +3709,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3677
3709
|
}),
|
|
3678
3710
|
[]
|
|
3679
3711
|
);
|
|
3680
|
-
const onScrollHandler = useStickyScrollHandler(
|
|
3712
|
+
const onScrollHandler = useStickyScrollHandler(stickyHeaderIndices, horizontal, ctx, fns.onScroll);
|
|
3681
3713
|
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
3682
3714
|
ListComponent,
|
|
3683
3715
|
{
|
|
@@ -3719,7 +3751,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3719
3751
|
scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
|
|
3720
3752
|
scrollEventThrottle: 16 ,
|
|
3721
3753
|
snapToIndices,
|
|
3722
|
-
|
|
3754
|
+
stickyHeaderIndices,
|
|
3723
3755
|
style,
|
|
3724
3756
|
updateItemSize: fns.updateItemSize,
|
|
3725
3757
|
waitForInitialLayout
|