@legendapp/list 2.1.0-beta.10 → 2.1.0-beta.11
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 +12 -4
- package/index.d.ts +12 -4
- package/index.js +127 -34
- package/index.mjs +127 -34
- package/index.native.d.mts +12 -4
- package/index.native.d.ts +12 -4
- package/index.native.js +152 -43
- package/index.native.mjs +152 -43
- package/package.json +1 -1
package/index.native.d.mts
CHANGED
|
@@ -395,12 +395,14 @@ interface InternalState {
|
|
|
395
395
|
refScroller: React.RefObject<ScrollView>;
|
|
396
396
|
loadStartTime: number;
|
|
397
397
|
initialScroll: ScrollIndexWithOffsetAndContentOffset | undefined;
|
|
398
|
+
initialAnchor?: InitialScrollAnchor;
|
|
398
399
|
lastLayout: LayoutRectangle | undefined;
|
|
399
400
|
timeoutSetPaddingTop?: any;
|
|
400
401
|
activeStickyIndex: number | undefined;
|
|
401
402
|
stickyContainers: Map<number, number>;
|
|
402
403
|
stickyContainerPool: Set<number>;
|
|
403
404
|
scrollProcessingEnabled: boolean;
|
|
405
|
+
pendingTotalSize?: number;
|
|
404
406
|
props: {
|
|
405
407
|
alignItemsAtEnd: boolean;
|
|
406
408
|
data: readonly any[];
|
|
@@ -638,14 +640,20 @@ type TypedMemo = <T extends React.ComponentType<any>>(Component: T, propsAreEqua
|
|
|
638
640
|
declare const typedMemo: TypedMemo;
|
|
639
641
|
interface ScrollIndexWithOffset {
|
|
640
642
|
index: number;
|
|
641
|
-
viewOffset
|
|
643
|
+
viewOffset?: number;
|
|
644
|
+
viewPosition?: number;
|
|
642
645
|
}
|
|
643
646
|
interface ScrollIndexWithOffsetPosition extends ScrollIndexWithOffset {
|
|
644
|
-
viewPosition
|
|
647
|
+
viewPosition?: number;
|
|
645
648
|
}
|
|
646
|
-
interface ScrollIndexWithOffsetAndContentOffset extends
|
|
649
|
+
interface ScrollIndexWithOffsetAndContentOffset extends ScrollIndexWithOffsetPosition {
|
|
647
650
|
contentOffset?: number;
|
|
648
651
|
}
|
|
652
|
+
interface InitialScrollAnchor extends ScrollIndexWithOffsetPosition {
|
|
653
|
+
attempts?: number;
|
|
654
|
+
lastDelta?: number;
|
|
655
|
+
settledTicks?: number;
|
|
656
|
+
}
|
|
649
657
|
type GetRenderedItemResult<ItemT> = {
|
|
650
658
|
index: number;
|
|
651
659
|
item: ItemT;
|
|
@@ -668,4 +676,4 @@ declare function useListScrollSize(): {
|
|
|
668
676
|
};
|
|
669
677
|
declare function useSyncLayout(): () => void;
|
|
670
678
|
|
|
671
|
-
export { type ColumnWrapperStyle, type GetRenderedItem, type GetRenderedItemResult, type InternalState, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type MaintainScrollAtEndOptions, type OnViewableItemsChanged, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type ScrollState, type ScrollTarget, type ThresholdSnapshot, type TypedForwardRef, type TypedMemo, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
|
|
679
|
+
export { type ColumnWrapperStyle, type GetRenderedItem, type GetRenderedItemResult, type InitialScrollAnchor, type InternalState, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type MaintainScrollAtEndOptions, type OnViewableItemsChanged, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type ScrollState, type ScrollTarget, type ThresholdSnapshot, type TypedForwardRef, type TypedMemo, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
|
package/index.native.d.ts
CHANGED
|
@@ -395,12 +395,14 @@ interface InternalState {
|
|
|
395
395
|
refScroller: React.RefObject<ScrollView>;
|
|
396
396
|
loadStartTime: number;
|
|
397
397
|
initialScroll: ScrollIndexWithOffsetAndContentOffset | undefined;
|
|
398
|
+
initialAnchor?: InitialScrollAnchor;
|
|
398
399
|
lastLayout: LayoutRectangle | undefined;
|
|
399
400
|
timeoutSetPaddingTop?: any;
|
|
400
401
|
activeStickyIndex: number | undefined;
|
|
401
402
|
stickyContainers: Map<number, number>;
|
|
402
403
|
stickyContainerPool: Set<number>;
|
|
403
404
|
scrollProcessingEnabled: boolean;
|
|
405
|
+
pendingTotalSize?: number;
|
|
404
406
|
props: {
|
|
405
407
|
alignItemsAtEnd: boolean;
|
|
406
408
|
data: readonly any[];
|
|
@@ -638,14 +640,20 @@ type TypedMemo = <T extends React.ComponentType<any>>(Component: T, propsAreEqua
|
|
|
638
640
|
declare const typedMemo: TypedMemo;
|
|
639
641
|
interface ScrollIndexWithOffset {
|
|
640
642
|
index: number;
|
|
641
|
-
viewOffset
|
|
643
|
+
viewOffset?: number;
|
|
644
|
+
viewPosition?: number;
|
|
642
645
|
}
|
|
643
646
|
interface ScrollIndexWithOffsetPosition extends ScrollIndexWithOffset {
|
|
644
|
-
viewPosition
|
|
647
|
+
viewPosition?: number;
|
|
645
648
|
}
|
|
646
|
-
interface ScrollIndexWithOffsetAndContentOffset extends
|
|
649
|
+
interface ScrollIndexWithOffsetAndContentOffset extends ScrollIndexWithOffsetPosition {
|
|
647
650
|
contentOffset?: number;
|
|
648
651
|
}
|
|
652
|
+
interface InitialScrollAnchor extends ScrollIndexWithOffsetPosition {
|
|
653
|
+
attempts?: number;
|
|
654
|
+
lastDelta?: number;
|
|
655
|
+
settledTicks?: number;
|
|
656
|
+
}
|
|
649
657
|
type GetRenderedItemResult<ItemT> = {
|
|
650
658
|
index: number;
|
|
651
659
|
item: ItemT;
|
|
@@ -668,4 +676,4 @@ declare function useListScrollSize(): {
|
|
|
668
676
|
};
|
|
669
677
|
declare function useSyncLayout(): () => void;
|
|
670
678
|
|
|
671
|
-
export { type ColumnWrapperStyle, type GetRenderedItem, type GetRenderedItemResult, type InternalState, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type MaintainScrollAtEndOptions, type OnViewableItemsChanged, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type ScrollState, type ScrollTarget, type ThresholdSnapshot, type TypedForwardRef, type TypedMemo, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
|
|
679
|
+
export { type ColumnWrapperStyle, type GetRenderedItem, type GetRenderedItemResult, type InitialScrollAnchor, type InternalState, LegendList, type LegendListProps, type LegendListPropsBase, type LegendListRecyclingState, type LegendListRef, type LegendListRenderItemProps, type MaintainScrollAtEndOptions, type OnViewableItemsChanged, type ScrollIndexWithOffset, type ScrollIndexWithOffsetAndContentOffset, type ScrollIndexWithOffsetPosition, type ScrollState, type ScrollTarget, type ThresholdSnapshot, type TypedForwardRef, type TypedMemo, type ViewAmountToken, type ViewToken, type ViewabilityAmountCallback, type ViewabilityCallback, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange, typedForwardRef, typedMemo, useIsLastItem, useListScrollSize, useRecyclingEffect, useRecyclingState, useSyncLayout, useViewability, useViewabilityAmount };
|
package/index.native.js
CHANGED
|
@@ -120,11 +120,12 @@ function set$(ctx, signalName, value) {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
function getContentSize(ctx) {
|
|
123
|
+
var _a3, _b;
|
|
123
124
|
const { values } = ctx;
|
|
124
125
|
const stylePaddingTop = values.get("stylePaddingTop") || 0;
|
|
125
126
|
const headerSize = values.get("headerSize") || 0;
|
|
126
127
|
const footerSize = values.get("footerSize") || 0;
|
|
127
|
-
const totalSize = values.get("totalSize");
|
|
128
|
+
const totalSize = (_b = (_a3 = ctx.internalState) == null ? void 0 : _a3.pendingTotalSize) != null ? _b : values.get("totalSize");
|
|
128
129
|
return headerSize + footerSize + totalSize + stylePaddingTop;
|
|
129
130
|
}
|
|
130
131
|
function useArr$(signalNames) {
|
|
@@ -252,21 +253,24 @@ function findContainerId(ctx, key) {
|
|
|
252
253
|
|
|
253
254
|
// src/hooks/useValue$.ts
|
|
254
255
|
function useValue$(key, params) {
|
|
255
|
-
var _a3;
|
|
256
256
|
const { getValue, delay } = params || {};
|
|
257
257
|
const ctx = useStateContext();
|
|
258
|
-
const
|
|
258
|
+
const getNewValue = () => {
|
|
259
|
+
var _a3;
|
|
260
|
+
return (_a3 = getValue ? getValue(peek$(ctx, key)) : peek$(ctx, key)) != null ? _a3 : 0;
|
|
261
|
+
};
|
|
262
|
+
const animValue = useAnimatedValue(getNewValue());
|
|
259
263
|
React2.useMemo(() => {
|
|
260
|
-
let newValue;
|
|
261
264
|
let prevValue;
|
|
262
265
|
let didQueueTask = false;
|
|
263
266
|
listen$(ctx, key, (v) => {
|
|
264
|
-
newValue =
|
|
267
|
+
const newValue = getNewValue();
|
|
265
268
|
if (delay !== void 0) {
|
|
266
269
|
const fn = () => {
|
|
267
270
|
didQueueTask = false;
|
|
268
|
-
|
|
269
|
-
|
|
271
|
+
const latestValue = getNewValue();
|
|
272
|
+
if (latestValue !== void 0) {
|
|
273
|
+
animValue.setValue(latestValue);
|
|
270
274
|
}
|
|
271
275
|
};
|
|
272
276
|
const delayValue = isFunction(delay) ? delay(newValue, prevValue) : delay;
|
|
@@ -482,10 +486,16 @@ function useOnLayoutSync({
|
|
|
482
486
|
onLayoutProp,
|
|
483
487
|
onLayoutChange
|
|
484
488
|
}, deps = []) {
|
|
489
|
+
const lastLayoutRef = React2.useRef(null);
|
|
485
490
|
const onLayout = React2.useCallback(
|
|
486
491
|
(event) => {
|
|
487
|
-
|
|
488
|
-
|
|
492
|
+
var _a3, _b;
|
|
493
|
+
const { layout } = event.nativeEvent;
|
|
494
|
+
if (layout.height !== ((_a3 = lastLayoutRef.current) == null ? void 0 : _a3.height) || layout.width !== ((_b = lastLayoutRef.current) == null ? void 0 : _b.width)) {
|
|
495
|
+
onLayoutChange(layout, false);
|
|
496
|
+
onLayoutProp == null ? void 0 : onLayoutProp(event);
|
|
497
|
+
lastLayoutRef.current = layout;
|
|
498
|
+
}
|
|
489
499
|
},
|
|
490
500
|
[onLayoutChange]
|
|
491
501
|
);
|
|
@@ -493,7 +503,9 @@ function useOnLayoutSync({
|
|
|
493
503
|
React2.useLayoutEffect(() => {
|
|
494
504
|
if (ref.current) {
|
|
495
505
|
ref.current.measure((x, y, width, height) => {
|
|
496
|
-
|
|
506
|
+
const layout = { height, width, x, y };
|
|
507
|
+
lastLayoutRef.current = layout;
|
|
508
|
+
onLayoutChange(layout, true);
|
|
497
509
|
});
|
|
498
510
|
}
|
|
499
511
|
}, deps);
|
|
@@ -949,44 +961,30 @@ function updateAlignItemsPaddingTop(ctx, state) {
|
|
|
949
961
|
}
|
|
950
962
|
}
|
|
951
963
|
|
|
952
|
-
// src/core/
|
|
953
|
-
function updateTotalSize(ctx, state) {
|
|
954
|
-
const {
|
|
955
|
-
positions,
|
|
956
|
-
props: { data }
|
|
957
|
-
} = state;
|
|
958
|
-
if (data.length === 0) {
|
|
959
|
-
addTotalSize(ctx, state, null, 0);
|
|
960
|
-
} else {
|
|
961
|
-
const lastId = getId(state, data.length - 1);
|
|
962
|
-
if (lastId !== void 0) {
|
|
963
|
-
const lastPosition = positions.get(lastId);
|
|
964
|
-
if (lastPosition !== void 0) {
|
|
965
|
-
const lastSize = getItemSize(ctx, state, lastId, data.length - 1, data[data.length - 1]);
|
|
966
|
-
if (lastSize !== void 0) {
|
|
967
|
-
const totalSize = lastPosition + lastSize;
|
|
968
|
-
addTotalSize(ctx, state, null, totalSize);
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
}
|
|
964
|
+
// src/core/addTotalSize.ts
|
|
974
965
|
function addTotalSize(ctx, state, key, add) {
|
|
975
966
|
const { alignItemsAtEnd } = state.props;
|
|
976
967
|
const prevTotalSize = state.totalSize;
|
|
968
|
+
let totalSize = state.totalSize;
|
|
977
969
|
if (key === null) {
|
|
978
|
-
|
|
970
|
+
totalSize = add;
|
|
979
971
|
if (state.timeoutSetPaddingTop) {
|
|
980
972
|
clearTimeout(state.timeoutSetPaddingTop);
|
|
981
973
|
state.timeoutSetPaddingTop = void 0;
|
|
982
974
|
}
|
|
983
975
|
} else {
|
|
984
|
-
|
|
976
|
+
totalSize += add;
|
|
985
977
|
}
|
|
986
|
-
if (prevTotalSize !==
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
978
|
+
if (prevTotalSize !== totalSize) {
|
|
979
|
+
if (!IsNewArchitecture && state.initialScroll && totalSize < prevTotalSize) {
|
|
980
|
+
state.pendingTotalSize = totalSize;
|
|
981
|
+
} else {
|
|
982
|
+
state.pendingTotalSize = void 0;
|
|
983
|
+
state.totalSize = totalSize;
|
|
984
|
+
set$(ctx, "totalSize", totalSize);
|
|
985
|
+
if (alignItemsAtEnd) {
|
|
986
|
+
updateAlignItemsPaddingTop(ctx, state);
|
|
987
|
+
}
|
|
990
988
|
}
|
|
991
989
|
}
|
|
992
990
|
}
|
|
@@ -1191,6 +1189,7 @@ function onScroll(ctx, state, event) {
|
|
|
1191
1189
|
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
1192
1190
|
}
|
|
1193
1191
|
function updateScroll(ctx, state, newScroll, forceUpdate) {
|
|
1192
|
+
var _a3;
|
|
1194
1193
|
const scrollingTo = peek$(ctx, "scrollingTo");
|
|
1195
1194
|
state.hasScrolled = true;
|
|
1196
1195
|
state.lastBatchingAction = Date.now();
|
|
@@ -1224,7 +1223,7 @@ function updateScroll(ctx, state, newScroll, forceUpdate) {
|
|
|
1224
1223
|
}
|
|
1225
1224
|
if (forceUpdate || state.dataChangeNeedsScrollUpdate || Math.abs(state.scroll - state.scrollPrev) > 2) {
|
|
1226
1225
|
state.ignoreScrollFromMVCPIgnored = false;
|
|
1227
|
-
|
|
1226
|
+
(_a3 = state.triggerCalculateItemsInView) == null ? void 0 : _a3.call(state, { doMVCP: scrollingTo !== void 0 });
|
|
1228
1227
|
checkAtBottom(ctx, state);
|
|
1229
1228
|
checkAtTop(state);
|
|
1230
1229
|
state.dataChangeNeedsScrollUpdate = false;
|
|
@@ -1237,7 +1236,11 @@ function finishScrollTo(ctx, state) {
|
|
|
1237
1236
|
if (state) {
|
|
1238
1237
|
state.scrollHistory.length = 0;
|
|
1239
1238
|
state.initialScroll = void 0;
|
|
1239
|
+
state.initialAnchor = void 0;
|
|
1240
1240
|
set$(ctx, "scrollingTo", void 0);
|
|
1241
|
+
if (state.pendingTotalSize !== void 0) {
|
|
1242
|
+
addTotalSize(ctx, state, null, state.pendingTotalSize);
|
|
1243
|
+
}
|
|
1241
1244
|
if ((_a3 = state.props) == null ? void 0 : _a3.data) {
|
|
1242
1245
|
(_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
|
|
1243
1246
|
}
|
|
@@ -1331,6 +1334,58 @@ function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
|
1331
1334
|
}
|
|
1332
1335
|
}
|
|
1333
1336
|
|
|
1337
|
+
// src/core/ensureInitialAnchor.ts
|
|
1338
|
+
var INITIAL_ANCHOR_TOLERANCE = 0.5;
|
|
1339
|
+
var INITIAL_ANCHOR_MAX_ATTEMPTS = 4;
|
|
1340
|
+
var INITIAL_ANCHOR_SETTLED_TICKS = 2;
|
|
1341
|
+
function ensureInitialAnchor(ctx, state) {
|
|
1342
|
+
var _a3, _b, _c, _d, _e;
|
|
1343
|
+
const anchor = state.initialAnchor;
|
|
1344
|
+
const item = state.props.data[anchor.index];
|
|
1345
|
+
const containersDidLayout = peek$(ctx, "containersDidLayout");
|
|
1346
|
+
if (!containersDidLayout) {
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
const id = getId(state, anchor.index);
|
|
1350
|
+
if (state.positions.get(id) === void 0) {
|
|
1351
|
+
return;
|
|
1352
|
+
}
|
|
1353
|
+
const size = getItemSize(ctx, state, id, anchor.index, item, true, true);
|
|
1354
|
+
if (size === void 0) {
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
const availableSpace = Math.max(0, state.scrollLength - size);
|
|
1358
|
+
const desiredOffset = calculateOffsetForIndex(ctx, state, anchor.index) - ((_a3 = anchor.viewOffset) != null ? _a3 : 0) - ((_b = anchor.viewPosition) != null ? _b : 0) * availableSpace;
|
|
1359
|
+
const contentSize = getContentSize(ctx);
|
|
1360
|
+
const maxOffset = Math.max(0, contentSize - state.scrollLength);
|
|
1361
|
+
const clampedDesiredOffset = Math.max(0, Math.min(desiredOffset, maxOffset));
|
|
1362
|
+
const delta = clampedDesiredOffset - state.scroll;
|
|
1363
|
+
if (Math.abs(delta) <= INITIAL_ANCHOR_TOLERANCE) {
|
|
1364
|
+
const settledTicks = ((_c = anchor.settledTicks) != null ? _c : 0) + 1;
|
|
1365
|
+
if (settledTicks >= INITIAL_ANCHOR_SETTLED_TICKS) {
|
|
1366
|
+
state.initialAnchor = void 0;
|
|
1367
|
+
} else {
|
|
1368
|
+
anchor.settledTicks = settledTicks;
|
|
1369
|
+
}
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
if (((_d = anchor.attempts) != null ? _d : 0) >= INITIAL_ANCHOR_MAX_ATTEMPTS) {
|
|
1373
|
+
state.initialAnchor = void 0;
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
const lastDelta = anchor.lastDelta;
|
|
1377
|
+
if (lastDelta !== void 0 && Math.abs(delta) >= Math.abs(lastDelta)) {
|
|
1378
|
+
state.initialAnchor = void 0;
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
Object.assign(anchor, {
|
|
1382
|
+
attempts: ((_e = anchor.attempts) != null ? _e : 0) + 1,
|
|
1383
|
+
lastDelta: delta,
|
|
1384
|
+
settledTicks: 0
|
|
1385
|
+
});
|
|
1386
|
+
requestAdjust(ctx, state, delta);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1334
1389
|
// src/core/mvcp.ts
|
|
1335
1390
|
function prepareMVCP(ctx, state, dataChanged) {
|
|
1336
1391
|
const {
|
|
@@ -1346,6 +1401,9 @@ function prepareMVCP(ctx, state, dataChanged) {
|
|
|
1346
1401
|
if (maintainVisibleContentPosition) {
|
|
1347
1402
|
const indexByKey = state.indexByKey;
|
|
1348
1403
|
if (scrollTarget !== void 0) {
|
|
1404
|
+
if (!IsNewArchitecture && (scrollingTo == null ? void 0 : scrollingTo.isInitialScroll)) {
|
|
1405
|
+
return void 0;
|
|
1406
|
+
}
|
|
1349
1407
|
targetId = getId(state, scrollTarget);
|
|
1350
1408
|
} else if (idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
|
|
1351
1409
|
if (dataChanged) {
|
|
@@ -1379,7 +1437,7 @@ function prepareMVCP(ctx, state, dataChanged) {
|
|
|
1379
1437
|
if (targetId !== void 0 && prevPosition !== void 0) {
|
|
1380
1438
|
const newPosition = positions.get(targetId);
|
|
1381
1439
|
if (newPosition !== void 0) {
|
|
1382
|
-
const totalSize =
|
|
1440
|
+
const totalSize = getContentSize(ctx);
|
|
1383
1441
|
let diff = newPosition - prevPosition;
|
|
1384
1442
|
if (diff !== 0 && state.scroll + state.scrollLength > totalSize) {
|
|
1385
1443
|
if (diff > 0) {
|
|
@@ -1459,6 +1517,29 @@ function calculateRowMaxSize(ctx, state, startIndex, endIndex, useAverageSize) {
|
|
|
1459
1517
|
return maxSize;
|
|
1460
1518
|
}
|
|
1461
1519
|
|
|
1520
|
+
// src/core/updateTotalSize.ts
|
|
1521
|
+
function updateTotalSize(ctx, state) {
|
|
1522
|
+
const {
|
|
1523
|
+
positions,
|
|
1524
|
+
props: { data }
|
|
1525
|
+
} = state;
|
|
1526
|
+
if (data.length === 0) {
|
|
1527
|
+
addTotalSize(ctx, state, null, 0);
|
|
1528
|
+
} else {
|
|
1529
|
+
const lastId = getId(state, data.length - 1);
|
|
1530
|
+
if (lastId !== void 0) {
|
|
1531
|
+
const lastPosition = positions.get(lastId);
|
|
1532
|
+
if (lastPosition !== void 0) {
|
|
1533
|
+
const lastSize = getItemSize(ctx, state, lastId, data.length - 1, data[data.length - 1]);
|
|
1534
|
+
if (lastSize !== void 0) {
|
|
1535
|
+
const totalSize = lastPosition + lastSize;
|
|
1536
|
+
addTotalSize(ctx, state, null, totalSize);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1462
1543
|
// src/utils/getScrollVelocity.ts
|
|
1463
1544
|
var getScrollVelocity = (state) => {
|
|
1464
1545
|
const { scrollHistory } = state;
|
|
@@ -2079,9 +2160,12 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2079
2160
|
const stickyIndicesSet = state.props.stickyIndicesSet || /* @__PURE__ */ new Set();
|
|
2080
2161
|
const prevNumContainers = peek$(ctx, "numContainers");
|
|
2081
2162
|
if (!data || scrollLength === 0 || !prevNumContainers) {
|
|
2163
|
+
if (state.initialAnchor) {
|
|
2164
|
+
ensureInitialAnchor(ctx, state);
|
|
2165
|
+
}
|
|
2082
2166
|
return;
|
|
2083
2167
|
}
|
|
2084
|
-
const totalSize =
|
|
2168
|
+
const totalSize = getContentSize(ctx);
|
|
2085
2169
|
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
2086
2170
|
const numColumns = peek$(ctx, "numColumns");
|
|
2087
2171
|
const { dataChanged, doMVCP, forceFullItemPositions } = params;
|
|
@@ -2128,6 +2212,9 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2128
2212
|
if (!dataChanged && scrollForNextCalculateItemsInView) {
|
|
2129
2213
|
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
2130
2214
|
if (scrollTopBuffered > top && scrollBottomBuffered < bottom) {
|
|
2215
|
+
if (state.initialAnchor) {
|
|
2216
|
+
ensureInitialAnchor(ctx, state);
|
|
2217
|
+
}
|
|
2131
2218
|
return;
|
|
2132
2219
|
}
|
|
2133
2220
|
}
|
|
@@ -2380,6 +2467,9 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
2380
2467
|
}
|
|
2381
2468
|
}
|
|
2382
2469
|
});
|
|
2470
|
+
if (state.initialAnchor) {
|
|
2471
|
+
ensureInitialAnchor(ctx, state);
|
|
2472
|
+
}
|
|
2383
2473
|
}
|
|
2384
2474
|
|
|
2385
2475
|
// src/core/checkActualChange.ts
|
|
@@ -3015,7 +3105,7 @@ var LegendList = typedMemo(
|
|
|
3015
3105
|
})
|
|
3016
3106
|
);
|
|
3017
3107
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
3018
|
-
var _a3;
|
|
3108
|
+
var _a3, _b;
|
|
3019
3109
|
const {
|
|
3020
3110
|
alignItemsAtEnd = false,
|
|
3021
3111
|
columnWrapperStyle,
|
|
@@ -3106,6 +3196,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3106
3196
|
idCache: [],
|
|
3107
3197
|
idsInView: [],
|
|
3108
3198
|
indexByKey: /* @__PURE__ */ new Map(),
|
|
3199
|
+
initialAnchor: (initialScrollProp == null ? void 0 : initialScrollProp.index) !== void 0 && (initialScrollProp == null ? void 0 : initialScrollProp.viewPosition) !== void 0 ? {
|
|
3200
|
+
attempts: 0,
|
|
3201
|
+
index: initialScrollProp.index,
|
|
3202
|
+
settledTicks: 0,
|
|
3203
|
+
viewOffset: (_a3 = initialScrollProp.viewOffset) != null ? _a3 : 0,
|
|
3204
|
+
viewPosition: initialScrollProp.viewPosition
|
|
3205
|
+
} : void 0,
|
|
3109
3206
|
initialScroll: initialScrollProp,
|
|
3110
3207
|
isAtEnd: false,
|
|
3111
3208
|
isAtStart: false,
|
|
@@ -3227,10 +3324,21 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3227
3324
|
);
|
|
3228
3325
|
}
|
|
3229
3326
|
const initialContentOffset = React2.useMemo(() => {
|
|
3327
|
+
var _a4, _b2;
|
|
3230
3328
|
const { initialScroll } = refState.current;
|
|
3231
3329
|
if (!initialScroll) {
|
|
3330
|
+
refState.current.initialAnchor = void 0;
|
|
3232
3331
|
return 0;
|
|
3233
3332
|
}
|
|
3333
|
+
if (initialScroll.index !== void 0 && (!refState.current.initialAnchor || ((_a4 = refState.current.initialAnchor) == null ? void 0 : _a4.index) !== initialScroll.index)) {
|
|
3334
|
+
refState.current.initialAnchor = {
|
|
3335
|
+
attempts: 0,
|
|
3336
|
+
index: initialScroll.index,
|
|
3337
|
+
settledTicks: 0,
|
|
3338
|
+
viewOffset: (_b2 = initialScroll.viewOffset) != null ? _b2 : 0,
|
|
3339
|
+
viewPosition: initialScroll.viewPosition
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3234
3342
|
if (initialScroll.contentOffset !== void 0) {
|
|
3235
3343
|
return initialScroll.contentOffset;
|
|
3236
3344
|
}
|
|
@@ -3282,6 +3390,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3282
3390
|
scrollTo(ctx, state, {
|
|
3283
3391
|
animated: false,
|
|
3284
3392
|
index: (_a4 = state.initialScroll) == null ? void 0 : _a4.index,
|
|
3393
|
+
isInitialScroll: true,
|
|
3285
3394
|
offset: initialContentOffset,
|
|
3286
3395
|
precomputedWithViewOffset: true
|
|
3287
3396
|
});
|
|
@@ -3396,7 +3505,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
3396
3505
|
}
|
|
3397
3506
|
),
|
|
3398
3507
|
refScrollView: combinedRef,
|
|
3399
|
-
scrollAdjustHandler: (
|
|
3508
|
+
scrollAdjustHandler: (_b = refState.current) == null ? void 0 : _b.scrollAdjustHandler,
|
|
3400
3509
|
scrollEventThrottle: Platform2.OS === "web" ? 16 : void 0,
|
|
3401
3510
|
snapToIndices,
|
|
3402
3511
|
stickyIndices,
|