@legendapp/list 3.0.4 → 3.0.6

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.
@@ -1,5 +1,5 @@
1
1
  import * as React3 from 'react';
2
- import { forwardRef, useReducer, useEffect, createContext, useRef, useState, useMemo, useCallback, useImperativeHandle, useLayoutEffect, useContext } from 'react';
2
+ import { forwardRef, useReducer, useEffect, createContext, useRef, useState, useMemo, useCallback, useLayoutEffect, useImperativeHandle, useContext } from 'react';
3
3
  import { useSyncExternalStore } from 'use-sync-external-store/shim';
4
4
  import * as ReactDOM from 'react-dom';
5
5
  import { flushSync } from 'react-dom';
@@ -132,6 +132,7 @@ function StateProvider({ children }) {
132
132
  const [value] = React3.useState(() => ({
133
133
  animatedScrollY: createAnimatedValue(0),
134
134
  columnWrapperStyle: void 0,
135
+ containerLayoutTriggers: /* @__PURE__ */ new Map(),
135
136
  contextNum: contextNum++,
136
137
  listeners: /* @__PURE__ */ new Map(),
137
138
  mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
@@ -142,6 +143,7 @@ function StateProvider({ children }) {
142
143
  positionListeners: /* @__PURE__ */ new Map(),
143
144
  state: void 0,
144
145
  values: /* @__PURE__ */ new Map([
146
+ ["alignItemsAtEndPadding", 0],
145
147
  ["stylePaddingTop", 0],
146
148
  ["headerSize", 0],
147
149
  ["numContainers", 0],
@@ -284,15 +286,16 @@ function getContentInsetEnd(ctx, contentInsetEndAdjustmentOverride) {
284
286
 
285
287
  // src/state/getContentSize.ts
286
288
  function getContentSize(ctx) {
287
- var _a3;
289
+ var _a3, _b;
288
290
  const { values, state } = ctx;
289
291
  const stylePaddingTop = values.get("stylePaddingTop") || 0;
290
292
  const stylePaddingBottom = state.props.stylePaddingBottom || 0;
293
+ const alignItemsAtEndPadding = values.get("alignItemsAtEndPadding") || 0;
291
294
  const headerSize = values.get("headerSize") || 0;
292
295
  const footerSize = values.get("footerSize") || 0;
293
296
  const contentInsetBottom = getContentInsetEnd(ctx);
294
- const totalSize = (_a3 = state.pendingTotalSize) != null ? _a3 : values.get("totalSize");
295
- return headerSize + footerSize + totalSize + stylePaddingTop + stylePaddingBottom + (contentInsetBottom || 0);
297
+ const totalSize = (_b = (_a3 = state.pendingTotalSize) != null ? _a3 : state.totalSize) != null ? _b : values.get("totalSize");
298
+ return headerSize + footerSize + totalSize + stylePaddingTop + alignItemsAtEndPadding + stylePaddingBottom + (contentInsetBottom || 0);
296
299
  }
297
300
 
298
301
  // src/components/DebugView.tsx
@@ -399,9 +402,6 @@ function roundSize(size) {
399
402
  function isNullOrUndefined(value) {
400
403
  return value === null || value === void 0;
401
404
  }
402
- function comparatorDefault(a, b) {
403
- return a - b;
404
- }
405
405
  function getPadding(s, type) {
406
406
  var _a3, _b, _c;
407
407
  const axisPadding = type === "Left" || type === "Right" ? s.paddingHorizontal : s.paddingVertical;
@@ -909,18 +909,6 @@ var Container = typedMemo(function Container2({
909
909
  [itemKey, data, extraData]
910
910
  );
911
911
  const { index, renderedItem } = renderedItemInfo || {};
912
- const contextValue = useMemo(() => {
913
- ctx.viewRefs.set(id, ref);
914
- return {
915
- containerId: id,
916
- index,
917
- itemKey,
918
- triggerLayout: () => {
919
- forceLayoutRender((v) => v + 1);
920
- },
921
- value: data
922
- };
923
- }, [id, itemKey, index, data]);
924
912
  const onLayoutChange = useCallback((rectangle) => {
925
913
  const {
926
914
  horizontal: currentHorizontal,
@@ -964,6 +952,27 @@ var Container = typedMemo(function Container2({
964
952
  doUpdate();
965
953
  }
966
954
  }, []);
955
+ const triggerLayout = useCallback(() => {
956
+ forceLayoutRender((v) => v + 1);
957
+ }, []);
958
+ const contextValue = useMemo(() => {
959
+ ctx.viewRefs.set(id, ref);
960
+ return {
961
+ containerId: id,
962
+ index,
963
+ itemKey,
964
+ triggerLayout,
965
+ value: data
966
+ };
967
+ }, [id, itemKey, index, data, triggerLayout]);
968
+ useLayoutEffect(() => {
969
+ ctx.containerLayoutTriggers.set(id, triggerLayout);
970
+ return () => {
971
+ if (ctx.containerLayoutTriggers.get(id) === triggerLayout) {
972
+ ctx.containerLayoutTriggers.delete(id);
973
+ }
974
+ };
975
+ }, [ctx, id, triggerLayout]);
967
976
  const { onLayout } = useOnLayoutSync(
968
977
  {
969
978
  onLayoutChange,
@@ -1786,6 +1795,51 @@ function WebAnchoredEndSpace({ horizontal }) {
1786
1795
  const style = horizontal ? { height: "100%", width: anchoredEndSpaceSize || 0 } : { height: anchoredEndSpaceSize || 0 };
1787
1796
  return /* @__PURE__ */ React3.createElement("div", { style }, null);
1788
1797
  }
1798
+
1799
+ // src/core/updateContentMetrics.ts
1800
+ function getRawContentLength(ctx) {
1801
+ var _a3, _b, _c;
1802
+ const { state, values } = ctx;
1803
+ return (values.get("headerSize") || 0) + (values.get("footerSize") || 0) + ((_c = (_b = (_a3 = state.pendingTotalSize) != null ? _a3 : state.totalSize) != null ? _b : values.get("totalSize")) != null ? _c : 0) + (state.props.stylePaddingTop || 0) + (state.props.stylePaddingBottom || 0);
1804
+ }
1805
+ function getAlignItemsAtEndPadding(ctx) {
1806
+ const { state } = ctx;
1807
+ const shouldPad = !!state.props.alignItemsAtEndPaddingEnabled && !state.props.horizontal && state.props.data.length > 0 && state.scrollLength > 0;
1808
+ return shouldPad ? Math.max(0, state.scrollLength - getRawContentLength(ctx) - getContentInsetEnd(ctx)) : 0;
1809
+ }
1810
+ function updateContentMetrics(ctx) {
1811
+ const nextPadding = getAlignItemsAtEndPadding(ctx);
1812
+ if (peek$(ctx, "alignItemsAtEndPadding") !== nextPadding) {
1813
+ set$(ctx, "alignItemsAtEndPadding", nextPadding);
1814
+ }
1815
+ }
1816
+ function setContentLengthSignal(ctx, signalName, size) {
1817
+ if (peek$(ctx, signalName) !== size) {
1818
+ set$(ctx, signalName, size);
1819
+ updateContentMetrics(ctx);
1820
+ }
1821
+ }
1822
+ function setHeaderSize(ctx, size) {
1823
+ setContentLengthSignal(ctx, "headerSize", size);
1824
+ }
1825
+ function setFooterSize(ctx, size) {
1826
+ setContentLengthSignal(ctx, "footerSize", size);
1827
+ }
1828
+ function areInsetsEqual(left, right) {
1829
+ var _a3, _b, _c, _d, _e, _f, _g, _h;
1830
+ return ((_a3 = left == null ? void 0 : left.top) != null ? _a3 : 0) === ((_b = right == null ? void 0 : right.top) != null ? _b : 0) && ((_c = left == null ? void 0 : left.bottom) != null ? _c : 0) === ((_d = right == null ? void 0 : right.bottom) != null ? _d : 0) && ((_e = left == null ? void 0 : left.left) != null ? _e : 0) === ((_f = right == null ? void 0 : right.left) != null ? _f : 0) && ((_g = left == null ? void 0 : left.right) != null ? _g : 0) === ((_h = right == null ? void 0 : right.right) != null ? _h : 0);
1831
+ }
1832
+ function setContentInsetOverride(ctx, inset) {
1833
+ const { state } = ctx;
1834
+ const previousInset = state.contentInsetOverride;
1835
+ const nextInset = inset != null ? inset : void 0;
1836
+ const didChange = !areInsetsEqual(previousInset, nextInset);
1837
+ state.contentInsetOverride = nextInset;
1838
+ if (didChange) {
1839
+ updateContentMetrics(ctx);
1840
+ }
1841
+ return didChange;
1842
+ }
1789
1843
  function useStableRenderComponent(renderComponent, mapProps) {
1790
1844
  const renderComponentRef = useLatestRef(renderComponent);
1791
1845
  const mapPropsRef = useLatestRef(mapProps);
@@ -1837,7 +1891,7 @@ var ListComponent = typedMemo(function ListComponent2({
1837
1891
  }) {
1838
1892
  const ctx = useStateContext();
1839
1893
  const maintainVisibleContentPosition = ctx.state.props.maintainVisibleContentPosition;
1840
- const [otherAxisSize = 0] = useArr$(["otherAxisSize"]);
1894
+ const [alignItemsAtEndPadding = 0, otherAxisSize = 0] = useArr$(["alignItemsAtEndPadding", "otherAxisSize"]);
1841
1895
  const autoOtherAxisStyle = getAutoOtherAxisStyle({
1842
1896
  horizontal,
1843
1897
  needsOtherAxisSize: ctx.state.needsOtherAxisSize,
@@ -1851,23 +1905,23 @@ var ListComponent = typedMemo(function ListComponent2({
1851
1905
  const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
1852
1906
  useLayoutEffect(() => {
1853
1907
  if (!ListHeaderComponent) {
1854
- set$(ctx, "headerSize", 0);
1908
+ setHeaderSize(ctx, 0);
1855
1909
  }
1856
1910
  if (!ListFooterComponent) {
1857
- set$(ctx, "footerSize", 0);
1911
+ setFooterSize(ctx, 0);
1858
1912
  }
1859
1913
  }, [ListHeaderComponent, ListFooterComponent, ctx]);
1860
1914
  const onLayoutHeader = useCallback(
1861
1915
  (rect) => {
1862
1916
  const size = rect[horizontal ? "width" : "height"];
1863
- set$(ctx, "headerSize", size);
1917
+ setHeaderSize(ctx, size);
1864
1918
  },
1865
1919
  [ctx, horizontal]
1866
1920
  );
1867
1921
  const onLayoutFooterInternal = useCallback(
1868
1922
  (rect, fromLayoutEffect) => {
1869
1923
  const size = rect[horizontal ? "width" : "height"];
1870
- set$(ctx, "footerSize", size);
1924
+ setFooterSize(ctx, size);
1871
1925
  onLayoutFooter == null ? void 0 : onLayoutFooter(rect, fromLayoutEffect);
1872
1926
  },
1873
1927
  [ctx, horizontal, onLayoutFooter]
@@ -1895,6 +1949,13 @@ var ListComponent = typedMemo(function ListComponent2({
1895
1949
  /* @__PURE__ */ React3.createElement(ScrollAdjust, null),
1896
1950
  ListHeaderComponent && /* @__PURE__ */ React3.createElement(LayoutView, { onLayoutChange: onLayoutHeader, style: ListHeaderComponentStyle }, getComponent(ListHeaderComponent)),
1897
1951
  ListEmptyComponent && getComponent(ListEmptyComponent),
1952
+ alignItemsAtEndPadding > 0 && /* @__PURE__ */ React3.createElement(
1953
+ View,
1954
+ {
1955
+ style: horizontal ? { flexShrink: 0, width: alignItemsAtEndPadding } : { flexShrink: 0, height: alignItemsAtEndPadding }
1956
+ },
1957
+ null
1958
+ ),
1898
1959
  canRender && !ListEmptyComponent && /* @__PURE__ */ React3.createElement(
1899
1960
  Containers,
1900
1961
  {
@@ -2386,7 +2447,7 @@ function calculateOffsetForIndex(ctx, index) {
2386
2447
 
2387
2448
  // src/core/getTopOffsetAdjustment.ts
2388
2449
  function getTopOffsetAdjustment(ctx) {
2389
- return (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
2450
+ return (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "alignItemsAtEndPadding") || 0) + (peek$(ctx, "headerSize") || 0);
2390
2451
  }
2391
2452
 
2392
2453
  // src/utils/getId.ts
@@ -2422,6 +2483,7 @@ function addTotalSize(ctx, key, add, notifyTotalSize = true) {
2422
2483
  if (notifyTotalSize) {
2423
2484
  set$(ctx, "totalSize", totalSize);
2424
2485
  }
2486
+ updateContentMetrics(ctx);
2425
2487
  }
2426
2488
  } else if (notifyTotalSize && ctx.values.get("totalSize") !== totalSize) {
2427
2489
  set$(ctx, "totalSize", totalSize);
@@ -2441,14 +2503,14 @@ function setSize(ctx, itemKey, size, notifyTotalSize = true) {
2441
2503
  }
2442
2504
 
2443
2505
  // src/utils/getItemSize.ts
2444
- function getKnownOrFixedSize(ctx, key, index, data) {
2445
- var _a3;
2506
+ function getKnownOrFixedSize(ctx, key, index, data, resolved) {
2507
+ var _a3, _b;
2446
2508
  const state = ctx.state;
2447
2509
  const { getFixedItemSize, getItemType } = state.props;
2448
2510
  let size = key ? state.sizesKnown.get(key) : void 0;
2449
2511
  if (size === void 0 && key && getFixedItemSize) {
2450
- const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
2451
- size = getFixedItemSize(data, index, itemType);
2512
+ const itemType = (_b = resolved == null ? void 0 : resolved.itemType) != null ? _b : getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
2513
+ size = (resolved == null ? void 0 : resolved.didResolveFixedItemSize) ? resolved.fixedItemSize : getFixedItemSize(data, index, itemType);
2452
2514
  if (size !== void 0) {
2453
2515
  state.sizesKnown.set(key, size);
2454
2516
  }
@@ -2467,8 +2529,8 @@ function areKnownOrFixedItemSizesAvailable(ctx, startIndex, endIndex) {
2467
2529
  }
2468
2530
  return true;
2469
2531
  }
2470
- function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, notifyTotalSize) {
2471
- var _a3, _b, _c;
2532
+ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, notifyTotalSize, resolved) {
2533
+ var _a3, _b, _c, _d;
2472
2534
  const state = ctx.state;
2473
2535
  const {
2474
2536
  sizes,
@@ -2487,14 +2549,14 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, no
2487
2549
  return renderedSize;
2488
2550
  }
2489
2551
  }
2490
- size = getKnownOrFixedSize(ctx, key, index, data);
2552
+ size = getKnownOrFixedSize(ctx, key, index, data, resolved);
2491
2553
  if (size !== void 0) {
2492
2554
  setSize(ctx, key, size, notifyTotalSize);
2493
2555
  return size;
2494
2556
  }
2495
- const itemType = getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
2557
+ const itemType = (_b = resolved == null ? void 0 : resolved.itemType) != null ? _b : getItemType ? (_a3 = getItemType(data, index)) != null ? _a3 : "" : "";
2496
2558
  if (useAverageSize && !scrollingTo) {
2497
- const averageSizeForType = (_b = averageSizes[itemType]) == null ? void 0 : _b.avg;
2559
+ const averageSizeForType = (_c = averageSizes[itemType]) == null ? void 0 : _c.avg;
2498
2560
  if (averageSizeForType !== void 0) {
2499
2561
  size = roundSize(averageSizeForType);
2500
2562
  }
@@ -2503,7 +2565,7 @@ function getItemSize(ctx, key, index, data, useAverageSize, preferCachedSize, no
2503
2565
  return renderedSize;
2504
2566
  }
2505
2567
  if (size === void 0 && useAverageSize && scrollingTo) {
2506
- const averageSizeForType = (_c = scrollingTo.averageSizeSnapshot) == null ? void 0 : _c[itemType];
2568
+ const averageSizeForType = (_d = scrollingTo.averageSizeSnapshot) == null ? void 0 : _d[itemType];
2507
2569
  if (averageSizeForType !== void 0) {
2508
2570
  size = roundSize(averageSizeForType);
2509
2571
  }
@@ -3064,8 +3126,8 @@ function updateScroll(ctx, newScroll, forceUpdate, options) {
3064
3126
  if ((options == null ? void 0 : options.markHasScrolled) !== false) {
3065
3127
  state.hasScrolled = true;
3066
3128
  }
3067
- state.lastBatchingAction = Date.now();
3068
3129
  const currentTime = Date.now();
3130
+ state.lastBatchingAction = currentTime;
3069
3131
  const adjust = scrollAdjustHandler.getAdjust();
3070
3132
  const adjustChanged = lastScrollAdjustForHistory !== void 0 && Math.abs(adjust - lastScrollAdjustForHistory) > 0.1;
3071
3133
  if (adjustChanged) {
@@ -3374,26 +3436,22 @@ function advanceCurrentInitialScrollSession(ctx, options) {
3374
3436
  }
3375
3437
 
3376
3438
  // src/utils/checkAllSizesKnown.ts
3377
- function isNullOrUndefined2(value) {
3378
- return value === null || value === void 0;
3379
- }
3380
- function getMountedIndicesInRange(state, start, end) {
3381
- if (!isNullOrUndefined2(end) && !isNullOrUndefined2(start) && start >= 0 && end >= 0) {
3382
- return Array.from(state.containerItemKeys.keys()).map((key) => state.indexByKey.get(key)).filter((index) => index !== void 0 && index >= start && index <= end).sort((a, b) => a - b);
3439
+ function checkAllSizesKnown(state, start, end) {
3440
+ if (start == null || end == null || start < 0 || end < start) {
3441
+ return false;
3383
3442
  }
3384
- return [];
3385
- }
3386
- function getMountedBufferedIndices(state) {
3387
- return getMountedIndicesInRange(state, state.startBuffered, state.endBuffered);
3388
- }
3389
- function getMountedNoBufferIndices(state) {
3390
- return getMountedIndicesInRange(state, state.startNoBuffer, state.endNoBuffer);
3391
- }
3392
- function checkAllSizesKnown(state, indices) {
3393
- return indices.length > 0 && indices.every((index) => {
3394
- const key = getId(state, index);
3395
- return key !== void 0 && state.sizesKnown.has(key);
3396
- });
3443
+ let hasMountedIndex = false;
3444
+ for (const key of state.containerItemKeys.keys()) {
3445
+ const index = state.indexByKey.get(key);
3446
+ if (index !== void 0 && index >= start && index <= end) {
3447
+ hasMountedIndex = true;
3448
+ const id = getId(state, index);
3449
+ if (id === void 0 || !state.sizesKnown.has(id)) {
3450
+ return false;
3451
+ }
3452
+ }
3453
+ }
3454
+ return hasMountedIndex;
3397
3455
  }
3398
3456
 
3399
3457
  // src/core/bootstrapInitialScroll.ts
@@ -3894,8 +3952,7 @@ function evaluateBootstrapInitialScroll(ctx) {
3894
3952
  bootstrapInitialScroll.targetIndexSeed = void 0;
3895
3953
  }
3896
3954
  const resolvedOffset = resolveInitialScrollOffset(ctx, initialScroll);
3897
- const mountedBufferedIndices = getMountedBufferedIndices(state);
3898
- const areMountedBufferedIndicesMeasured = checkAllSizesKnown(state, mountedBufferedIndices);
3955
+ const areMountedBufferedIndicesMeasured = checkAllSizesKnown(state, state.startBuffered, state.endBuffered);
3899
3956
  const didResolvedOffsetChange = Math.abs(bootstrapInitialScroll.scroll - resolvedOffset) > 1;
3900
3957
  const { data } = state.props;
3901
3958
  const visibleIndices = getBootstrapRevealVisibleIndices({
@@ -4471,7 +4528,14 @@ function updateSnapToOffsets(ctx) {
4471
4528
  }
4472
4529
 
4473
4530
  // src/core/updateItemPositions.ts
4474
- function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffered, forceFullUpdate = false, doMVCP, optimizeForVisibleWindow = false } = {
4531
+ function updateItemPositions(ctx, dataChanged, {
4532
+ doMVCP,
4533
+ forceFullUpdate = false,
4534
+ optimizeForVisibleWindow = false,
4535
+ scrollBottomBuffered,
4536
+ scrollVelocity,
4537
+ startIndex
4538
+ } = {
4475
4539
  doMVCP: false,
4476
4540
  forceFullUpdate: false,
4477
4541
  optimizeForVisibleWindow: false,
@@ -4498,7 +4562,7 @@ function updateItemPositions(ctx, dataChanged, { startIndex, scrollBottomBuffere
4498
4562
  const extraData = peek$(ctx, "extraData");
4499
4563
  const layoutConfig = overrideItemLayout ? { span: 1 } : void 0;
4500
4564
  const lastScrollDelta = state.lastScrollDelta;
4501
- const velocity = getScrollVelocity(state);
4565
+ const velocity = scrollVelocity != null ? scrollVelocity : getScrollVelocity(state);
4502
4566
  const shouldOptimize = !forceFullUpdate && !dataChanged && (optimizeForVisibleWindow || Math.abs(velocity) > 0 || state.scrollLength > 0 && lastScrollDelta > state.scrollLength);
4503
4567
  const maxVisibleArea = scrollBottomBuffered + 1e3;
4504
4568
  const useAverageSize = true;
@@ -4678,25 +4742,28 @@ function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, stat
4678
4742
  const configId = viewabilityConfig.id;
4679
4743
  const viewabilityState = ensureViewabilityState(ctx, configId);
4680
4744
  const { viewableItems: previousViewableItems, start, end, startBuffered, endBuffered } = viewabilityState;
4681
- const viewabilityTokens = /* @__PURE__ */ new Map();
4745
+ let staleViewabilityAmountIds;
4682
4746
  for (const [containerId, value] of ctx.mapViewabilityAmountValues) {
4683
- viewabilityTokens.set(
4747
+ const nextValue = computeViewability(
4748
+ state,
4749
+ ctx,
4750
+ viewabilityConfig,
4684
4751
  containerId,
4685
- computeViewability(
4686
- state,
4687
- ctx,
4688
- viewabilityConfig,
4689
- containerId,
4690
- value.key,
4691
- scrollSize,
4692
- value.item,
4693
- value.index
4694
- )
4752
+ value.key,
4753
+ scrollSize,
4754
+ value.item,
4755
+ value.index
4695
4756
  );
4757
+ if (nextValue.sizeVisible < 0) {
4758
+ staleViewabilityAmountIds != null ? staleViewabilityAmountIds : staleViewabilityAmountIds = [];
4759
+ staleViewabilityAmountIds.push(containerId);
4760
+ }
4696
4761
  }
4697
4762
  const changed = [];
4763
+ const previousViewableKeys = /* @__PURE__ */ new Set();
4698
4764
  if (previousViewableItems) {
4699
4765
  for (const viewToken of previousViewableItems) {
4766
+ previousViewableKeys.add(viewToken.key);
4700
4767
  const containerId = findContainerId(ctx, viewToken.key);
4701
4768
  if (!checkIsViewable(
4702
4769
  state,
@@ -4728,7 +4795,7 @@ function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, stat
4728
4795
  key
4729
4796
  };
4730
4797
  viewableItems.push(viewToken);
4731
- if (!(previousViewableItems == null ? void 0 : previousViewableItems.find((v) => v.key === viewToken.key))) {
4798
+ if (!previousViewableKeys.has(viewToken.key)) {
4732
4799
  changed.push(viewToken);
4733
4800
  }
4734
4801
  }
@@ -4749,24 +4816,21 @@ function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, stat
4749
4816
  onViewableItemsChanged({ changed, end, endBuffered, start, startBuffered, viewableItems });
4750
4817
  }
4751
4818
  }
4752
- for (const [containerId, value] of ctx.mapViewabilityAmountValues) {
4753
- if (value.sizeVisible < 0) {
4754
- ctx.mapViewabilityAmountValues.delete(containerId);
4819
+ if (staleViewabilityAmountIds) {
4820
+ for (const containerId of staleViewabilityAmountIds) {
4821
+ const value = ctx.mapViewabilityAmountValues.get(containerId);
4822
+ if (value && value.sizeVisible < 0) {
4823
+ ctx.mapViewabilityAmountValues.delete(containerId);
4824
+ }
4755
4825
  }
4756
4826
  }
4757
4827
  }
4758
- function shallowEqual(prev, next) {
4759
- if (!prev) return false;
4760
- const keys = Object.keys(next);
4761
- for (let i = 0; i < keys.length; i++) {
4762
- const k = keys[i];
4763
- if (prev[k] !== next[k]) return false;
4764
- }
4765
- return true;
4828
+ function areViewabilityAmountTokensEqual(prev, next) {
4829
+ return !!prev && prev.containerId === next.containerId && prev.index === next.index && prev.isViewable === next.isViewable && prev.item === next.item && prev.key === next.key && prev.percentOfScroller === next.percentOfScroller && prev.percentVisible === next.percentVisible && prev.scrollSize === next.scrollSize && prev.size === next.size && prev.sizeVisible === next.sizeVisible;
4766
4830
  }
4767
4831
  function computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
4768
4832
  const { sizes, scroll: scrollState } = state;
4769
- const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
4833
+ const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "alignItemsAtEndPadding") || 0) + (peek$(ctx, "headerSize") || 0);
4770
4834
  const { itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold } = viewabilityConfig;
4771
4835
  const viewAreaMode = viewAreaCoveragePercentThreshold != null;
4772
4836
  const viewablePercentThreshold = viewAreaMode ? viewAreaCoveragePercentThreshold : itemVisiblePercentThreshold;
@@ -4787,7 +4851,7 @@ function computeViewability(state, ctx, viewabilityConfig, containerId, key, scr
4787
4851
  sizeVisible: -1
4788
4852
  };
4789
4853
  const prev2 = ctx.mapViewabilityAmountValues.get(containerId);
4790
- if (!shallowEqual(prev2, value2)) {
4854
+ if (!areViewabilityAmountTokensEqual(prev2, value2)) {
4791
4855
  ctx.mapViewabilityAmountValues.set(containerId, value2);
4792
4856
  const cb = ctx.mapViewabilityAmountCallbacks.get(containerId);
4793
4857
  if (cb) {
@@ -4817,7 +4881,7 @@ function computeViewability(state, ctx, viewabilityConfig, containerId, key, scr
4817
4881
  sizeVisible
4818
4882
  };
4819
4883
  const prev = ctx.mapViewabilityAmountValues.get(containerId);
4820
- if (!shallowEqual(prev, value)) {
4884
+ if (!areViewabilityAmountTokensEqual(prev, value)) {
4821
4885
  ctx.mapViewabilityAmountValues.set(containerId, value);
4822
4886
  const cb = ctx.mapViewabilityAmountCallbacks.get(containerId);
4823
4887
  if (cb) {
@@ -4868,126 +4932,152 @@ function getExpandedContainerPoolSize(dataLength, numContainers) {
4868
4932
  }
4869
4933
 
4870
4934
  // src/utils/findAvailableContainers.ts
4871
- function findAvailableContainers(ctx, numNeeded, startBuffered, endBuffered, pendingRemoval, requiredItemTypes, needNewContainers, protectedKeys) {
4935
+ function findAvailableContainers(ctx, needNewContainers, startBuffered, endBuffered, pendingRemoval, getRequiredItemType, protectedKeys) {
4936
+ const numNeeded = needNewContainers.length;
4937
+ if (numNeeded === 0) {
4938
+ return [];
4939
+ }
4872
4940
  const numContainers = peek$(ctx, "numContainers");
4873
4941
  const state = ctx.state;
4874
4942
  const { stickyContainerPool, containerItemTypes } = state;
4875
4943
  const shouldAvoidAssignedContainerReuse = state.props.recycleItems && !!state.props.positionComponentInternal;
4876
- const result = [];
4877
- const availableContainers = [];
4878
- const pendingRemovalSet = new Set(pendingRemoval);
4944
+ const allocations = [];
4945
+ const pendingRemovalSet = pendingRemoval.length > 0 ? new Set(pendingRemoval) : void 0;
4879
4946
  let pendingRemovalChanged = false;
4947
+ let nextNewContainerIndex = numContainers;
4948
+ const usedContainers = /* @__PURE__ */ new Set();
4949
+ let availableContainers;
4880
4950
  const stickyHeaderIndicesSet = state.props.stickyHeaderIndicesSet;
4881
- const stickyHeaderItemIndices = (needNewContainers == null ? void 0 : needNewContainers.filter((index) => stickyHeaderIndicesSet.has(index))) || [];
4882
4951
  const canReuseContainer = (containerIndex, requiredType) => {
4883
4952
  if (!requiredType) return true;
4884
4953
  const existingType = containerItemTypes.get(containerIndex);
4885
4954
  if (!existingType) return true;
4886
4955
  return existingType === requiredType;
4887
4956
  };
4888
- const neededTypes = requiredItemTypes ? [...requiredItemTypes] : [];
4889
- let typeIndex = 0;
4890
- for (let i = 0; i < stickyHeaderItemIndices.length; i++) {
4891
- const requiredType = neededTypes[typeIndex];
4892
- let foundContainer = false;
4893
- for (const containerIndex of stickyContainerPool) {
4894
- const key = peek$(ctx, `containerItemKey${containerIndex}`);
4895
- const isPendingRemoval = pendingRemovalSet.has(containerIndex);
4896
- if ((key === void 0 || isPendingRemoval) && canReuseContainer(containerIndex, requiredType) && !result.includes(containerIndex)) {
4897
- result.push(containerIndex);
4898
- if (isPendingRemoval && pendingRemovalSet.delete(containerIndex)) {
4899
- pendingRemovalChanged = true;
4900
- }
4901
- foundContainer = true;
4902
- if (requiredItemTypes) typeIndex++;
4903
- break;
4904
- }
4957
+ const pushAllocation = (itemIndex, itemType, containerIndex) => {
4958
+ allocations.push({
4959
+ containerIndex,
4960
+ itemIndex,
4961
+ itemType
4962
+ });
4963
+ usedContainers.add(containerIndex);
4964
+ if (pendingRemovalSet == null ? void 0 : pendingRemovalSet.delete(containerIndex)) {
4965
+ pendingRemovalChanged = true;
4905
4966
  }
4906
- if (!foundContainer) {
4907
- const newContainerIndex = numContainers + result.filter((index) => index >= numContainers).length;
4908
- result.push(newContainerIndex);
4967
+ };
4968
+ const pushNewContainer = (itemIndex, itemType, isSticky) => {
4969
+ const newContainerIndex = nextNewContainerIndex++;
4970
+ pushAllocation(itemIndex, itemType, newContainerIndex);
4971
+ if (isSticky) {
4909
4972
  stickyContainerPool.add(newContainerIndex);
4910
- if (requiredItemTypes) typeIndex++;
4911
- }
4912
- }
4913
- for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
4914
- if (stickyContainerPool.has(u)) {
4915
- continue;
4916
4973
  }
4917
- const key = peek$(ctx, `containerItemKey${u}`);
4918
- const requiredType = neededTypes[typeIndex];
4919
- const isPending = key !== void 0 && pendingRemovalSet.has(u);
4920
- const canUse = key === void 0 || isPending && canReuseContainer(u, requiredType);
4921
- if (canUse) {
4922
- if (isPending) {
4923
- pendingRemovalSet.delete(u);
4924
- pendingRemovalChanged = true;
4925
- }
4926
- result.push(u);
4927
- if (requiredItemTypes) {
4928
- typeIndex++;
4929
- }
4974
+ return newContainerIndex;
4975
+ };
4976
+ const canUseContainer = (containerIndex, itemType) => {
4977
+ if (usedContainers.has(containerIndex) || stickyContainerPool.has(containerIndex)) {
4978
+ return false;
4930
4979
  }
4931
- }
4932
- if (!shouldAvoidAssignedContainerReuse) {
4933
- for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
4934
- if (stickyContainerPool.has(u)) {
4935
- continue;
4936
- }
4937
- const key = peek$(ctx, `containerItemKey${u}`);
4938
- if (key === void 0) continue;
4939
- if ((protectedKeys == null ? void 0 : protectedKeys.has(key)) && state.indexByKey.has(key)) continue;
4940
- const index = state.indexByKey.get(key);
4941
- const isOutOfView = index < startBuffered || index > endBuffered;
4942
- if (isOutOfView) {
4943
- const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
4944
- if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
4945
- availableContainers.push({ distance, index: u });
4980
+ const key = peek$(ctx, `containerItemKey${containerIndex}`);
4981
+ const isPending = !!(pendingRemovalSet == null ? void 0 : pendingRemovalSet.has(containerIndex));
4982
+ return (key === void 0 || isPending) && canReuseContainer(containerIndex, itemType);
4983
+ };
4984
+ const findStickyContainer = (itemType) => {
4985
+ let foundContainer;
4986
+ for (const containerIndex of stickyContainerPool) {
4987
+ if (!usedContainers.has(containerIndex)) {
4988
+ const key = peek$(ctx, `containerItemKey${containerIndex}`);
4989
+ const isPendingRemoval = !!(pendingRemovalSet == null ? void 0 : pendingRemovalSet.has(containerIndex));
4990
+ if ((key === void 0 || isPendingRemoval) && canReuseContainer(containerIndex, itemType)) {
4991
+ foundContainer = containerIndex;
4992
+ break;
4946
4993
  }
4947
4994
  }
4948
4995
  }
4949
- }
4950
- const remaining = numNeeded - result.length;
4951
- if (remaining > 0) {
4952
- if (availableContainers.length > 0) {
4953
- if (availableContainers.length > remaining) {
4954
- availableContainers.sort(comparatorByDistance);
4955
- availableContainers.length = remaining;
4996
+ return foundContainer;
4997
+ };
4998
+ const findUnassignedOrPendingContainer = (itemType) => {
4999
+ let foundContainer;
5000
+ for (let containerIndex = 0; containerIndex < numContainers && foundContainer === void 0; containerIndex++) {
5001
+ if (canUseContainer(containerIndex, itemType)) {
5002
+ foundContainer = containerIndex;
4956
5003
  }
4957
- for (const container of availableContainers) {
4958
- result.push(container.index);
4959
- if (requiredItemTypes) {
4960
- typeIndex++;
5004
+ }
5005
+ return foundContainer;
5006
+ };
5007
+ const getAvailableContainers = () => {
5008
+ if (!availableContainers) {
5009
+ availableContainers = [];
5010
+ if (!shouldAvoidAssignedContainerReuse) {
5011
+ for (let containerIndex = 0; containerIndex < numContainers; containerIndex++) {
5012
+ if (usedContainers.has(containerIndex) || stickyContainerPool.has(containerIndex)) {
5013
+ continue;
5014
+ }
5015
+ const key = peek$(ctx, `containerItemKey${containerIndex}`);
5016
+ if (key === void 0) continue;
5017
+ if ((protectedKeys == null ? void 0 : protectedKeys.has(key)) && state.indexByKey.has(key)) continue;
5018
+ const index = state.indexByKey.get(key);
5019
+ const isOutOfView = index < startBuffered || index > endBuffered;
5020
+ if (isOutOfView) {
5021
+ const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
5022
+ availableContainers.push({ distance, index: containerIndex });
5023
+ }
4961
5024
  }
5025
+ availableContainers.sort(comparatorByDistance);
4962
5026
  }
4963
5027
  }
4964
- const stillNeeded = numNeeded - result.length;
4965
- if (stillNeeded > 0) {
4966
- for (let i = 0; i < stillNeeded; i++) {
4967
- result.push(numContainers + i);
5028
+ return availableContainers;
5029
+ };
5030
+ const findAvailableContainer = (itemType) => {
5031
+ const containers = getAvailableContainers();
5032
+ let matchIndex = -1;
5033
+ for (let i = 0; i < containers.length && matchIndex === -1; i++) {
5034
+ const containerIndex = containers[i].index;
5035
+ if (!usedContainers.has(containerIndex) && canReuseContainer(containerIndex, itemType)) {
5036
+ matchIndex = i;
4968
5037
  }
4969
- if (IS_DEV && numContainers + stillNeeded > peek$(ctx, "numContainersPooled")) {
4970
- console.warn(
4971
- "[legend-list] No unused container available, so creating one on demand. This can be a minor performance issue and is likely caused by the estimatedItemSize being too large. Consider decreasing estimatedItemSize.",
4972
- {
4973
- debugInfo: {
4974
- numContainers,
4975
- numContainersPooled: peek$(ctx, "numContainersPooled"),
4976
- numNeeded,
4977
- stillNeeded
4978
- }
4979
- }
4980
- );
5038
+ }
5039
+ return matchIndex === -1 ? void 0 : containers.splice(matchIndex, 1)[0].index;
5040
+ };
5041
+ for (const itemIndex of needNewContainers) {
5042
+ const itemType = getRequiredItemType == null ? void 0 : getRequiredItemType(itemIndex);
5043
+ const isSticky = stickyHeaderIndicesSet.has(itemIndex);
5044
+ let containerIndex;
5045
+ if (isSticky) {
5046
+ containerIndex = findStickyContainer(itemType);
5047
+ } else {
5048
+ containerIndex = findUnassignedOrPendingContainer(itemType);
5049
+ if (containerIndex === void 0) {
5050
+ containerIndex = findAvailableContainer(itemType);
4981
5051
  }
4982
5052
  }
5053
+ if (containerIndex !== void 0) {
5054
+ pushAllocation(itemIndex, itemType, containerIndex);
5055
+ } else {
5056
+ pushNewContainer(itemIndex, itemType, isSticky);
5057
+ }
4983
5058
  }
4984
5059
  if (pendingRemovalChanged) {
4985
5060
  pendingRemoval.length = 0;
4986
- for (const value of pendingRemovalSet) {
4987
- pendingRemoval.push(value);
5061
+ if (pendingRemovalSet) {
5062
+ for (const value of pendingRemovalSet) {
5063
+ pendingRemoval.push(value);
5064
+ }
4988
5065
  }
4989
5066
  }
4990
- return result.sort(comparatorDefault);
5067
+ if (IS_DEV && nextNewContainerIndex > peek$(ctx, "numContainersPooled")) {
5068
+ console.warn(
5069
+ "[legend-list] No unused container available, so creating one on demand. This can be a minor performance issue and is likely caused by the estimatedItemSize being too large. Consider decreasing estimatedItemSize.",
5070
+ {
5071
+ debugInfo: {
5072
+ numContainers,
5073
+ numContainersPooled: peek$(ctx, "numContainersPooled"),
5074
+ numNeeded,
5075
+ stillNeeded: nextNewContainerIndex - numContainers
5076
+ }
5077
+ }
5078
+ );
5079
+ }
5080
+ return allocations;
4991
5081
  }
4992
5082
  function comparatorByDistance(a, b) {
4993
5083
  return b.distance - a.distance;
@@ -5013,21 +5103,28 @@ function findCurrentStickyIndex(stickyArray, scroll, state) {
5013
5103
  }
5014
5104
  return -1;
5015
5105
  }
5016
- function getActiveStickyIndices(ctx, stickyHeaderIndices) {
5106
+ function isStickyIndexActive(ctx, targetIndex) {
5017
5107
  const state = ctx.state;
5018
- return new Set(
5019
- Array.from(state.stickyContainerPool).map((i) => peek$(ctx, `containerItemKey${i}`)).map((key) => key ? state.indexByKey.get(key) : void 0).filter((idx) => idx !== void 0 && stickyHeaderIndices.has(idx))
5020
- );
5108
+ let isActive = false;
5109
+ for (const containerIndex of state.stickyContainerPool) {
5110
+ const key = peek$(ctx, `containerItemKey${containerIndex}`);
5111
+ const itemIndex = key ? state.indexByKey.get(key) : void 0;
5112
+ if (itemIndex === targetIndex) {
5113
+ isActive = true;
5114
+ break;
5115
+ }
5116
+ }
5117
+ return isActive;
5021
5118
  }
5022
- function handleStickyActivation(ctx, stickyHeaderIndices, stickyArray, currentStickyIdx, needNewContainers, needNewContainersSet, startBuffered, endBuffered) {
5119
+ function handleStickyActivation(ctx, stickyArray, currentStickyIdx, needNewContainers, needNewContainersSet, startBuffered, endBuffered) {
5023
5120
  var _a3;
5024
5121
  const state = ctx.state;
5025
- const activeIndices = getActiveStickyIndices(ctx, stickyHeaderIndices);
5026
5122
  set$(ctx, "activeStickyIndex", currentStickyIdx >= 0 ? stickyArray[currentStickyIdx] : -1);
5027
5123
  for (let offset = 0; offset <= 1; offset++) {
5028
5124
  const idx = currentStickyIdx - offset;
5029
- if (idx < 0 || activeIndices.has(stickyArray[idx])) continue;
5125
+ if (idx < 0) continue;
5030
5126
  const stickyIndex = stickyArray[idx];
5127
+ if (isStickyIndexActive(ctx, stickyIndex)) continue;
5031
5128
  const stickyId = (_a3 = state.idCache[stickyIndex]) != null ? _a3 : getId(state, stickyIndex);
5032
5129
  if (stickyId && !state.containerItemKeys.has(stickyId) && (stickyIndex < startBuffered || stickyIndex > endBuffered) && !needNewContainersSet.has(stickyIndex)) {
5033
5130
  needNewContainersSet.add(stickyIndex);
@@ -5069,10 +5166,86 @@ function handleStickyRecycling(ctx, stickyArray, scroll, drawDistance, currentSt
5069
5166
  }
5070
5167
  }
5071
5168
  }
5169
+ function trackVisibleRange(range, i, top, size, scroll, scrollBottom) {
5170
+ let didPassVisibleEnd = false;
5171
+ if (range.startNoBuffer === null && top + size > scroll) {
5172
+ range.startNoBuffer = i;
5173
+ }
5174
+ if (range.firstFullyOnScreenIndex === void 0 && top >= scroll - 10 && top <= scrollBottom) {
5175
+ range.firstFullyOnScreenIndex = i;
5176
+ }
5177
+ if (range.startNoBuffer !== null) {
5178
+ if (top <= scrollBottom) {
5179
+ range.endNoBuffer = i;
5180
+ } else {
5181
+ didPassVisibleEnd = true;
5182
+ }
5183
+ }
5184
+ return didPassVisibleEnd;
5185
+ }
5186
+ function getIdsInVisibleRange(state, range) {
5187
+ var _a3, _b;
5188
+ const idsInView = [];
5189
+ const firstVisibleAnchorIndex = (_a3 = range.firstFullyOnScreenIndex) != null ? _a3 : range.startNoBuffer;
5190
+ if (firstVisibleAnchorIndex !== null && firstVisibleAnchorIndex !== void 0 && range.endNoBuffer !== null) {
5191
+ for (let i = firstVisibleAnchorIndex; i <= range.endNoBuffer; i++) {
5192
+ const id = (_b = state.idCache[i]) != null ? _b : getId(state, i);
5193
+ idsInView.push(id);
5194
+ }
5195
+ }
5196
+ return idsInView;
5197
+ }
5198
+ function updateViewabilityForCachedRange(ctx, viewabilityConfigCallbackPairs, scrollLength, scroll, scrollBottom) {
5199
+ var _a3, _b;
5200
+ const state = ctx.state;
5201
+ const {
5202
+ endBuffered,
5203
+ idCache,
5204
+ positions,
5205
+ props: { data },
5206
+ sizes,
5207
+ startBuffered
5208
+ } = state;
5209
+ if (startBuffered === null || endBuffered === null || startBuffered < 0 || endBuffered < startBuffered) {
5210
+ return;
5211
+ }
5212
+ const visibleRange = {
5213
+ endNoBuffer: null,
5214
+ firstFullyOnScreenIndex: void 0,
5215
+ startNoBuffer: null
5216
+ };
5217
+ for (let i = startBuffered; i <= endBuffered && i < data.length; i++) {
5218
+ const id = (_a3 = idCache[i]) != null ? _a3 : getId(state, i);
5219
+ const size = (_b = sizes.get(id)) != null ? _b : getItemSize(ctx, id, i, data[i]);
5220
+ const top = positions[i];
5221
+ const didPassVisibleEnd = trackVisibleRange(visibleRange, i, top, size, scroll, scrollBottom);
5222
+ if (didPassVisibleEnd) {
5223
+ break;
5224
+ }
5225
+ }
5226
+ Object.assign(state, {
5227
+ endNoBuffer: visibleRange.endNoBuffer,
5228
+ firstFullyOnScreenIndex: visibleRange.firstFullyOnScreenIndex,
5229
+ idsInView: getIdsInVisibleRange(state, visibleRange),
5230
+ startNoBuffer: visibleRange.startNoBuffer
5231
+ });
5232
+ if (visibleRange.startNoBuffer !== null && visibleRange.endNoBuffer !== null) {
5233
+ updateViewableItems(
5234
+ state,
5235
+ ctx,
5236
+ viewabilityConfigCallbackPairs,
5237
+ scrollLength,
5238
+ visibleRange.startNoBuffer,
5239
+ visibleRange.endNoBuffer,
5240
+ startBuffered,
5241
+ endBuffered
5242
+ );
5243
+ }
5244
+ }
5072
5245
  function calculateItemsInView(ctx, params = {}) {
5073
5246
  const state = ctx.state;
5074
5247
  batchedUpdates(() => {
5075
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
5248
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
5076
5249
  const {
5077
5250
  columns,
5078
5251
  containerItemKeys,
@@ -5108,7 +5281,7 @@ function calculateItemsInView(ctx, params = {}) {
5108
5281
  return;
5109
5282
  }
5110
5283
  let totalSize = getContentSize(ctx);
5111
- const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
5284
+ const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "alignItemsAtEndPadding") + peek$(ctx, "headerSize");
5112
5285
  const numColumns = peek$(ctx, "numColumns");
5113
5286
  const speed = getScrollVelocity(state);
5114
5287
  const scrollExtra = 0;
@@ -5173,6 +5346,15 @@ function calculateItemsInView(ctx, params = {}) {
5173
5346
  state.scrollForNextCalculateItemsInView = void 0;
5174
5347
  } else if ((top === null || scrollTopBuffered > top) && (bottom === null || scrollBottomBuffered < bottom)) {
5175
5348
  if (!isInMVCPActiveMode(state)) {
5349
+ if (viewabilityConfigCallbackPairs) {
5350
+ updateViewabilityForCachedRange(
5351
+ ctx,
5352
+ viewabilityConfigCallbackPairs,
5353
+ scrollLength,
5354
+ scroll,
5355
+ scrollBottom
5356
+ );
5357
+ }
5176
5358
  finishCalculateItemsInView == null ? void 0 : finishCalculateItemsInView();
5177
5359
  return;
5178
5360
  }
@@ -5189,6 +5371,7 @@ function calculateItemsInView(ctx, params = {}) {
5189
5371
  forceFullUpdate: !!forceFullItemPositions,
5190
5372
  optimizeForVisibleWindow,
5191
5373
  scrollBottomBuffered,
5374
+ scrollVelocity: speed,
5192
5375
  startIndex
5193
5376
  });
5194
5377
  totalSize = getContentSize(ctx);
@@ -5214,10 +5397,8 @@ function calculateItemsInView(ctx, params = {}) {
5214
5397
  updateScroll2(state.scroll);
5215
5398
  updateScrollRange();
5216
5399
  }
5217
- let startNoBuffer = null;
5218
5400
  let startBuffered = null;
5219
5401
  let startBufferedId = null;
5220
- let endNoBuffer = null;
5221
5402
  let endBuffered = null;
5222
5403
  let loopStart = (_f = suppressInitialScrollSideEffects ? bootstrapInitialScrollState == null ? void 0 : bootstrapInitialScrollState.targetIndexSeed : void 0) != null ? _f : !dataChanged && startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
5223
5404
  for (let i = loopStart; i >= 0; i--) {
@@ -5251,19 +5432,18 @@ function calculateItemsInView(ctx, params = {}) {
5251
5432
  maxIndexRendered = Math.max(maxIndexRendered, index);
5252
5433
  }
5253
5434
  }
5254
- let firstFullyOnScreenIndex;
5435
+ const visibleRange = {
5436
+ endNoBuffer: null,
5437
+ firstFullyOnScreenIndex: void 0,
5438
+ startNoBuffer: null
5439
+ };
5255
5440
  const dataLength = data.length;
5256
5441
  for (let i = Math.max(0, loopStart); i < dataLength && (!foundEnd || i <= maxIndexRendered); i++) {
5257
5442
  const id = (_i = idCache[i]) != null ? _i : getId(state, i);
5258
5443
  const size = (_j = sizes.get(id)) != null ? _j : getItemSize(ctx, id, i, data[i]);
5259
5444
  const top = positions[i];
5260
5445
  if (!foundEnd) {
5261
- if (startNoBuffer === null && top + size > scroll) {
5262
- startNoBuffer = i;
5263
- }
5264
- if (firstFullyOnScreenIndex === void 0 && top >= scroll - 10 && top <= scrollBottom) {
5265
- firstFullyOnScreenIndex = i;
5266
- }
5446
+ trackVisibleRange(visibleRange, i, top, size, scroll, scrollBottom);
5267
5447
  if (startBuffered === null && top + size > scrollTopBuffered) {
5268
5448
  startBuffered = i;
5269
5449
  startBufferedId = id;
@@ -5273,10 +5453,7 @@ function calculateItemsInView(ctx, params = {}) {
5273
5453
  nextTop = top;
5274
5454
  }
5275
5455
  }
5276
- if (startNoBuffer !== null) {
5277
- if (top <= scrollBottom) {
5278
- endNoBuffer = i;
5279
- }
5456
+ if (visibleRange.startNoBuffer !== null) {
5280
5457
  if (top <= scrollBottomBuffered) {
5281
5458
  endBuffered = i;
5282
5459
  if (scrollBottomBuffered > totalSize) {
@@ -5290,22 +5467,14 @@ function calculateItemsInView(ctx, params = {}) {
5290
5467
  }
5291
5468
  }
5292
5469
  }
5293
- const idsInView = [];
5294
- const firstVisibleAnchorIndex = firstFullyOnScreenIndex != null ? firstFullyOnScreenIndex : startNoBuffer;
5295
- if (firstVisibleAnchorIndex !== null && firstVisibleAnchorIndex !== void 0 && endNoBuffer !== null) {
5296
- for (let i = firstVisibleAnchorIndex; i <= endNoBuffer; i++) {
5297
- const id = (_k = idCache[i]) != null ? _k : getId(state, i);
5298
- idsInView.push(id);
5299
- }
5300
- }
5301
5470
  Object.assign(state, {
5302
5471
  endBuffered,
5303
- endNoBuffer,
5304
- firstFullyOnScreenIndex,
5305
- idsInView,
5472
+ endNoBuffer: visibleRange.endNoBuffer,
5473
+ firstFullyOnScreenIndex: visibleRange.firstFullyOnScreenIndex,
5474
+ idsInView: getIdsInVisibleRange(state, visibleRange),
5306
5475
  startBuffered,
5307
5476
  startBufferedId,
5308
- startNoBuffer
5477
+ startNoBuffer: visibleRange.startNoBuffer
5309
5478
  });
5310
5479
  if (enableScrollForNextCalculateItemsInView && nextTop !== void 0 && nextBottom !== void 0) {
5311
5480
  state.scrollForNextCalculateItemsInView = isNullOrUndefined(nextTop) && isNullOrUndefined(nextBottom) ? void 0 : {
@@ -5327,7 +5496,7 @@ function calculateItemsInView(ctx, params = {}) {
5327
5496
  const needNewContainers = [];
5328
5497
  const needNewContainersSet = /* @__PURE__ */ new Set();
5329
5498
  for (let i = startBuffered; i <= endBuffered; i++) {
5330
- const id = (_l = idCache[i]) != null ? _l : getId(state, i);
5499
+ const id = (_k = idCache[i]) != null ? _k : getId(state, i);
5331
5500
  if (!containerItemKeys.has(id)) {
5332
5501
  needNewContainersSet.add(i);
5333
5502
  needNewContainers.push(i);
@@ -5336,7 +5505,7 @@ function calculateItemsInView(ctx, params = {}) {
5336
5505
  if (alwaysRenderArr.length > 0) {
5337
5506
  for (const index of alwaysRenderArr) {
5338
5507
  if (index < 0 || index >= dataLength) continue;
5339
- const id = (_m = idCache[index]) != null ? _m : getId(state, index);
5508
+ const id = (_l = idCache[index]) != null ? _l : getId(state, index);
5340
5509
  if (id && !containerItemKeys.has(id) && !needNewContainersSet.has(index)) {
5341
5510
  needNewContainersSet.add(index);
5342
5511
  needNewContainers.push(index);
@@ -5346,7 +5515,6 @@ function calculateItemsInView(ctx, params = {}) {
5346
5515
  if (stickyHeaderIndicesArr.length > 0) {
5347
5516
  handleStickyActivation(
5348
5517
  ctx,
5349
- stickyHeaderIndicesSet,
5350
5518
  stickyHeaderIndicesArr,
5351
5519
  currentStickyIdx,
5352
5520
  needNewContainers,
@@ -5358,35 +5526,34 @@ function calculateItemsInView(ctx, params = {}) {
5358
5526
  set$(ctx, "activeStickyIndex", -1);
5359
5527
  }
5360
5528
  if (needNewContainers.length > 0) {
5361
- const requiredItemTypes = getItemType ? needNewContainers.map((i) => {
5529
+ const getRequiredItemType = getItemType ? (i) => {
5362
5530
  const itemType = getItemType(data[i], i);
5363
5531
  return itemType !== void 0 ? String(itemType) : "";
5364
- }) : void 0;
5365
- const availableContainers = findAvailableContainers(
5532
+ } : void 0;
5533
+ const availableContainerAllocations = findAvailableContainers(
5366
5534
  ctx,
5367
- needNewContainers.length,
5535
+ needNewContainers,
5368
5536
  startBuffered,
5369
5537
  endBuffered,
5370
5538
  pendingRemoval,
5371
- requiredItemTypes,
5372
- needNewContainers,
5539
+ getRequiredItemType,
5373
5540
  protectedContainerKeys
5374
5541
  );
5375
- for (let idx = 0; idx < needNewContainers.length; idx++) {
5376
- const i = needNewContainers[idx];
5377
- const containerIndex = availableContainers[idx];
5378
- const id = (_n = idCache[i]) != null ? _n : getId(state, i);
5542
+ for (const allocation of availableContainerAllocations) {
5543
+ const i = allocation.itemIndex;
5544
+ const containerIndex = allocation.containerIndex;
5545
+ const id = (_m = idCache[i]) != null ? _m : getId(state, i);
5379
5546
  const oldKey = peek$(ctx, `containerItemKey${containerIndex}`);
5380
5547
  if (oldKey && oldKey !== id) {
5381
5548
  containerItemKeys.delete(oldKey);
5382
5549
  }
5383
5550
  set$(ctx, `containerItemKey${containerIndex}`, id);
5384
5551
  set$(ctx, `containerItemData${containerIndex}`, data[i]);
5385
- if (requiredItemTypes) {
5386
- state.containerItemTypes.set(containerIndex, requiredItemTypes[idx]);
5552
+ if (allocation.itemType !== void 0) {
5553
+ state.containerItemTypes.set(containerIndex, allocation.itemType);
5387
5554
  }
5388
5555
  containerItemKeys.set(id, containerIndex);
5389
- (_o = state.userScrollAnchorReset) == null ? void 0 : _o.keys.add(id);
5556
+ (_n = state.userScrollAnchorReset) == null ? void 0 : _n.keys.add(id);
5390
5557
  const containerSticky = `containerSticky${containerIndex}`;
5391
5558
  const isSticky = stickyHeaderIndicesSet.has(i);
5392
5559
  const isAlwaysRender = alwaysRenderSet.has(i);
@@ -5424,7 +5591,7 @@ function calculateItemsInView(ctx, params = {}) {
5424
5591
  if (alwaysRenderArr.length > 0) {
5425
5592
  for (const index of alwaysRenderArr) {
5426
5593
  if (index < 0 || index >= dataLength) continue;
5427
- const id = (_p = idCache[index]) != null ? _p : getId(state, index);
5594
+ const id = (_o = idCache[index]) != null ? _o : getId(state, index);
5428
5595
  const containerIndex = containerItemKeys.get(id);
5429
5596
  if (containerIndex !== void 0) {
5430
5597
  state.stickyContainerPool.add(containerIndex);
@@ -5443,10 +5610,11 @@ function calculateItemsInView(ctx, params = {}) {
5443
5610
  alwaysRenderSet
5444
5611
  );
5445
5612
  }
5613
+ const pendingRemovalSet = pendingRemoval.length > 0 ? new Set(pendingRemoval) : void 0;
5446
5614
  let didChangePositions = false;
5447
5615
  for (let i = 0; i < numContainers; i++) {
5448
5616
  const itemKey = peek$(ctx, `containerItemKey${i}`);
5449
- if (pendingRemoval.includes(i)) {
5617
+ if (pendingRemovalSet == null ? void 0 : pendingRemovalSet.has(i)) {
5450
5618
  if (itemKey !== void 0) {
5451
5619
  containerItemKeys.delete(itemKey);
5452
5620
  }
@@ -5477,24 +5645,24 @@ function calculateItemsInView(ctx, params = {}) {
5477
5645
  evaluateBootstrapInitialScroll(ctx);
5478
5646
  return;
5479
5647
  }
5480
- const mountedBufferedIndices = getMountedBufferedIndices(state);
5481
- const mountedNoBufferIndices = getMountedNoBufferIndices(state);
5482
- const readinessIndices = hasActiveInitialScroll(state) ? mountedBufferedIndices : mountedNoBufferIndices.length > 0 ? mountedNoBufferIndices : mountedBufferedIndices;
5483
- if (!queuedInitialLayout && readinessIndices.length > 0 && checkAllSizesKnown(state, readinessIndices)) {
5484
- setDidLayout(ctx);
5485
- handleInitialScrollLayoutReady(ctx);
5648
+ if (!queuedInitialLayout && !state.didContainersLayout) {
5649
+ const isInitialLayoutReady = hasActiveInitialScroll(state) ? checkAllSizesKnown(state, state.startBuffered, state.endBuffered) : checkAllSizesKnown(state, state.startNoBuffer, state.endNoBuffer) || checkAllSizesKnown(state, state.startBuffered, state.endBuffered);
5650
+ if (isInitialLayoutReady) {
5651
+ setDidLayout(ctx);
5652
+ handleInitialScrollLayoutReady(ctx);
5653
+ }
5486
5654
  }
5487
- if (viewabilityConfigCallbackPairs && startNoBuffer !== null && endNoBuffer !== null) {
5655
+ if (viewabilityConfigCallbackPairs && visibleRange.startNoBuffer !== null && visibleRange.endNoBuffer !== null) {
5488
5656
  if (!didMVCPAdjustScroll) {
5489
5657
  updateViewableItems(
5490
5658
  ctx.state,
5491
5659
  ctx,
5492
5660
  viewabilityConfigCallbackPairs,
5493
5661
  scrollLength,
5494
- startNoBuffer,
5495
- endNoBuffer,
5496
- startBuffered != null ? startBuffered : startNoBuffer,
5497
- endBuffered != null ? endBuffered : endNoBuffer
5662
+ visibleRange.startNoBuffer,
5663
+ visibleRange.endNoBuffer,
5664
+ startBuffered != null ? startBuffered : visibleRange.startNoBuffer,
5665
+ endBuffered != null ? endBuffered : visibleRange.endNoBuffer
5498
5666
  );
5499
5667
  }
5500
5668
  }
@@ -5657,6 +5825,7 @@ function handleLayout(ctx, layoutParam, setCanRender) {
5657
5825
  if (didChange) {
5658
5826
  state.scrollLength = scrollLength;
5659
5827
  state.otherAxisSize = otherAxisSize;
5828
+ updateContentMetrics(ctx);
5660
5829
  state.lastBatchingAction = Date.now();
5661
5830
  state.scrollForNextCalculateItemsInView = void 0;
5662
5831
  if (scrollLength > 0) {
@@ -5953,6 +6122,7 @@ function updateItemSize(ctx, itemKey, sizeObj) {
5953
6122
  } = state;
5954
6123
  if (!data) return;
5955
6124
  const index = state.indexByKey.get(itemKey);
6125
+ let resolvedMeasurementItem;
5956
6126
  if (getFixedItemSize) {
5957
6127
  if (index === void 0) {
5958
6128
  return;
@@ -5963,6 +6133,12 @@ function updateItemSize(ctx, itemKey, sizeObj) {
5963
6133
  }
5964
6134
  const type = getItemType ? (_a3 = getItemType(itemData, index)) != null ? _a3 : "" : "";
5965
6135
  const size2 = getFixedItemSize(itemData, index, type);
6136
+ resolvedMeasurementItem = {
6137
+ didResolveFixedItemSize: true,
6138
+ fixedItemSize: size2,
6139
+ itemData,
6140
+ itemType: type
6141
+ };
5966
6142
  if (size2 !== void 0 && size2 === sizesKnown.get(itemKey)) {
5967
6143
  updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
5968
6144
  return;
@@ -5972,7 +6148,7 @@ function updateItemSize(ctx, itemKey, sizeObj) {
5972
6148
  let shouldMaintainScrollAtEnd = false;
5973
6149
  let minIndexSizeChanged;
5974
6150
  const prevSizeKnown = state.sizesKnown.get(itemKey);
5975
- const diff = updateOneItemSize(ctx, itemKey, sizeObj);
6151
+ const diff = updateOneItemSize(ctx, itemKey, sizeObj, resolvedMeasurementItem);
5976
6152
  const size = roundSize(horizontal ? sizeObj.width : sizeObj.height);
5977
6153
  if (diff !== 0) {
5978
6154
  minIndexSizeChanged = minIndexSizeChanged !== void 0 ? Math.min(minIndexSizeChanged, index) : index;
@@ -5997,7 +6173,7 @@ function updateItemSize(ctx, itemKey, sizeObj) {
5997
6173
  state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, minIndexSizeChanged) : minIndexSizeChanged;
5998
6174
  }
5999
6175
  updateOtherAxisSizeIfNeeded(ctx, sizeObj, horizontal);
6000
- if (didContainersLayout || checkAllSizesKnown(state, getMountedBufferedIndices(state))) {
6176
+ if (didContainersLayout || checkAllSizesKnown(state, state.startBuffered, state.endBuffered)) {
6001
6177
  if (needsRecalculate) {
6002
6178
  state.scrollForNextCalculateItemsInView = void 0;
6003
6179
  runOrScheduleMVCPRecalculate(ctx);
@@ -6011,8 +6187,8 @@ function updateItemSize(ctx, itemKey, sizeObj) {
6011
6187
  }
6012
6188
  }
6013
6189
  }
6014
- function updateOneItemSize(ctx, itemKey, sizeObj) {
6015
- var _a3, _b;
6190
+ function updateOneItemSize(ctx, itemKey, sizeObj, resolvedMeasurementItem) {
6191
+ var _a3, _b, _c;
6016
6192
  const state = ctx.state;
6017
6193
  const {
6018
6194
  indexByKey,
@@ -6022,20 +6198,25 @@ function updateOneItemSize(ctx, itemKey, sizeObj) {
6022
6198
  } = state;
6023
6199
  if (!data) return 0;
6024
6200
  const index = indexByKey.get(itemKey);
6025
- const itemData = data[index];
6026
- let itemType;
6027
- let fixedItemSize;
6028
- if (getFixedItemSize) {
6029
- itemType = getItemType ? (_a3 = getItemType(itemData, index)) != null ? _a3 : "" : "";
6201
+ const itemData = (_a3 = resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.itemData) != null ? _a3 : data[index];
6202
+ let itemType = resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.itemType;
6203
+ let fixedItemSize = resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.fixedItemSize;
6204
+ if (getFixedItemSize && !(resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.didResolveFixedItemSize)) {
6205
+ itemType = getItemType ? (_b = getItemType(itemData, index)) != null ? _b : "" : "";
6030
6206
  fixedItemSize = getFixedItemSize(itemData, index, itemType);
6031
6207
  }
6032
- const prevSize = getItemSize(ctx, itemKey, index, itemData);
6208
+ const resolvedItemSize = (resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.didResolveFixedItemSize) || itemType !== void 0 || fixedItemSize !== void 0 ? {
6209
+ didResolveFixedItemSize: resolvedMeasurementItem == null ? void 0 : resolvedMeasurementItem.didResolveFixedItemSize,
6210
+ fixedItemSize,
6211
+ itemType
6212
+ } : void 0;
6213
+ const prevSize = getItemSize(ctx, itemKey, index, itemData, void 0, void 0, void 0, resolvedItemSize);
6033
6214
  const rawSize = horizontal ? sizeObj.width : sizeObj.height;
6034
6215
  const prevSizeKnown = sizesKnown.get(itemKey);
6035
6216
  const size = Math.round(rawSize) ;
6036
6217
  sizesKnown.set(itemKey, size);
6037
6218
  if (fixedItemSize === void 0 && size > 0) {
6038
- itemType != null ? itemType : itemType = getItemType ? (_b = getItemType(itemData, index)) != null ? _b : "" : "";
6219
+ itemType != null ? itemType : itemType = getItemType ? (_c = getItemType(itemData, index)) != null ? _c : "" : "";
6039
6220
  let averages = averageSizes[itemType];
6040
6221
  if (!averages) {
6041
6222
  averages = averageSizes[itemType] = { avg: 0, num: 0 };
@@ -6137,6 +6318,11 @@ function getAverageItemSizes(state) {
6137
6318
  }
6138
6319
  return averageItemSizes;
6139
6320
  }
6321
+ function triggerMountedContainerLayouts(ctx) {
6322
+ for (const triggerLayout of ctx.containerLayoutTriggers.values()) {
6323
+ triggerLayout();
6324
+ }
6325
+ }
6140
6326
  function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
6141
6327
  const state = ctx.state;
6142
6328
  const IMPERATIVE_SCROLL_SETTLE_MAX_WAIT_MS = 800;
@@ -6262,6 +6448,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
6262
6448
  state.columns.length = 0;
6263
6449
  state.columnSpans.length = 0;
6264
6450
  }
6451
+ triggerMountedContainerLayouts(ctx);
6265
6452
  (_b = state.triggerCalculateItemsInView) == null ? void 0 : _b.call(state, { forceFullItemPositions: true });
6266
6453
  };
6267
6454
  return {
@@ -6304,10 +6491,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
6304
6491
  startBuffered: state.startBuffered
6305
6492
  }),
6306
6493
  reportContentInset: (inset) => {
6307
- var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
6308
- const previousInset = state.contentInsetOverride;
6309
- state.contentInsetOverride = inset != null ? inset : void 0;
6310
- const didChange = ((_a3 = previousInset == null ? void 0 : previousInset.top) != null ? _a3 : 0) !== ((_c = (_b = state.contentInsetOverride) == null ? void 0 : _b.top) != null ? _c : 0) || ((_d = previousInset == null ? void 0 : previousInset.bottom) != null ? _d : 0) !== ((_f = (_e = state.contentInsetOverride) == null ? void 0 : _e.bottom) != null ? _f : 0) || ((_g = previousInset == null ? void 0 : previousInset.left) != null ? _g : 0) !== ((_i = (_h = state.contentInsetOverride) == null ? void 0 : _h.left) != null ? _i : 0) || ((_j = previousInset == null ? void 0 : previousInset.right) != null ? _j : 0) !== ((_l = (_k = state.contentInsetOverride) == null ? void 0 : _k.right) != null ? _l : 0);
6494
+ const didChange = setContentInsetOverride(ctx, inset);
6311
6495
  updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
6312
6496
  if (didChange) {
6313
6497
  retargetActiveInitialScrollAtEnd(ctx);
@@ -6663,10 +6847,11 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6663
6847
  ...restProps
6664
6848
  } = rest;
6665
6849
  const contentContainerStyleBase = StyleSheet.flatten(contentContainerStyleProp);
6666
- const shouldFlexGrow = alignItemsAtEnd && (horizontal ? (contentContainerStyleBase == null ? void 0 : contentContainerStyleBase.minWidth) == null : (contentContainerStyleBase == null ? void 0 : contentContainerStyleBase.minHeight) == null);
6850
+ const useAlignItemsAtEndPadding = alignItemsAtEnd && !horizontal && (contentContainerStyleBase == null ? void 0 : contentContainerStyleBase.minHeight) == null && dataProp.length > 0;
6851
+ const shouldFlexGrow = alignItemsAtEnd && !useAlignItemsAtEndPadding && (horizontal ? (contentContainerStyleBase == null ? void 0 : contentContainerStyleBase.minWidth) == null : (contentContainerStyleBase == null ? void 0 : contentContainerStyleBase.minHeight) == null);
6667
6852
  const contentContainerStyle = {
6668
6853
  ...contentContainerStyleBase,
6669
- ...alignItemsAtEnd ? {
6854
+ ...alignItemsAtEnd && !useAlignItemsAtEndPadding ? {
6670
6855
  display: "flex",
6671
6856
  flexDirection: horizontal ? "row" : "column",
6672
6857
  ...shouldFlexGrow ? { flexGrow: 1 } : {},
@@ -6830,6 +7015,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6830
7015
  const didAnchoredEndSpaceAnchorIndexChange = !isFirstLocal && !didDataChangeLocal && ((_g = state.props.anchoredEndSpace) == null ? void 0 : _g.anchorIndex) !== (anchoredEndSpaceResolved == null ? void 0 : anchoredEndSpaceResolved.anchorIndex);
6831
7016
  state.props = {
6832
7017
  alignItemsAtEnd,
7018
+ alignItemsAtEndPaddingEnabled: useAlignItemsAtEndPadding,
6833
7019
  alwaysRender,
6834
7020
  alwaysRenderIndicesArr: alwaysRenderIndices.arr,
6835
7021
  alwaysRenderIndicesSet: alwaysRenderIndices.set,
@@ -6887,6 +7073,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
6887
7073
  const prevPaddingTop = peek$(ctx, "stylePaddingTop");
6888
7074
  setPaddingTop(ctx, { stylePaddingTop: stylePaddingTopState });
6889
7075
  refState.current.props.stylePaddingBottom = stylePaddingBottomState;
7076
+ updateContentMetrics(ctx);
6890
7077
  let paddingDiff = stylePaddingTopState - prevPaddingTop;
6891
7078
  if (shouldAdjustPadding && maintainVisibleContentPositionConfig.size && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") ;
6892
7079
  };
@@ -7005,7 +7192,14 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7005
7192
  }, [snapToIndices]);
7006
7193
  useLayoutEffect(
7007
7194
  () => initializeStateVars(true),
7008
- [dataVersion, memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingBottomState, stylePaddingTopState]
7195
+ [
7196
+ dataVersion,
7197
+ memoizedLastItemKeys.join(","),
7198
+ numColumnsProp,
7199
+ stylePaddingBottomState,
7200
+ stylePaddingTopState,
7201
+ useAlignItemsAtEndPadding
7202
+ ]
7009
7203
  );
7010
7204
  useLayoutEffect(() => {
7011
7205
  const {
@@ -7064,7 +7258,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
7064
7258
  viewabilityConfigCallbackPairs
7065
7259
  });
7066
7260
  state.viewabilityConfigCallbackPairs = viewability;
7067
- state.enableScrollForNextCalculateItemsInView = !viewability;
7261
+ state.enableScrollForNextCalculateItemsInView = true;
7068
7262
  if (viewability) {
7069
7263
  state.scrollForNextCalculateItemsInView = void 0;
7070
7264
  }