@legendapp/list 1.0.0-beta.25 → 1.0.0-beta.27
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/README.md +93 -37
- package/animated.d.mts +31 -31
- package/animated.d.ts +31 -31
- package/index.d.mts +234 -72
- package/index.d.ts +234 -72
- package/index.js +122 -67
- package/index.mjs +122 -67
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -571,6 +571,7 @@ var ScrollAdjustHandler = class {
|
|
|
571
571
|
this.appliedAdjust = 0;
|
|
572
572
|
this.busy = false;
|
|
573
573
|
this.isPaused = false;
|
|
574
|
+
this.isDisabled = false;
|
|
574
575
|
this.context = ctx;
|
|
575
576
|
}
|
|
576
577
|
doAjdust() {
|
|
@@ -578,6 +579,9 @@ var ScrollAdjustHandler = class {
|
|
|
578
579
|
this.busy = false;
|
|
579
580
|
}
|
|
580
581
|
requestAdjust(adjust, onAdjusted) {
|
|
582
|
+
if (this.isDisabled) {
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
581
585
|
const oldAdjustTop = peek$(this.context, "scrollAdjust");
|
|
582
586
|
if (oldAdjustTop === adjust) {
|
|
583
587
|
return;
|
|
@@ -595,6 +599,9 @@ var ScrollAdjustHandler = class {
|
|
|
595
599
|
pauseAdjust() {
|
|
596
600
|
this.isPaused = true;
|
|
597
601
|
}
|
|
602
|
+
setDisableAdjust(disable) {
|
|
603
|
+
this.isDisabled = disable;
|
|
604
|
+
}
|
|
598
605
|
// return true if it was paused
|
|
599
606
|
unPauseAdjust() {
|
|
600
607
|
if (this.isPaused) {
|
|
@@ -869,18 +876,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
869
876
|
return 0;
|
|
870
877
|
};
|
|
871
878
|
const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : React6.useMemo(calculateOffsetForIndex, []);
|
|
872
|
-
if (reactNative.Platform.OS === "web") {
|
|
873
|
-
React6.useEffect(() => {
|
|
874
|
-
var _a2;
|
|
875
|
-
if (initialContentOffset) {
|
|
876
|
-
(_a2 = refScroller.current) == null ? void 0 : _a2.scrollTo({
|
|
877
|
-
x: horizontal ? initialContentOffset : 0,
|
|
878
|
-
y: horizontal ? 0 : initialContentOffset,
|
|
879
|
-
animated: false
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
}, []);
|
|
883
|
-
}
|
|
884
879
|
if (!refState.current) {
|
|
885
880
|
const initialScrollLength = reactNative.Dimensions.get("window")[horizontal ? "width" : "height"];
|
|
886
881
|
refState.current = {
|
|
@@ -924,7 +919,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
924
919
|
minIndexSizeChanged: 0,
|
|
925
920
|
numPendingInitialLayout: 0,
|
|
926
921
|
queuedCalculateItemsInView: 0,
|
|
927
|
-
lastBatchingAction: Date.now()
|
|
922
|
+
lastBatchingAction: Date.now(),
|
|
923
|
+
onScroll: onScrollProp
|
|
928
924
|
};
|
|
929
925
|
if (maintainVisibleContentPosition) {
|
|
930
926
|
if (initialScrollIndex) {
|
|
@@ -947,6 +943,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
947
943
|
}
|
|
948
944
|
const didDataChange = refState.current.data !== dataProp;
|
|
949
945
|
refState.current.data = dataProp;
|
|
946
|
+
refState.current.onScroll = onScrollProp;
|
|
950
947
|
const getAnchorElementIndex = () => {
|
|
951
948
|
const state = refState.current;
|
|
952
949
|
if (state.anchorElement) {
|
|
@@ -996,7 +993,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
996
993
|
}, []);
|
|
997
994
|
const getRowHeight = (n) => {
|
|
998
995
|
const { rowHeights, data } = refState.current;
|
|
999
|
-
|
|
996
|
+
const numColumns = peek$(ctx, "numColumns");
|
|
997
|
+
if (numColumns === 1) {
|
|
1000
998
|
const id = getId(n);
|
|
1001
999
|
return getItemSize(id, n, data[n]);
|
|
1002
1000
|
}
|
|
@@ -1004,8 +1002,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1004
1002
|
return rowHeights.get(n) || 0;
|
|
1005
1003
|
}
|
|
1006
1004
|
let rowHeight = 0;
|
|
1007
|
-
const startEl = n *
|
|
1008
|
-
for (let i = startEl; i < startEl +
|
|
1005
|
+
const startEl = n * numColumns;
|
|
1006
|
+
for (let i = startEl; i < startEl + numColumns && i < data.length; i++) {
|
|
1009
1007
|
const id = getId(i);
|
|
1010
1008
|
const size = getItemSize(id, i, data[i]);
|
|
1011
1009
|
rowHeight = Math.max(rowHeight, size);
|
|
@@ -1024,10 +1022,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1024
1022
|
return /* @__PURE__ */ new Map();
|
|
1025
1023
|
}
|
|
1026
1024
|
const map = state.belowAnchorElementPositions || /* @__PURE__ */ new Map();
|
|
1025
|
+
const numColumns = peek$(ctx, "numColumns");
|
|
1027
1026
|
for (let i = anchorIndex - 1; i >= 0; i--) {
|
|
1028
1027
|
const id = getId(i);
|
|
1029
|
-
const rowNumber = Math.floor(i /
|
|
1030
|
-
if (i %
|
|
1028
|
+
const rowNumber = Math.floor(i / numColumns);
|
|
1029
|
+
if (i % numColumns === 0) {
|
|
1031
1030
|
top -= getRowHeight(rowNumber);
|
|
1032
1031
|
}
|
|
1033
1032
|
map.set(id, top);
|
|
@@ -1064,6 +1063,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1064
1063
|
return;
|
|
1065
1064
|
}
|
|
1066
1065
|
const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
|
|
1066
|
+
const numColumns = peek$(ctx, "numColumns");
|
|
1067
1067
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
1068
1068
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
1069
1069
|
const scroll = scrollState - previousScrollAdjust - topPad;
|
|
@@ -1119,7 +1119,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1119
1119
|
}
|
|
1120
1120
|
}
|
|
1121
1121
|
}
|
|
1122
|
-
const numColumns = peek$(ctx, "numColumns");
|
|
1123
1122
|
const loopStartMod = loopStart % numColumns;
|
|
1124
1123
|
if (loopStartMod > 0) {
|
|
1125
1124
|
loopStart -= loopStartMod;
|
|
@@ -1276,7 +1275,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1276
1275
|
};
|
|
1277
1276
|
const column2 = columns.get(id) || 1;
|
|
1278
1277
|
if (maintainVisibleContentPosition && itemIndex < anchorElementIndex) {
|
|
1279
|
-
const currentRow = Math.floor(itemIndex /
|
|
1278
|
+
const currentRow = Math.floor(itemIndex / numColumns);
|
|
1280
1279
|
const rowHeight = getRowHeight(currentRow);
|
|
1281
1280
|
const elementHeight = getItemSize(id, itemIndex, data[i]);
|
|
1282
1281
|
const diff = rowHeight - elementHeight;
|
|
@@ -1434,13 +1433,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1434
1433
|
}
|
|
1435
1434
|
};
|
|
1436
1435
|
const calcTotalSizesAndPositions = ({ forgetPositions = false }) => {
|
|
1437
|
-
var _a2, _b2, _c2;
|
|
1436
|
+
var _a2, _b2, _c2, _d2;
|
|
1438
1437
|
let totalSize = 0;
|
|
1439
1438
|
let totalSizeBelowIndex = 0;
|
|
1440
1439
|
const indexByKey = /* @__PURE__ */ new Map();
|
|
1441
1440
|
const newPositions = /* @__PURE__ */ new Map();
|
|
1442
1441
|
let column = 1;
|
|
1443
1442
|
let maxSizeInRow = 0;
|
|
1443
|
+
const numColumns = (_a2 = peek$(ctx, "numColumns")) != null ? _a2 : numColumnsProp;
|
|
1444
1444
|
if (!refState.current) {
|
|
1445
1445
|
return;
|
|
1446
1446
|
}
|
|
@@ -1469,8 +1469,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1469
1469
|
id: getId(0)
|
|
1470
1470
|
};
|
|
1471
1471
|
refState.current.anchorElement = newAnchorElement;
|
|
1472
|
-
(
|
|
1473
|
-
(
|
|
1472
|
+
(_b2 = refState.current.belowAnchorElementPositions) == null ? void 0 : _b2.clear();
|
|
1473
|
+
(_c2 = refScroller.current) == null ? void 0 : _c2.scrollTo({ x: 0, y: 0, animated: false });
|
|
1474
1474
|
setTimeout(() => {
|
|
1475
1475
|
calculateItemsInView();
|
|
1476
1476
|
}, 0);
|
|
@@ -1485,7 +1485,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1485
1485
|
} else {
|
|
1486
1486
|
refState.current.startBufferedId = void 0;
|
|
1487
1487
|
}
|
|
1488
|
-
(
|
|
1488
|
+
(_d2 = refScroller.current) == null ? void 0 : _d2.scrollTo({ x: 0, y: 0, animated: false });
|
|
1489
1489
|
setTimeout(() => {
|
|
1490
1490
|
calculateItemsInView();
|
|
1491
1491
|
}, 0);
|
|
@@ -1498,7 +1498,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1498
1498
|
const size = getItemSize(key, i, dataProp[i]);
|
|
1499
1499
|
maxSizeInRow = Math.max(maxSizeInRow, size);
|
|
1500
1500
|
column++;
|
|
1501
|
-
if (column >
|
|
1501
|
+
if (column > numColumns) {
|
|
1502
1502
|
if (maintainVisibleContentPosition && anchorElementIndex !== void 0 && i < anchorElementIndex) {
|
|
1503
1503
|
totalSizeBelowIndex += maxSizeInRow;
|
|
1504
1504
|
}
|
|
@@ -1518,6 +1518,20 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1518
1518
|
addTotalSize(null, totalSize, totalSizeBelowIndex);
|
|
1519
1519
|
};
|
|
1520
1520
|
const isFirst = !refState.current.renderItem;
|
|
1521
|
+
const memoizedLastItemKeys = React6.useMemo(() => {
|
|
1522
|
+
if (!dataProp.length) return /* @__PURE__ */ new Set();
|
|
1523
|
+
return new Set(
|
|
1524
|
+
Array.from({ length: Math.min(numColumnsProp, dataProp.length) }, (_, i) => getId(dataProp.length - 1 - i))
|
|
1525
|
+
);
|
|
1526
|
+
}, [dataProp.length, numColumnsProp, dataProp.slice(-numColumnsProp).toString()]);
|
|
1527
|
+
const initalizeStateVars = () => {
|
|
1528
|
+
set$(ctx, "lastItemKeys", memoizedLastItemKeys);
|
|
1529
|
+
set$(ctx, "numColumns", numColumnsProp);
|
|
1530
|
+
set$(ctx, "stylePaddingTop", stylePaddingTop);
|
|
1531
|
+
};
|
|
1532
|
+
if (isFirst) {
|
|
1533
|
+
initalizeStateVars();
|
|
1534
|
+
}
|
|
1521
1535
|
if (isFirst || didDataChange || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
1522
1536
|
refState.current.lastBatchingAction = Date.now();
|
|
1523
1537
|
if (!keyExtractorProp && !isFirst && didDataChange) {
|
|
@@ -1527,30 +1541,19 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1527
1541
|
calcTotalSizesAndPositions({ forgetPositions: false });
|
|
1528
1542
|
}
|
|
1529
1543
|
React6.useEffect(() => {
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1544
|
+
const didAllocateContainers = doInitialAllocateContainers();
|
|
1545
|
+
if (!didAllocateContainers) {
|
|
1546
|
+
checkResetContainers(
|
|
1547
|
+
/*isFirst*/
|
|
1548
|
+
isFirst
|
|
1549
|
+
);
|
|
1550
|
+
}
|
|
1534
1551
|
}, [isFirst, dataProp, numColumnsProp]);
|
|
1535
1552
|
React6.useEffect(() => {
|
|
1536
1553
|
set$(ctx, "extraData", extraData);
|
|
1537
1554
|
}, [extraData]);
|
|
1538
1555
|
refState.current.renderItem = renderItem;
|
|
1539
|
-
const memoizedLastItemKeys = React6.useMemo(() => {
|
|
1540
|
-
if (!dataProp.length) return [];
|
|
1541
|
-
return new Set(
|
|
1542
|
-
Array.from({ length: Math.min(numColumnsProp, dataProp.length) }, (_, i) => getId(dataProp.length - 1 - i))
|
|
1543
|
-
);
|
|
1544
|
-
}, [dataProp.length, numColumnsProp, dataProp.slice(-numColumnsProp).toString()]);
|
|
1545
1556
|
const stylePaddingTop = (_d = (_c = (_a = reactNative.StyleSheet.flatten(style)) == null ? void 0 : _a.paddingTop) != null ? _c : (_b = reactNative.StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _b.paddingTop) != null ? _d : 0;
|
|
1546
|
-
const initalizeStateVars = () => {
|
|
1547
|
-
set$(ctx, "lastItemKeys", memoizedLastItemKeys);
|
|
1548
|
-
set$(ctx, "numColumns", numColumnsProp);
|
|
1549
|
-
set$(ctx, "stylePaddingTop", stylePaddingTop);
|
|
1550
|
-
};
|
|
1551
|
-
if (isFirst) {
|
|
1552
|
-
initalizeStateVars();
|
|
1553
|
-
}
|
|
1554
1557
|
React6.useEffect(initalizeStateVars, [memoizedLastItemKeys, numColumnsProp, stylePaddingTop]);
|
|
1555
1558
|
const getRenderedItem = React6.useCallback((key) => {
|
|
1556
1559
|
var _a2, _b2;
|
|
@@ -1578,6 +1581,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1578
1581
|
const renderedItem = (_b2 = (_a2 = refState.current).renderItem) == null ? void 0 : _b2.call(_a2, {
|
|
1579
1582
|
item: data[index],
|
|
1580
1583
|
index,
|
|
1584
|
+
extraData: peek$(ctx, "extraData"),
|
|
1581
1585
|
useViewability: useViewability2,
|
|
1582
1586
|
useViewabilityAmount: useViewabilityAmount2,
|
|
1583
1587
|
useRecyclingEffect: useRecyclingEffect2,
|
|
@@ -1588,9 +1592,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1588
1592
|
const doInitialAllocateContainers = () => {
|
|
1589
1593
|
var _a2;
|
|
1590
1594
|
const state = refState.current;
|
|
1591
|
-
const scrollLength = state
|
|
1592
|
-
if (scrollLength > 0 && !peek$(ctx, "numContainers")) {
|
|
1593
|
-
const averageItemSize = (_a2 = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0,
|
|
1595
|
+
const { scrollLength, data } = state;
|
|
1596
|
+
if (scrollLength > 0 && data.length > 0 && !peek$(ctx, "numContainers")) {
|
|
1597
|
+
const averageItemSize = (_a2 = estimatedItemSize != null ? estimatedItemSize : getEstimatedItemSize == null ? void 0 : getEstimatedItemSize(0, data[0])) != null ? _a2 : DEFAULT_ITEM_SIZE;
|
|
1594
1598
|
const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize) * numColumnsProp;
|
|
1595
1599
|
for (let i = 0; i < numContainers; i++) {
|
|
1596
1600
|
set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
|
|
@@ -1605,6 +1609,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1605
1609
|
} else {
|
|
1606
1610
|
calculateItemsInView();
|
|
1607
1611
|
}
|
|
1612
|
+
return true;
|
|
1608
1613
|
}
|
|
1609
1614
|
};
|
|
1610
1615
|
useInit(() => {
|
|
@@ -1625,14 +1630,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1625
1630
|
state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, index) : index;
|
|
1626
1631
|
const prevSize = getItemSize(itemKey, index, data);
|
|
1627
1632
|
let needsCalculate = false;
|
|
1633
|
+
let needsUpdateContainersDidLayout = false;
|
|
1628
1634
|
if (state.numPendingInitialLayout > 0) {
|
|
1629
1635
|
state.numPendingInitialLayout--;
|
|
1630
1636
|
if (state.numPendingInitialLayout === 0) {
|
|
1631
1637
|
needsCalculate = true;
|
|
1632
1638
|
state.numPendingInitialLayout = -1;
|
|
1633
|
-
|
|
1634
|
-
set$(ctx, "containersDidLayout", true);
|
|
1635
|
-
});
|
|
1639
|
+
needsUpdateContainersDidLayout = true;
|
|
1636
1640
|
}
|
|
1637
1641
|
}
|
|
1638
1642
|
if (!prevSize || Math.abs(prevSize - size) > 0.5) {
|
|
@@ -1684,13 +1688,27 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1684
1688
|
if (needsCalculate) {
|
|
1685
1689
|
const scrollVelocity = state.scrollVelocity;
|
|
1686
1690
|
if ((Number.isNaN(scrollVelocity) || Math.abs(scrollVelocity) < 1) && (!waitForInitialLayout || state.numPendingInitialLayout < 0)) {
|
|
1691
|
+
const setDidLayout = () => {
|
|
1692
|
+
set$(ctx, "containersDidLayout", true);
|
|
1693
|
+
if (reactNative.Platform.OS === "web") {
|
|
1694
|
+
setTimeout(() => {
|
|
1695
|
+
state.scrollAdjustHandler.setDisableAdjust(false);
|
|
1696
|
+
}, 32);
|
|
1697
|
+
}
|
|
1698
|
+
};
|
|
1687
1699
|
if (Date.now() - state.lastBatchingAction < 500) {
|
|
1688
1700
|
state.queuedCalculateItemsInView = requestAnimationFrame(() => {
|
|
1689
1701
|
state.queuedCalculateItemsInView = void 0;
|
|
1690
1702
|
calculateItemsInView();
|
|
1703
|
+
if (needsUpdateContainersDidLayout) {
|
|
1704
|
+
setDidLayout();
|
|
1705
|
+
}
|
|
1691
1706
|
});
|
|
1692
1707
|
} else {
|
|
1693
1708
|
calculateItemsInView();
|
|
1709
|
+
if (needsUpdateContainersDidLayout) {
|
|
1710
|
+
queueMicrotask(setDidLayout);
|
|
1711
|
+
}
|
|
1694
1712
|
}
|
|
1695
1713
|
}
|
|
1696
1714
|
}
|
|
@@ -1701,6 +1719,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1701
1719
|
const didChange = scrollLength !== state.scrollLength;
|
|
1702
1720
|
state.scrollLength = scrollLength;
|
|
1703
1721
|
state.lastBatchingAction = Date.now();
|
|
1722
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
1704
1723
|
doInitialAllocateContainers();
|
|
1705
1724
|
doMaintainScrollAtEnd(false);
|
|
1706
1725
|
doUpdatePaddingTop();
|
|
@@ -1724,18 +1743,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1724
1743
|
}, []);
|
|
1725
1744
|
const handleScroll = React6.useCallback(
|
|
1726
1745
|
(event, fromSelf) => {
|
|
1727
|
-
var _a2, _b2, _c2;
|
|
1746
|
+
var _a2, _b2, _c2, _d2;
|
|
1728
1747
|
if (((_b2 = (_a2 = event.nativeEvent) == null ? void 0 : _a2.contentSize) == null ? void 0 : _b2.height) === 0 && ((_c2 = event.nativeEvent.contentSize) == null ? void 0 : _c2.width) === 0) {
|
|
1729
1748
|
return;
|
|
1730
1749
|
}
|
|
1731
1750
|
const state = refState.current;
|
|
1732
|
-
|
|
1751
|
+
const newScroll = event.nativeEvent.contentOffset[horizontal ? "x" : "y"];
|
|
1752
|
+
if (state.ignoreScrollFromCalcTotal && newScroll !== 0) {
|
|
1733
1753
|
return;
|
|
1734
1754
|
}
|
|
1735
1755
|
state.hasScrolled = true;
|
|
1736
1756
|
state.lastBatchingAction = Date.now();
|
|
1737
1757
|
const currentTime = performance.now();
|
|
1738
|
-
const newScroll = event.nativeEvent.contentOffset[horizontal ? "x" : "y"];
|
|
1739
1758
|
if (!(state.scrollHistory.length === 0 && newScroll === initialContentOffset)) {
|
|
1740
1759
|
state.scrollHistory.push({ scroll: newScroll, time: currentTime });
|
|
1741
1760
|
}
|
|
@@ -1765,7 +1784,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1765
1784
|
checkAtBottom();
|
|
1766
1785
|
checkAtTop();
|
|
1767
1786
|
if (!fromSelf) {
|
|
1768
|
-
|
|
1787
|
+
(_d2 = state.onScroll) == null ? void 0 : _d2.call(state, event);
|
|
1769
1788
|
}
|
|
1770
1789
|
},
|
|
1771
1790
|
[]
|
|
@@ -1785,39 +1804,39 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1785
1804
|
let firstIndexScrollPostion = firstIndexOffset - viewOffset;
|
|
1786
1805
|
const diff = Math.abs(state.scroll - firstIndexScrollPostion);
|
|
1787
1806
|
const needsReanchoring = maintainVisibleContentPosition && diff > 100;
|
|
1807
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
1788
1808
|
if (needsReanchoring) {
|
|
1789
1809
|
const id = getId(index);
|
|
1790
1810
|
state.anchorElement = { id, coordinate: firstIndexOffset };
|
|
1791
1811
|
(_a2 = state.belowAnchorElementPositions) == null ? void 0 : _a2.clear();
|
|
1792
1812
|
state.positions.clear();
|
|
1793
1813
|
calcTotalSizesAndPositions({ forgetPositions: true });
|
|
1794
|
-
state.scrollForNextCalculateItemsInView = void 0;
|
|
1795
1814
|
state.startBufferedId = id;
|
|
1796
1815
|
state.minIndexSizeChanged = index;
|
|
1797
1816
|
firstIndexScrollPostion = firstIndexOffset - viewOffset + state.scrollAdjustHandler.getAppliedAdjust();
|
|
1798
1817
|
}
|
|
1799
|
-
state.scrollAdjustHandler.
|
|
1818
|
+
state.scrollAdjustHandler.setDisableAdjust(true);
|
|
1800
1819
|
setTimeout(
|
|
1801
1820
|
() => {
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
refState.current.scrollVelocity = 0;
|
|
1805
|
-
refState.current.scrollHistory = [];
|
|
1806
|
-
calculateItemsInView();
|
|
1807
|
-
}
|
|
1821
|
+
state.scrollAdjustHandler.setDisableAdjust(false);
|
|
1822
|
+
calculateItemsInView();
|
|
1808
1823
|
},
|
|
1809
|
-
animated ?
|
|
1824
|
+
animated ? 150 : 50
|
|
1810
1825
|
);
|
|
1811
1826
|
if (viewPosition) {
|
|
1812
1827
|
firstIndexScrollPostion -= viewPosition * (state.scrollLength - getItemSize(getId(index), index, state.data[index]));
|
|
1813
1828
|
}
|
|
1814
1829
|
const offset = horizontal ? { x: firstIndexScrollPostion, y: 0 } : { x: 0, y: firstIndexScrollPostion };
|
|
1815
|
-
|
|
1816
|
-
|
|
1830
|
+
refScroller.current.scrollTo({ ...offset, animated });
|
|
1831
|
+
const totalSizeWithScrollAdjust = peek$(ctx, "totalSizeWithScrollAdjust");
|
|
1832
|
+
if (maintainVisibleContentPosition && totalSizeWithScrollAdjust - firstIndexScrollPostion < state.scrollLength) {
|
|
1833
|
+
const doScrollTo = () => {
|
|
1817
1834
|
refScroller.current.scrollTo({ ...offset, animated });
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
|
|
1835
|
+
};
|
|
1836
|
+
setTimeout(doScrollTo, animated ? 150 : 50);
|
|
1837
|
+
if (animated) {
|
|
1838
|
+
setTimeout(doScrollTo, 350);
|
|
1839
|
+
}
|
|
1821
1840
|
}
|
|
1822
1841
|
};
|
|
1823
1842
|
return {
|
|
@@ -1842,6 +1861,42 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1842
1861
|
},
|
|
1843
1862
|
[]
|
|
1844
1863
|
);
|
|
1864
|
+
if (reactNative.Platform.OS === "web") {
|
|
1865
|
+
React6.useEffect(() => {
|
|
1866
|
+
var _a2, _b2;
|
|
1867
|
+
if (initialContentOffset) {
|
|
1868
|
+
(_a2 = refState.current) == null ? void 0 : _a2.scrollAdjustHandler.setDisableAdjust(true);
|
|
1869
|
+
(_b2 = refScroller.current) == null ? void 0 : _b2.scrollTo({
|
|
1870
|
+
x: horizontal ? initialContentOffset : 0,
|
|
1871
|
+
y: horizontal ? 0 : initialContentOffset,
|
|
1872
|
+
animated: false
|
|
1873
|
+
});
|
|
1874
|
+
setTimeout(() => {
|
|
1875
|
+
var _a3;
|
|
1876
|
+
(_a3 = refState.current) == null ? void 0 : _a3.scrollAdjustHandler.setDisableAdjust(false);
|
|
1877
|
+
}, 0);
|
|
1878
|
+
}
|
|
1879
|
+
}, []);
|
|
1880
|
+
}
|
|
1881
|
+
if (isFirst) {
|
|
1882
|
+
refState.current.scrollAdjustHandler.setDisableAdjust(true);
|
|
1883
|
+
}
|
|
1884
|
+
React6.useEffect(() => {
|
|
1885
|
+
refState.current.scrollAdjustHandler.setDisableAdjust(false);
|
|
1886
|
+
if (initialContentOffset) {
|
|
1887
|
+
const doScrollTo = () => {
|
|
1888
|
+
var _a2;
|
|
1889
|
+
(_a2 = refScroller.current) == null ? void 0 : _a2.scrollTo({
|
|
1890
|
+
x: horizontal ? initialContentOffset : 0,
|
|
1891
|
+
y: horizontal ? 0 : initialContentOffset,
|
|
1892
|
+
animated: false
|
|
1893
|
+
});
|
|
1894
|
+
calculateItemsInView();
|
|
1895
|
+
};
|
|
1896
|
+
setTimeout(doScrollTo, 32);
|
|
1897
|
+
setTimeout(doScrollTo, 300);
|
|
1898
|
+
}
|
|
1899
|
+
}, []);
|
|
1845
1900
|
return /* @__PURE__ */ React6__namespace.createElement(React6__namespace.Fragment, null, /* @__PURE__ */ React6__namespace.createElement(
|
|
1846
1901
|
ListComponent,
|
|
1847
1902
|
{
|