@legendapp/list 2.1.0-beta.13 → 2.1.0-beta.14
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 +664 -8
- package/index.d.ts +664 -8
- package/index.js +143 -175
- package/index.mjs +143 -175
- package/index.native.d.mts +664 -8
- package/index.native.d.ts +664 -8
- package/index.native.js +144 -154
- package/index.native.mjs +144 -154
- package/package.json +1 -1
- package/section-list.d.mts +0 -113
- package/section-list.d.ts +0 -113
- package/section-list.js +0 -3924
- package/section-list.mjs +0 -3903
- package/section-list.native.d.mts +0 -113
- package/section-list.native.d.ts +0 -113
- package/section-list.native.js +0 -3703
- package/section-list.native.mjs +0 -3682
- package/types-JPHClxiw.d.mts +0 -670
- package/types-JPHClxiw.d.ts +0 -670
- package/types-YNdphn_A.d.mts +0 -670
- package/types-YNdphn_A.d.ts +0 -670
package/index.js
CHANGED
|
@@ -504,17 +504,13 @@ function useOnLayoutSync({
|
|
|
504
504
|
};
|
|
505
505
|
const rect = element.getBoundingClientRect();
|
|
506
506
|
emit(toLayout(rect), true);
|
|
507
|
-
let prevRect = rect;
|
|
508
507
|
return createResizeObserver(element, (entry) => {
|
|
509
508
|
var _a4;
|
|
510
509
|
const target = entry.target instanceof HTMLElement ? entry.target : void 0;
|
|
511
510
|
const rect2 = (_a4 = entry.contentRect) != null ? _a4 : target == null ? void 0 : target.getBoundingClientRect();
|
|
512
|
-
|
|
513
|
-
prevRect = rect2;
|
|
514
|
-
emit(toLayout(rect2), false);
|
|
515
|
-
}
|
|
511
|
+
emit(toLayout(rect2), false);
|
|
516
512
|
});
|
|
517
|
-
}, deps
|
|
513
|
+
}, deps);
|
|
518
514
|
return {};
|
|
519
515
|
}
|
|
520
516
|
function toLayout(rect) {
|
|
@@ -1062,26 +1058,8 @@ function ScrollAdjust() {
|
|
|
1062
1058
|
if (scrollView && scrollOffset !== lastScrollOffsetRef.current) {
|
|
1063
1059
|
const scrollDelta = scrollOffset - lastScrollOffsetRef.current;
|
|
1064
1060
|
if (scrollDelta !== 0) {
|
|
1065
|
-
|
|
1066
|
-
|
|
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
|
-
}
|
|
1061
|
+
scrollView.scrollBy(0, scrollDelta);
|
|
1062
|
+
console.log("ScrollAdjust (web scrollBy)", scrollDelta, "total offset:", scrollOffset);
|
|
1085
1063
|
}
|
|
1086
1064
|
lastScrollOffsetRef.current = scrollOffset;
|
|
1087
1065
|
}
|
|
@@ -1135,7 +1113,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1135
1113
|
scrollAdjustHandler,
|
|
1136
1114
|
onLayoutHeader,
|
|
1137
1115
|
snapToIndices,
|
|
1138
|
-
|
|
1116
|
+
stickyIndices,
|
|
1139
1117
|
...rest
|
|
1140
1118
|
}) {
|
|
1141
1119
|
const ctx = useStateContext();
|
|
@@ -1170,7 +1148,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1170
1148
|
ScrollComponent: snapToIndices ? ScrollComponent : void 0,
|
|
1171
1149
|
style
|
|
1172
1150
|
},
|
|
1173
|
-
/* @__PURE__ */ React3__namespace.createElement(ScrollAdjust, null),
|
|
1151
|
+
maintainVisibleContentPosition && /* @__PURE__ */ React3__namespace.createElement(ScrollAdjust, null),
|
|
1174
1152
|
ENABLE_DEVMODE ? /* @__PURE__ */ React3__namespace.createElement(PaddingDevMode, null) : /* @__PURE__ */ React3__namespace.createElement(Padding, null),
|
|
1175
1153
|
ListHeaderComponent && /* @__PURE__ */ React3__namespace.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
|
|
1176
1154
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
@@ -1361,67 +1339,6 @@ function calculateOffsetWithOffsetPosition(ctx, state, offsetParam, params) {
|
|
|
1361
1339
|
return offset;
|
|
1362
1340
|
}
|
|
1363
1341
|
|
|
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
|
-
|
|
1425
1342
|
// src/utils/checkThreshold.ts
|
|
1426
1343
|
var HYSTERESIS_MULTIPLIER = 1.3;
|
|
1427
1344
|
var checkThreshold = (distance, atThreshold, threshold, wasReached, snapshot, context, onReached, setSnapshot) => {
|
|
@@ -1532,7 +1449,24 @@ function checkAtTop(state) {
|
|
|
1532
1449
|
);
|
|
1533
1450
|
}
|
|
1534
1451
|
|
|
1535
|
-
// src/core/
|
|
1452
|
+
// src/core/onScroll.ts
|
|
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
|
+
}
|
|
1536
1470
|
function updateScroll(ctx, state, newScroll, forceUpdate) {
|
|
1537
1471
|
var _a3;
|
|
1538
1472
|
const scrollingTo = peek$(ctx, "scrollingTo");
|
|
@@ -1575,15 +1509,73 @@ function updateScroll(ctx, state, newScroll, forceUpdate) {
|
|
|
1575
1509
|
}
|
|
1576
1510
|
}
|
|
1577
1511
|
|
|
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
|
+
|
|
1578
1573
|
// src/utils/requestAdjust.ts
|
|
1579
1574
|
function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
1580
1575
|
if (Math.abs(positionDiff) > 0.1) {
|
|
1581
1576
|
const doit = () => {
|
|
1582
1577
|
{
|
|
1583
1578
|
state.scrollAdjustHandler.requestAdjust(positionDiff);
|
|
1584
|
-
if (state.adjustingFromInitialMount) {
|
|
1585
|
-
state.adjustingFromInitialMount--;
|
|
1586
|
-
}
|
|
1587
1579
|
}
|
|
1588
1580
|
};
|
|
1589
1581
|
state.scroll += positionDiff;
|
|
@@ -1592,7 +1584,6 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
|
1592
1584
|
if (didLayout) {
|
|
1593
1585
|
doit();
|
|
1594
1586
|
} else {
|
|
1595
|
-
state.adjustingFromInitialMount = (state.adjustingFromInitialMount || 0) + 1;
|
|
1596
1587
|
requestAnimationFrame(doit);
|
|
1597
1588
|
}
|
|
1598
1589
|
}
|
|
@@ -1652,16 +1643,18 @@ function ensureInitialAnchor(ctx, state) {
|
|
|
1652
1643
|
|
|
1653
1644
|
// src/core/mvcp.ts
|
|
1654
1645
|
function prepareMVCP(ctx, state, dataChanged) {
|
|
1655
|
-
const {
|
|
1656
|
-
|
|
1646
|
+
const {
|
|
1647
|
+
idsInView,
|
|
1648
|
+
positions,
|
|
1649
|
+
props: { maintainVisibleContentPosition }
|
|
1650
|
+
} = state;
|
|
1657
1651
|
const scrollingTo = peek$(ctx, "scrollingTo");
|
|
1658
1652
|
let prevPosition;
|
|
1659
1653
|
let targetId;
|
|
1660
1654
|
const idsInViewWithPositions = [];
|
|
1661
1655
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
if (shouldMVCP) {
|
|
1656
|
+
if (maintainVisibleContentPosition) {
|
|
1657
|
+
const indexByKey = state.indexByKey;
|
|
1665
1658
|
if (scrollTarget !== void 0) {
|
|
1666
1659
|
targetId = getId(state, scrollTarget);
|
|
1667
1660
|
} else if (idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
|
|
@@ -1674,44 +1667,44 @@ function prepareMVCP(ctx, state, dataChanged) {
|
|
|
1674
1667
|
}
|
|
1675
1668
|
}
|
|
1676
1669
|
} else {
|
|
1677
|
-
targetId = idsInView.find((id) => indexByKey.get(id) !== void 0);
|
|
1670
|
+
targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
|
|
1678
1671
|
}
|
|
1679
1672
|
}
|
|
1680
1673
|
if (targetId !== void 0) {
|
|
1681
1674
|
prevPosition = positions.get(targetId);
|
|
1682
1675
|
}
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1676
|
+
}
|
|
1677
|
+
return () => {
|
|
1678
|
+
let positionDiff;
|
|
1679
|
+
if (dataChanged && targetId === void 0) {
|
|
1680
|
+
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1681
|
+
const { id, position } = idsInViewWithPositions[i];
|
|
1682
|
+
const newPosition = positions.get(id);
|
|
1683
|
+
if (newPosition !== void 0) {
|
|
1684
|
+
positionDiff = newPosition - position;
|
|
1685
|
+
break;
|
|
1693
1686
|
}
|
|
1694
1687
|
}
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1688
|
+
}
|
|
1689
|
+
if (targetId !== void 0 && prevPosition !== void 0) {
|
|
1690
|
+
const newPosition = positions.get(targetId);
|
|
1691
|
+
if (newPosition !== void 0) {
|
|
1692
|
+
const totalSize = getContentSize(ctx);
|
|
1693
|
+
let diff = newPosition - prevPosition;
|
|
1694
|
+
if (diff !== 0 && state.scroll + state.scrollLength > totalSize) {
|
|
1695
|
+
if (diff > 0) {
|
|
1696
|
+
diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
|
|
1697
|
+
} else {
|
|
1698
|
+
diff = 0;
|
|
1706
1699
|
}
|
|
1707
|
-
positionDiff = diff;
|
|
1708
1700
|
}
|
|
1701
|
+
positionDiff = diff;
|
|
1709
1702
|
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1703
|
+
}
|
|
1704
|
+
if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
|
|
1705
|
+
requestAdjust(ctx, state, positionDiff);
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1715
1708
|
}
|
|
1716
1709
|
|
|
1717
1710
|
// src/core/prepareColumnStartState.ts
|
|
@@ -1853,8 +1846,7 @@ function updateSnapToOffsets(ctx, state) {
|
|
|
1853
1846
|
}
|
|
1854
1847
|
|
|
1855
1848
|
// src/core/updateItemPositions.ts
|
|
1856
|
-
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false
|
|
1857
|
-
doMVCP: false,
|
|
1849
|
+
function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false } = {
|
|
1858
1850
|
forceFullUpdate: false,
|
|
1859
1851
|
scrollBottomBuffered: -1,
|
|
1860
1852
|
startIndex: 0
|
|
@@ -1866,7 +1858,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1866
1858
|
positions,
|
|
1867
1859
|
idCache,
|
|
1868
1860
|
sizesKnown,
|
|
1869
|
-
props: { getEstimatedItemSize, snapToIndices, enableAverages }
|
|
1861
|
+
props: { getEstimatedItemSize, snapToIndices, enableAverages, maintainVisibleContentPosition }
|
|
1870
1862
|
} = state;
|
|
1871
1863
|
const data = state.props.data;
|
|
1872
1864
|
const dataLength = data.length;
|
|
@@ -1877,7 +1869,7 @@ function updateItemPositions(ctx, state, dataChanged, { startIndex, scrollBottom
|
|
|
1877
1869
|
const shouldOptimize = !forceFullUpdate && !dataChanged && Math.abs(getScrollVelocity(state)) > 0;
|
|
1878
1870
|
const maxVisibleArea = scrollBottomBuffered + 1e3;
|
|
1879
1871
|
const useAverageSize = enableAverages && !getEstimatedItemSize;
|
|
1880
|
-
const preferCachedSize =
|
|
1872
|
+
const preferCachedSize = maintainVisibleContentPosition && (dataChanged || state.scrollAdjustHandler.getAdjust() !== 0 || ((_a3 = peek$(ctx, "scrollAdjustPending")) != null ? _a3 : 0) !== 0);
|
|
1881
1873
|
let currentRowTop = 0;
|
|
1882
1874
|
let column = 1;
|
|
1883
1875
|
let maxSizeInRow = 0;
|
|
@@ -2332,14 +2324,14 @@ function findCurrentStickyIndex(stickyArray, scroll, state) {
|
|
|
2332
2324
|
}
|
|
2333
2325
|
return -1;
|
|
2334
2326
|
}
|
|
2335
|
-
function getActiveStickyIndices(ctx, state,
|
|
2327
|
+
function getActiveStickyIndices(ctx, state, stickyIndices) {
|
|
2336
2328
|
return new Set(
|
|
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 &&
|
|
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 && stickyIndices.has(idx))
|
|
2338
2330
|
);
|
|
2339
2331
|
}
|
|
2340
|
-
function handleStickyActivation(ctx, state,
|
|
2332
|
+
function handleStickyActivation(ctx, state, stickyIndices, stickyArray, currentStickyIdx, needNewContainers, startBuffered, endBuffered) {
|
|
2341
2333
|
var _a3;
|
|
2342
|
-
const activeIndices = getActiveStickyIndices(ctx, state,
|
|
2334
|
+
const activeIndices = getActiveStickyIndices(ctx, state, stickyIndices);
|
|
2343
2335
|
state.activeStickyIndex = currentStickyIdx >= 0 ? stickyArray[currentStickyIdx] : void 0;
|
|
2344
2336
|
for (let offset = 0; offset <= 1; offset++) {
|
|
2345
2337
|
const idx = currentStickyIdx - offset;
|
|
@@ -2475,7 +2467,6 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2475
2467
|
}
|
|
2476
2468
|
const startIndex = dataChanged ? 0 : (_b = minIndexSizeChanged != null ? minIndexSizeChanged : state.startBuffered) != null ? _b : 0;
|
|
2477
2469
|
updateItemPositions(ctx, state, dataChanged, {
|
|
2478
|
-
doMVCP,
|
|
2479
2470
|
forceFullUpdate: !!forceFullItemPositions,
|
|
2480
2471
|
scrollBottomBuffered,
|
|
2481
2472
|
startIndex
|
|
@@ -2770,7 +2761,6 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
|
|
|
2770
2761
|
});
|
|
2771
2762
|
return true;
|
|
2772
2763
|
}
|
|
2773
|
-
return false;
|
|
2774
2764
|
}
|
|
2775
2765
|
|
|
2776
2766
|
// src/utils/updateAveragesOnDataChange.ts
|
|
@@ -2939,25 +2929,6 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2939
2929
|
setCanRender(true);
|
|
2940
2930
|
}
|
|
2941
2931
|
|
|
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
|
-
|
|
2961
2932
|
// src/core/ScrollAdjustHandler.ts
|
|
2962
2933
|
var ScrollAdjustHandler = class {
|
|
2963
2934
|
constructor(ctx) {
|
|
@@ -2993,7 +2964,12 @@ var ScrollAdjustHandler = class {
|
|
|
2993
2964
|
set$(this.context, "scrollAdjustPending", this.pendingAdjust);
|
|
2994
2965
|
} else {
|
|
2995
2966
|
this.appliedAdjust += add;
|
|
2996
|
-
set$(this.context, "scrollAdjust", this.appliedAdjust);
|
|
2967
|
+
const setter = () => set$(this.context, "scrollAdjust", this.appliedAdjust);
|
|
2968
|
+
if (this.mounted) {
|
|
2969
|
+
setter();
|
|
2970
|
+
} else {
|
|
2971
|
+
requestAnimationFrame(setter);
|
|
2972
|
+
}
|
|
2997
2973
|
}
|
|
2998
2974
|
}
|
|
2999
2975
|
setMounted() {
|
|
@@ -3154,7 +3130,7 @@ function RefreshControl(_props) {
|
|
|
3154
3130
|
}
|
|
3155
3131
|
|
|
3156
3132
|
// src/platform/useStickyScrollHandler.ts
|
|
3157
|
-
function useStickyScrollHandler(
|
|
3133
|
+
function useStickyScrollHandler(_stickyIndices, _horizontal, _ctx, onScroll2) {
|
|
3158
3134
|
return onScroll2;
|
|
3159
3135
|
}
|
|
3160
3136
|
|
|
@@ -3377,7 +3353,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3377
3353
|
ListHeaderComponent,
|
|
3378
3354
|
maintainScrollAtEnd = false,
|
|
3379
3355
|
maintainScrollAtEndThreshold = 0.1,
|
|
3380
|
-
maintainVisibleContentPosition =
|
|
3356
|
+
maintainVisibleContentPosition = true,
|
|
3381
3357
|
numColumns: numColumnsProp = 1,
|
|
3382
3358
|
onEndReached,
|
|
3383
3359
|
onEndReachedThreshold = 0.5,
|
|
@@ -3399,8 +3375,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3399
3375
|
renderItem,
|
|
3400
3376
|
scrollEventThrottle,
|
|
3401
3377
|
snapToIndices,
|
|
3402
|
-
|
|
3403
|
-
stickyIndices: stickyIndicesDeprecated,
|
|
3378
|
+
stickyIndices,
|
|
3404
3379
|
style: styleProp,
|
|
3405
3380
|
suggestEstimatedItemSize,
|
|
3406
3381
|
viewabilityConfig,
|
|
@@ -3422,13 +3397,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3422
3397
|
const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
|
|
3423
3398
|
const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
|
|
3424
3399
|
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
|
-
}
|
|
3432
3400
|
const refState = React3.useRef();
|
|
3433
3401
|
if (!refState.current) {
|
|
3434
3402
|
if (!ctx.internalState) {
|
|
@@ -3540,8 +3508,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3540
3508
|
renderItem,
|
|
3541
3509
|
scrollBuffer,
|
|
3542
3510
|
snapToIndices,
|
|
3543
|
-
stickyIndicesArr:
|
|
3544
|
-
stickyIndicesSet: React3.useMemo(() => new Set(
|
|
3511
|
+
stickyIndicesArr: stickyIndices != null ? stickyIndices : [],
|
|
3512
|
+
stickyIndicesSet: React3.useMemo(() => new Set(stickyIndices != null ? stickyIndices : []), [stickyIndices == null ? void 0 : stickyIndices.join(",")]),
|
|
3545
3513
|
stylePaddingBottom: stylePaddingBottomState,
|
|
3546
3514
|
stylePaddingTop: stylePaddingTopState,
|
|
3547
3515
|
suggestEstimatedItemSize: !!suggestEstimatedItemSize
|
|
@@ -3561,7 +3529,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3561
3529
|
setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
|
|
3562
3530
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
3563
3531
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
3564
|
-
if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3532
|
+
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3565
3533
|
if (state.scroll < 0) {
|
|
3566
3534
|
paddingDiff += state.scroll;
|
|
3567
3535
|
}
|
|
@@ -3609,7 +3577,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3609
3577
|
state.initialScroll = updatedInitialScroll;
|
|
3610
3578
|
refState.current.isStartReached = clampedOffset < refState.current.scrollLength * onStartReachedThreshold;
|
|
3611
3579
|
return clampedOffset;
|
|
3612
|
-
}, [renderNum]);
|
|
3580
|
+
}, [renderNum, state.initialScroll]);
|
|
3613
3581
|
if (isFirstLocal || didDataChangeLocal || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
3614
3582
|
refState.current.lastBatchingAction = Date.now();
|
|
3615
3583
|
if (!keyExtractorProp && !isFirstLocal && didDataChangeLocal) {
|
|
@@ -3647,7 +3615,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3647
3615
|
precomputedWithViewOffset: true
|
|
3648
3616
|
});
|
|
3649
3617
|
}
|
|
3650
|
-
}, [initialContentOffset]);
|
|
3618
|
+
}, [initialContentOffset, state.initialScroll]);
|
|
3651
3619
|
const onLayoutChange = React3.useCallback((layout) => {
|
|
3652
3620
|
doInitialScroll();
|
|
3653
3621
|
handleLayout(ctx, state, layout, setCanRender);
|
|
@@ -3709,7 +3677,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3709
3677
|
}),
|
|
3710
3678
|
[]
|
|
3711
3679
|
);
|
|
3712
|
-
const onScrollHandler = useStickyScrollHandler(
|
|
3680
|
+
const onScrollHandler = useStickyScrollHandler(stickyIndices, horizontal, ctx, fns.onScroll);
|
|
3713
3681
|
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
3714
3682
|
ListComponent,
|
|
3715
3683
|
{
|
|
@@ -3751,7 +3719,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3751
3719
|
scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
|
|
3752
3720
|
scrollEventThrottle: 16 ,
|
|
3753
3721
|
snapToIndices,
|
|
3754
|
-
|
|
3722
|
+
stickyIndices,
|
|
3755
3723
|
style,
|
|
3756
3724
|
updateItemSize: fns.updateItemSize,
|
|
3757
3725
|
waitForInitialLayout
|