@legendapp/list 3.0.0-beta.11 → 3.0.0-beta.12
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 +1 -0
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +68 -43
- package/index.mjs +68 -43
- package/index.native.d.mts +2 -2
- package/index.native.d.ts +2 -2
- package/index.native.js +69 -44
- package/index.native.mjs +69 -44
- package/package.json +1 -1
- package/section-list.d.mts +1 -1
- package/section-list.d.ts +1 -1
- package/section-list.js +68 -43
- package/section-list.mjs +68 -43
- package/section-list.native.d.mts +1 -1
- package/section-list.native.d.ts +1 -1
- package/section-list.native.js +69 -44
- package/section-list.native.mjs +69 -44
- package/{types-1Hgg1rTO.d.mts → types-C83aU7VI.d.mts} +17 -7
- package/{types-1Hgg1rTO.d.ts → types-C83aU7VI.d.ts} +17 -7
package/section-list.js
CHANGED
|
@@ -1071,7 +1071,6 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1071
1071
|
getRenderedItem: getRenderedItem2,
|
|
1072
1072
|
updateItemSize: updateItemSize2,
|
|
1073
1073
|
refScrollView,
|
|
1074
|
-
maintainVisibleContentPosition,
|
|
1075
1074
|
renderScrollComponent,
|
|
1076
1075
|
scrollAdjustHandler,
|
|
1077
1076
|
onLayoutHeader,
|
|
@@ -1080,6 +1079,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1080
1079
|
...rest
|
|
1081
1080
|
}) {
|
|
1082
1081
|
const ctx = useStateContext();
|
|
1082
|
+
const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
|
|
1083
1083
|
const ScrollComponent = renderScrollComponent ? React3.useMemo(
|
|
1084
1084
|
() => React3__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
1085
1085
|
[renderScrollComponent]
|
|
@@ -1097,7 +1097,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1097
1097
|
],
|
|
1098
1098
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
1099
1099
|
horizontal,
|
|
1100
|
-
maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
|
|
1100
|
+
maintainVisibleContentPosition: maintainVisibleContentPosition.scroll || maintainVisibleContentPosition.dataChanges ? { minIndexForVisible: 0 } : void 0,
|
|
1101
1101
|
onLayout,
|
|
1102
1102
|
onScroll: onScroll2,
|
|
1103
1103
|
ref: refScrollView,
|
|
@@ -1641,14 +1641,16 @@ function requestAdjust(ctx, positionDiff, dataChanged) {
|
|
|
1641
1641
|
function prepareMVCP(ctx, dataChanged) {
|
|
1642
1642
|
const state = ctx.state;
|
|
1643
1643
|
const { idsInView, positions, props } = state;
|
|
1644
|
-
const {
|
|
1644
|
+
const {
|
|
1645
|
+
maintainVisibleContentPosition: { dataChanges: mvcpDataChanges, scroll: mvcpScroll }
|
|
1646
|
+
} = props;
|
|
1645
1647
|
const scrollingTo = state.scrollingTo;
|
|
1646
1648
|
let prevPosition;
|
|
1647
1649
|
let targetId;
|
|
1648
1650
|
const idsInViewWithPositions = [];
|
|
1649
1651
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1650
1652
|
const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
|
|
1651
|
-
const shouldMVCP =
|
|
1653
|
+
const shouldMVCP = dataChanged ? mvcpDataChanges : mvcpScroll;
|
|
1652
1654
|
const indexByKey = state.indexByKey;
|
|
1653
1655
|
if (shouldMVCP) {
|
|
1654
1656
|
if (scrollTarget !== void 0) {
|
|
@@ -1671,7 +1673,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1671
1673
|
}
|
|
1672
1674
|
return () => {
|
|
1673
1675
|
let positionDiff = 0;
|
|
1674
|
-
if (dataChanged && targetId === void 0 &&
|
|
1676
|
+
if (dataChanged && targetId === void 0 && mvcpDataChanges) {
|
|
1675
1677
|
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1676
1678
|
const { id, position } = idsInViewWithPositions[i];
|
|
1677
1679
|
const newPosition = positions.get(id);
|
|
@@ -1805,39 +1807,40 @@ function updateTotalSize(ctx) {
|
|
|
1805
1807
|
// src/utils/getScrollVelocity.ts
|
|
1806
1808
|
var getScrollVelocity = (state) => {
|
|
1807
1809
|
const { scrollHistory } = state;
|
|
1808
|
-
|
|
1809
|
-
if (
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
const currentDirection = nextEntry.scroll - entry.scroll;
|
|
1821
|
-
if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
|
|
1822
|
-
start = i;
|
|
1823
|
-
break;
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1810
|
+
const newestIndex = scrollHistory.length - 1;
|
|
1811
|
+
if (newestIndex < 1) {
|
|
1812
|
+
return 0;
|
|
1813
|
+
}
|
|
1814
|
+
const newest = scrollHistory[newestIndex];
|
|
1815
|
+
const now = Date.now();
|
|
1816
|
+
let direction = 0;
|
|
1817
|
+
for (let i = newestIndex; i > 0; i--) {
|
|
1818
|
+
const delta = scrollHistory[i].scroll - scrollHistory[i - 1].scroll;
|
|
1819
|
+
if (delta !== 0) {
|
|
1820
|
+
direction = Math.sign(delta);
|
|
1821
|
+
break;
|
|
1826
1822
|
}
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1823
|
+
}
|
|
1824
|
+
if (direction === 0) {
|
|
1825
|
+
return 0;
|
|
1826
|
+
}
|
|
1827
|
+
let oldest = newest;
|
|
1828
|
+
for (let i = newestIndex - 1; i >= 0; i--) {
|
|
1829
|
+
const current = scrollHistory[i];
|
|
1830
|
+
const next = scrollHistory[i + 1];
|
|
1831
|
+
const delta = next.scroll - current.scroll;
|
|
1832
|
+
const deltaSign = Math.sign(delta);
|
|
1833
|
+
if (deltaSign !== 0 && deltaSign !== direction) {
|
|
1834
|
+
break;
|
|
1833
1835
|
}
|
|
1834
|
-
if (
|
|
1835
|
-
|
|
1836
|
-
const timeDiff = newest.time - oldest.time;
|
|
1837
|
-
velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
|
|
1836
|
+
if (now - current.time > 1e3) {
|
|
1837
|
+
break;
|
|
1838
1838
|
}
|
|
1839
|
+
oldest = current;
|
|
1839
1840
|
}
|
|
1840
|
-
|
|
1841
|
+
const scrollDiff = newest.scroll - oldest.scroll;
|
|
1842
|
+
const timeDiff = newest.time - oldest.time;
|
|
1843
|
+
return timeDiff > 0 ? scrollDiff / timeDiff : 0;
|
|
1841
1844
|
};
|
|
1842
1845
|
|
|
1843
1846
|
// src/utils/updateSnapToOffsets.ts
|
|
@@ -2767,7 +2770,7 @@ function checkFinishedScrollFrame(ctx) {
|
|
|
2767
2770
|
if (scrollingTo) {
|
|
2768
2771
|
const { state } = ctx;
|
|
2769
2772
|
state.animFrameCheckFinishedScroll = void 0;
|
|
2770
|
-
const scroll = state.
|
|
2773
|
+
const scroll = state.scrollPending;
|
|
2771
2774
|
const adjust = state.scrollAdjustHandler.getAdjust();
|
|
2772
2775
|
const clampedTargetOffset = clampScrollOffset(ctx, scrollingTo.offset - (scrollingTo.viewOffset || 0));
|
|
2773
2776
|
const maxOffset = clampScrollOffset(ctx, scroll);
|
|
@@ -3022,7 +3025,6 @@ function onScroll(ctx, event) {
|
|
|
3022
3025
|
return;
|
|
3023
3026
|
}
|
|
3024
3027
|
let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
3025
|
-
state.scrollPending = newScroll;
|
|
3026
3028
|
if (state.scrollingTo) {
|
|
3027
3029
|
const maxOffset = clampScrollOffset(ctx, newScroll);
|
|
3028
3030
|
if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
|
|
@@ -3036,8 +3038,11 @@ function onScroll(ctx, event) {
|
|
|
3036
3038
|
return;
|
|
3037
3039
|
}
|
|
3038
3040
|
}
|
|
3041
|
+
state.scrollPending = newScroll;
|
|
3039
3042
|
updateScroll(ctx, newScroll);
|
|
3040
|
-
|
|
3043
|
+
if (state.scrollingTo) {
|
|
3044
|
+
checkFinishedScroll(ctx);
|
|
3045
|
+
}
|
|
3041
3046
|
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
3042
3047
|
}
|
|
3043
3048
|
|
|
@@ -3372,6 +3377,24 @@ function getRenderedItem(ctx, key) {
|
|
|
3372
3377
|
}
|
|
3373
3378
|
return { index, item: data[index], renderedItem };
|
|
3374
3379
|
}
|
|
3380
|
+
|
|
3381
|
+
// src/utils/normalizeMaintainVisibleContentPosition.ts
|
|
3382
|
+
function normalizeMaintainVisibleContentPosition(value) {
|
|
3383
|
+
var _a3, _b;
|
|
3384
|
+
if (value === true) {
|
|
3385
|
+
return { dataChanges: true, scroll: true };
|
|
3386
|
+
}
|
|
3387
|
+
if (value && typeof value === "object") {
|
|
3388
|
+
return {
|
|
3389
|
+
dataChanges: (_a3 = value.dataChanges) != null ? _a3 : false,
|
|
3390
|
+
scroll: (_b = value.scroll) != null ? _b : true
|
|
3391
|
+
};
|
|
3392
|
+
}
|
|
3393
|
+
if (value === false) {
|
|
3394
|
+
return { dataChanges: false, scroll: false };
|
|
3395
|
+
}
|
|
3396
|
+
return { dataChanges: false, scroll: true };
|
|
3397
|
+
}
|
|
3375
3398
|
function useThrottleDebounce(mode) {
|
|
3376
3399
|
const timeoutRef = React3.useRef(null);
|
|
3377
3400
|
const lastCallTimeRef = React3.useRef(0);
|
|
@@ -3466,7 +3489,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3466
3489
|
ListHeaderComponent,
|
|
3467
3490
|
maintainScrollAtEnd = false,
|
|
3468
3491
|
maintainScrollAtEndThreshold = 0.1,
|
|
3469
|
-
maintainVisibleContentPosition
|
|
3492
|
+
maintainVisibleContentPosition: maintainVisibleContentPositionProp,
|
|
3470
3493
|
numColumns: numColumnsProp = 1,
|
|
3471
3494
|
onEndReached,
|
|
3472
3495
|
onEndReachedThreshold = 0.5,
|
|
@@ -3504,6 +3527,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3504
3527
|
const style = { ...StyleSheet.flatten(styleProp) };
|
|
3505
3528
|
const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
|
|
3506
3529
|
const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
|
|
3530
|
+
const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
|
|
3531
|
+
maintainVisibleContentPositionProp
|
|
3532
|
+
);
|
|
3507
3533
|
const [renderNum, setRenderNum] = React3.useState(0);
|
|
3508
3534
|
const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
|
|
3509
3535
|
const [canRender, setCanRender] = React3__namespace.useState(!IsNewArchitecture);
|
|
@@ -3588,7 +3614,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3588
3614
|
};
|
|
3589
3615
|
const internalState = ctx.state;
|
|
3590
3616
|
internalState.triggerCalculateItemsInView = (params) => calculateItemsInView(ctx, params);
|
|
3591
|
-
set$(ctx, "maintainVisibleContentPosition",
|
|
3617
|
+
set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
|
|
3592
3618
|
set$(ctx, "extraData", extraData);
|
|
3593
3619
|
}
|
|
3594
3620
|
refState.current = ctx.state;
|
|
@@ -3619,7 +3645,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3619
3645
|
keyExtractor,
|
|
3620
3646
|
maintainScrollAtEnd,
|
|
3621
3647
|
maintainScrollAtEndThreshold,
|
|
3622
|
-
maintainVisibleContentPosition,
|
|
3648
|
+
maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
|
|
3623
3649
|
numColumns: numColumnsProp,
|
|
3624
3650
|
onEndReached,
|
|
3625
3651
|
onEndReachedThreshold,
|
|
@@ -3654,7 +3680,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3654
3680
|
setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
|
|
3655
3681
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
3656
3682
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
3657
|
-
if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3683
|
+
if (maintainVisibleContentPositionConfig.scroll && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3658
3684
|
if (state.scroll < 0) {
|
|
3659
3685
|
paddingDiff += state.scroll;
|
|
3660
3686
|
}
|
|
@@ -3689,7 +3715,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3689
3715
|
value = 0;
|
|
3690
3716
|
}
|
|
3691
3717
|
if (!value) {
|
|
3692
|
-
|
|
3718
|
+
setInitialRenderState(ctx, { didInitialScroll: true });
|
|
3693
3719
|
}
|
|
3694
3720
|
return value;
|
|
3695
3721
|
}, [renderNum]);
|
|
@@ -3811,7 +3837,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3811
3837
|
initialContentOffset,
|
|
3812
3838
|
ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
|
|
3813
3839
|
ListHeaderComponent,
|
|
3814
|
-
maintainVisibleContentPosition,
|
|
3815
3840
|
onLayout,
|
|
3816
3841
|
onLayoutHeader,
|
|
3817
3842
|
onMomentumScrollEnd: fns.onMomentumScrollEnd,
|
package/section-list.mjs
CHANGED
|
@@ -1050,7 +1050,6 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1050
1050
|
getRenderedItem: getRenderedItem2,
|
|
1051
1051
|
updateItemSize: updateItemSize2,
|
|
1052
1052
|
refScrollView,
|
|
1053
|
-
maintainVisibleContentPosition,
|
|
1054
1053
|
renderScrollComponent,
|
|
1055
1054
|
scrollAdjustHandler,
|
|
1056
1055
|
onLayoutHeader,
|
|
@@ -1059,6 +1058,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1059
1058
|
...rest
|
|
1060
1059
|
}) {
|
|
1061
1060
|
const ctx = useStateContext();
|
|
1061
|
+
const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
|
|
1062
1062
|
const ScrollComponent = renderScrollComponent ? useMemo(
|
|
1063
1063
|
() => React3.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
1064
1064
|
[renderScrollComponent]
|
|
@@ -1076,7 +1076,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
1076
1076
|
],
|
|
1077
1077
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
1078
1078
|
horizontal,
|
|
1079
|
-
maintainVisibleContentPosition: maintainVisibleContentPosition ? { minIndexForVisible: 0 } : void 0,
|
|
1079
|
+
maintainVisibleContentPosition: maintainVisibleContentPosition.scroll || maintainVisibleContentPosition.dataChanges ? { minIndexForVisible: 0 } : void 0,
|
|
1080
1080
|
onLayout,
|
|
1081
1081
|
onScroll: onScroll2,
|
|
1082
1082
|
ref: refScrollView,
|
|
@@ -1620,14 +1620,16 @@ function requestAdjust(ctx, positionDiff, dataChanged) {
|
|
|
1620
1620
|
function prepareMVCP(ctx, dataChanged) {
|
|
1621
1621
|
const state = ctx.state;
|
|
1622
1622
|
const { idsInView, positions, props } = state;
|
|
1623
|
-
const {
|
|
1623
|
+
const {
|
|
1624
|
+
maintainVisibleContentPosition: { dataChanges: mvcpDataChanges, scroll: mvcpScroll }
|
|
1625
|
+
} = props;
|
|
1624
1626
|
const scrollingTo = state.scrollingTo;
|
|
1625
1627
|
let prevPosition;
|
|
1626
1628
|
let targetId;
|
|
1627
1629
|
const idsInViewWithPositions = [];
|
|
1628
1630
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
1629
1631
|
const scrollingToViewPosition = scrollingTo == null ? void 0 : scrollingTo.viewPosition;
|
|
1630
|
-
const shouldMVCP =
|
|
1632
|
+
const shouldMVCP = dataChanged ? mvcpDataChanges : mvcpScroll;
|
|
1631
1633
|
const indexByKey = state.indexByKey;
|
|
1632
1634
|
if (shouldMVCP) {
|
|
1633
1635
|
if (scrollTarget !== void 0) {
|
|
@@ -1650,7 +1652,7 @@ function prepareMVCP(ctx, dataChanged) {
|
|
|
1650
1652
|
}
|
|
1651
1653
|
return () => {
|
|
1652
1654
|
let positionDiff = 0;
|
|
1653
|
-
if (dataChanged && targetId === void 0 &&
|
|
1655
|
+
if (dataChanged && targetId === void 0 && mvcpDataChanges) {
|
|
1654
1656
|
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1655
1657
|
const { id, position } = idsInViewWithPositions[i];
|
|
1656
1658
|
const newPosition = positions.get(id);
|
|
@@ -1784,39 +1786,40 @@ function updateTotalSize(ctx) {
|
|
|
1784
1786
|
// src/utils/getScrollVelocity.ts
|
|
1785
1787
|
var getScrollVelocity = (state) => {
|
|
1786
1788
|
const { scrollHistory } = state;
|
|
1787
|
-
|
|
1788
|
-
if (
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
const currentDirection = nextEntry.scroll - entry.scroll;
|
|
1800
|
-
if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
|
|
1801
|
-
start = i;
|
|
1802
|
-
break;
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1789
|
+
const newestIndex = scrollHistory.length - 1;
|
|
1790
|
+
if (newestIndex < 1) {
|
|
1791
|
+
return 0;
|
|
1792
|
+
}
|
|
1793
|
+
const newest = scrollHistory[newestIndex];
|
|
1794
|
+
const now = Date.now();
|
|
1795
|
+
let direction = 0;
|
|
1796
|
+
for (let i = newestIndex; i > 0; i--) {
|
|
1797
|
+
const delta = scrollHistory[i].scroll - scrollHistory[i - 1].scroll;
|
|
1798
|
+
if (delta !== 0) {
|
|
1799
|
+
direction = Math.sign(delta);
|
|
1800
|
+
break;
|
|
1805
1801
|
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1802
|
+
}
|
|
1803
|
+
if (direction === 0) {
|
|
1804
|
+
return 0;
|
|
1805
|
+
}
|
|
1806
|
+
let oldest = newest;
|
|
1807
|
+
for (let i = newestIndex - 1; i >= 0; i--) {
|
|
1808
|
+
const current = scrollHistory[i];
|
|
1809
|
+
const next = scrollHistory[i + 1];
|
|
1810
|
+
const delta = next.scroll - current.scroll;
|
|
1811
|
+
const deltaSign = Math.sign(delta);
|
|
1812
|
+
if (deltaSign !== 0 && deltaSign !== direction) {
|
|
1813
|
+
break;
|
|
1812
1814
|
}
|
|
1813
|
-
if (
|
|
1814
|
-
|
|
1815
|
-
const timeDiff = newest.time - oldest.time;
|
|
1816
|
-
velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
|
|
1815
|
+
if (now - current.time > 1e3) {
|
|
1816
|
+
break;
|
|
1817
1817
|
}
|
|
1818
|
+
oldest = current;
|
|
1818
1819
|
}
|
|
1819
|
-
|
|
1820
|
+
const scrollDiff = newest.scroll - oldest.scroll;
|
|
1821
|
+
const timeDiff = newest.time - oldest.time;
|
|
1822
|
+
return timeDiff > 0 ? scrollDiff / timeDiff : 0;
|
|
1820
1823
|
};
|
|
1821
1824
|
|
|
1822
1825
|
// src/utils/updateSnapToOffsets.ts
|
|
@@ -2746,7 +2749,7 @@ function checkFinishedScrollFrame(ctx) {
|
|
|
2746
2749
|
if (scrollingTo) {
|
|
2747
2750
|
const { state } = ctx;
|
|
2748
2751
|
state.animFrameCheckFinishedScroll = void 0;
|
|
2749
|
-
const scroll = state.
|
|
2752
|
+
const scroll = state.scrollPending;
|
|
2750
2753
|
const adjust = state.scrollAdjustHandler.getAdjust();
|
|
2751
2754
|
const clampedTargetOffset = clampScrollOffset(ctx, scrollingTo.offset - (scrollingTo.viewOffset || 0));
|
|
2752
2755
|
const maxOffset = clampScrollOffset(ctx, scroll);
|
|
@@ -3001,7 +3004,6 @@ function onScroll(ctx, event) {
|
|
|
3001
3004
|
return;
|
|
3002
3005
|
}
|
|
3003
3006
|
let newScroll = event.nativeEvent.contentOffset[state.props.horizontal ? "x" : "y"];
|
|
3004
|
-
state.scrollPending = newScroll;
|
|
3005
3007
|
if (state.scrollingTo) {
|
|
3006
3008
|
const maxOffset = clampScrollOffset(ctx, newScroll);
|
|
3007
3009
|
if (newScroll !== maxOffset && Math.abs(newScroll - maxOffset) > 1) {
|
|
@@ -3015,8 +3017,11 @@ function onScroll(ctx, event) {
|
|
|
3015
3017
|
return;
|
|
3016
3018
|
}
|
|
3017
3019
|
}
|
|
3020
|
+
state.scrollPending = newScroll;
|
|
3018
3021
|
updateScroll(ctx, newScroll);
|
|
3019
|
-
|
|
3022
|
+
if (state.scrollingTo) {
|
|
3023
|
+
checkFinishedScroll(ctx);
|
|
3024
|
+
}
|
|
3020
3025
|
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
3021
3026
|
}
|
|
3022
3027
|
|
|
@@ -3351,6 +3356,24 @@ function getRenderedItem(ctx, key) {
|
|
|
3351
3356
|
}
|
|
3352
3357
|
return { index, item: data[index], renderedItem };
|
|
3353
3358
|
}
|
|
3359
|
+
|
|
3360
|
+
// src/utils/normalizeMaintainVisibleContentPosition.ts
|
|
3361
|
+
function normalizeMaintainVisibleContentPosition(value) {
|
|
3362
|
+
var _a3, _b;
|
|
3363
|
+
if (value === true) {
|
|
3364
|
+
return { dataChanges: true, scroll: true };
|
|
3365
|
+
}
|
|
3366
|
+
if (value && typeof value === "object") {
|
|
3367
|
+
return {
|
|
3368
|
+
dataChanges: (_a3 = value.dataChanges) != null ? _a3 : false,
|
|
3369
|
+
scroll: (_b = value.scroll) != null ? _b : true
|
|
3370
|
+
};
|
|
3371
|
+
}
|
|
3372
|
+
if (value === false) {
|
|
3373
|
+
return { dataChanges: false, scroll: false };
|
|
3374
|
+
}
|
|
3375
|
+
return { dataChanges: false, scroll: true };
|
|
3376
|
+
}
|
|
3354
3377
|
function useThrottleDebounce(mode) {
|
|
3355
3378
|
const timeoutRef = useRef(null);
|
|
3356
3379
|
const lastCallTimeRef = useRef(0);
|
|
@@ -3445,7 +3468,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3445
3468
|
ListHeaderComponent,
|
|
3446
3469
|
maintainScrollAtEnd = false,
|
|
3447
3470
|
maintainScrollAtEndThreshold = 0.1,
|
|
3448
|
-
maintainVisibleContentPosition
|
|
3471
|
+
maintainVisibleContentPosition: maintainVisibleContentPositionProp,
|
|
3449
3472
|
numColumns: numColumnsProp = 1,
|
|
3450
3473
|
onEndReached,
|
|
3451
3474
|
onEndReachedThreshold = 0.5,
|
|
@@ -3483,6 +3506,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3483
3506
|
const style = { ...StyleSheet.flatten(styleProp) };
|
|
3484
3507
|
const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
|
|
3485
3508
|
const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
|
|
3509
|
+
const maintainVisibleContentPositionConfig = normalizeMaintainVisibleContentPosition(
|
|
3510
|
+
maintainVisibleContentPositionProp
|
|
3511
|
+
);
|
|
3486
3512
|
const [renderNum, setRenderNum] = useState(0);
|
|
3487
3513
|
const initialScrollProp = initialScrollAtEnd ? { index: Math.max(0, dataProp.length - 1), viewOffset: -stylePaddingBottomState } : initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
|
|
3488
3514
|
const [canRender, setCanRender] = React3.useState(!IsNewArchitecture);
|
|
@@ -3567,7 +3593,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3567
3593
|
};
|
|
3568
3594
|
const internalState = ctx.state;
|
|
3569
3595
|
internalState.triggerCalculateItemsInView = (params) => calculateItemsInView(ctx, params);
|
|
3570
|
-
set$(ctx, "maintainVisibleContentPosition",
|
|
3596
|
+
set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPositionConfig);
|
|
3571
3597
|
set$(ctx, "extraData", extraData);
|
|
3572
3598
|
}
|
|
3573
3599
|
refState.current = ctx.state;
|
|
@@ -3598,7 +3624,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3598
3624
|
keyExtractor,
|
|
3599
3625
|
maintainScrollAtEnd,
|
|
3600
3626
|
maintainScrollAtEndThreshold,
|
|
3601
|
-
maintainVisibleContentPosition,
|
|
3627
|
+
maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
|
|
3602
3628
|
numColumns: numColumnsProp,
|
|
3603
3629
|
onEndReached,
|
|
3604
3630
|
onEndReachedThreshold,
|
|
@@ -3633,7 +3659,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3633
3659
|
setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
|
|
3634
3660
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
3635
3661
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
3636
|
-
if (paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3662
|
+
if (maintainVisibleContentPositionConfig.scroll && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
3637
3663
|
if (state.scroll < 0) {
|
|
3638
3664
|
paddingDiff += state.scroll;
|
|
3639
3665
|
}
|
|
@@ -3668,7 +3694,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3668
3694
|
value = 0;
|
|
3669
3695
|
}
|
|
3670
3696
|
if (!value) {
|
|
3671
|
-
|
|
3697
|
+
setInitialRenderState(ctx, { didInitialScroll: true });
|
|
3672
3698
|
}
|
|
3673
3699
|
return value;
|
|
3674
3700
|
}, [renderNum]);
|
|
@@ -3790,7 +3816,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3790
3816
|
initialContentOffset,
|
|
3791
3817
|
ListEmptyComponent: dataProp.length === 0 ? ListEmptyComponent : void 0,
|
|
3792
3818
|
ListHeaderComponent,
|
|
3793
|
-
maintainVisibleContentPosition,
|
|
3794
3819
|
onLayout,
|
|
3795
3820
|
onLayoutHeader,
|
|
3796
3821
|
onMomentumScrollEnd: fns.onMomentumScrollEnd,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_native from 'react-native';
|
|
2
2
|
import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { a as LegendListRef, L as LegendListProps } from './types-
|
|
4
|
+
import { a as LegendListRef, L as LegendListProps } from './types-C83aU7VI.mjs';
|
|
5
5
|
import 'react-native-reanimated';
|
|
6
6
|
|
|
7
7
|
type SectionListSeparatorProps<ItemT, SectionT> = {
|
package/section-list.native.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_native from 'react-native';
|
|
2
2
|
import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { a as LegendListRef, L as LegendListProps } from './types-
|
|
4
|
+
import { a as LegendListRef, L as LegendListProps } from './types-C83aU7VI.js';
|
|
5
5
|
import 'react-native-reanimated';
|
|
6
6
|
|
|
7
7
|
type SectionListSeparatorProps<ItemT, SectionT> = {
|