@oxog/scrollex 1.1.0 → 1.2.0

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/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React$1 from 'react';
2
- import { V as VirtualListProps, a as VirtualListHandle, b as VirtualGridProps, c as VirtualMasonryProps, U as UseVirtualListOptions, d as UseVirtualListReturn, e as UseVirtualGridOptions, f as UseVirtualGridReturn, g as UseVirtualMasonryOptions, h as UseVirtualMasonryReturn, K as Kernel, i as KernelOptions, P as Plugin } from './scroll-controller-D5AV1E2p.cjs';
3
- export { A as AutoMeasurerAPI, j as AutoMeasurerOptions, E as EasingFunction, k as EventHandler, l as EventType, G as GridGap, m as GridRenderItemProps, n as GridRendererAPI, o as GridRendererOptions, I as InfiniteLoaderAPI, p as InfiniteLoaderOptions, q as ItemMeasuredEvent, r as ItemsChangeEvent, s as ItemsRenderedInfo, t as KernelEvent, L as ListRendererAPI, u as ListRendererOptions, v as LoadDirection, w as LoadMoreEvent, M as MasonryRenderItemProps, x as PluginConfig, y as PluginHooks, z as PluginInfo, B as PluginType, R as Range, C as RenderItemProps, D as ResizeEvent, S as ScrollAlignment, F as ScrollBehavior, H as ScrollControllerAPI, J as ScrollControllerOptions, N as ScrollDirection, O as ScrollEndEvent, Q as ScrollEvent, T as ScrollOptions, W as ScrollPosition, X as ScrollStartEvent, Y as ScrollToIndexOptions, Z as Unsubscribe, _ as Viewport, $ as VirtualItem, a0 as VisibleRangeChangeEvent, a1 as autoMeasurerPlugin, a2 as gridRendererPlugin, a3 as infiniteLoaderPlugin, a4 as listRendererPlugin, a5 as scrollControllerPlugin } from './scroll-controller-D5AV1E2p.cjs';
2
+ import { V as VirtualListProps, a as VirtualListHandle, b as VirtualGridProps, c as VirtualMasonryProps, U as UseVirtualListOptions, d as UseVirtualListReturn, e as UseVirtualGridOptions, f as UseVirtualGridReturn, g as UseVirtualMasonryOptions, h as UseVirtualMasonryReturn, K as Kernel, i as KernelOptions, P as Plugin } from './scroll-controller-U4Zov88U.cjs';
3
+ export { A as AutoMeasurerAPI, j as AutoMeasurerOptions, E as EasingFunction, k as EventHandler, l as EventType, G as GridGap, m as GridRenderItemProps, n as GridRendererAPI, o as GridRendererOptions, I as InfiniteLoaderAPI, p as InfiniteLoaderOptions, q as ItemMeasuredEvent, r as ItemsChangeEvent, s as ItemsRenderedInfo, t as KernelEvent, L as ListRendererAPI, u as ListRendererOptions, v as LoadDirection, w as LoadMoreEvent, M as MasonryRenderItemProps, x as PluginConfig, y as PluginHooks, z as PluginInfo, B as PluginType, R as Range, C as RenderItemProps, D as ResizeEvent, S as ScrollAlignment, F as ScrollBehavior, H as ScrollControllerAPI, J as ScrollControllerOptions, N as ScrollDirection, O as ScrollEndEvent, Q as ScrollEvent, T as ScrollOptions, W as ScrollPosition, X as ScrollStartEvent, Y as ScrollToIndexOptions, Z as Unsubscribe, _ as Viewport, $ as VirtualItem, a0 as VisibleRangeChangeEvent, a1 as autoMeasurerPlugin, a2 as gridRendererPlugin, a3 as infiniteLoaderPlugin, a4 as listRendererPlugin, a5 as scrollControllerPlugin } from './scroll-controller-U4Zov88U.cjs';
4
4
 
5
5
  /**
6
6
  * VirtualList component with forwardRef.
@@ -301,5 +301,4 @@ declare const easings: {
301
301
  readonly easeInOutCubic: (t: number) => number;
302
302
  };
303
303
 
304
- export { Kernel, KernelOptions, Plugin, UseVirtualGridOptions, UseVirtualGridReturn, UseVirtualListOptions, UseVirtualListReturn, UseVirtualMasonryOptions, UseVirtualMasonryReturn, VirtualGrid, VirtualGridProps, VirtualList, VirtualListHandle, VirtualListProps, VirtualMasonry, VirtualMasonryProps, createKernel, createPlugin, easings, useMeasure, useMeasureMany, useScrollex, useScrollexRequired, useVirtualGrid, useVirtualList, useVirtualMasonry };
305
- export type { UseMeasureOptions, UseMeasureReturn };
304
+ export { Kernel, KernelOptions, Plugin, type UseMeasureOptions, type UseMeasureReturn, UseVirtualGridOptions, UseVirtualGridReturn, UseVirtualListOptions, UseVirtualListReturn, UseVirtualMasonryOptions, UseVirtualMasonryReturn, VirtualGrid, VirtualGridProps, VirtualList, VirtualListHandle, VirtualListProps, VirtualMasonry, VirtualMasonryProps, createKernel, createPlugin, easings, useMeasure, useMeasureMany, useScrollex, useScrollexRequired, useVirtualGrid, useVirtualList, useVirtualMasonry };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React$1 from 'react';
2
- import { V as VirtualListProps, a as VirtualListHandle, b as VirtualGridProps, c as VirtualMasonryProps, U as UseVirtualListOptions, d as UseVirtualListReturn, e as UseVirtualGridOptions, f as UseVirtualGridReturn, g as UseVirtualMasonryOptions, h as UseVirtualMasonryReturn, K as Kernel, i as KernelOptions, P as Plugin } from './scroll-controller-D5AV1E2p.js';
3
- export { A as AutoMeasurerAPI, j as AutoMeasurerOptions, E as EasingFunction, k as EventHandler, l as EventType, G as GridGap, m as GridRenderItemProps, n as GridRendererAPI, o as GridRendererOptions, I as InfiniteLoaderAPI, p as InfiniteLoaderOptions, q as ItemMeasuredEvent, r as ItemsChangeEvent, s as ItemsRenderedInfo, t as KernelEvent, L as ListRendererAPI, u as ListRendererOptions, v as LoadDirection, w as LoadMoreEvent, M as MasonryRenderItemProps, x as PluginConfig, y as PluginHooks, z as PluginInfo, B as PluginType, R as Range, C as RenderItemProps, D as ResizeEvent, S as ScrollAlignment, F as ScrollBehavior, H as ScrollControllerAPI, J as ScrollControllerOptions, N as ScrollDirection, O as ScrollEndEvent, Q as ScrollEvent, T as ScrollOptions, W as ScrollPosition, X as ScrollStartEvent, Y as ScrollToIndexOptions, Z as Unsubscribe, _ as Viewport, $ as VirtualItem, a0 as VisibleRangeChangeEvent, a1 as autoMeasurerPlugin, a2 as gridRendererPlugin, a3 as infiniteLoaderPlugin, a4 as listRendererPlugin, a5 as scrollControllerPlugin } from './scroll-controller-D5AV1E2p.js';
2
+ import { V as VirtualListProps, a as VirtualListHandle, b as VirtualGridProps, c as VirtualMasonryProps, U as UseVirtualListOptions, d as UseVirtualListReturn, e as UseVirtualGridOptions, f as UseVirtualGridReturn, g as UseVirtualMasonryOptions, h as UseVirtualMasonryReturn, K as Kernel, i as KernelOptions, P as Plugin } from './scroll-controller-U4Zov88U.js';
3
+ export { A as AutoMeasurerAPI, j as AutoMeasurerOptions, E as EasingFunction, k as EventHandler, l as EventType, G as GridGap, m as GridRenderItemProps, n as GridRendererAPI, o as GridRendererOptions, I as InfiniteLoaderAPI, p as InfiniteLoaderOptions, q as ItemMeasuredEvent, r as ItemsChangeEvent, s as ItemsRenderedInfo, t as KernelEvent, L as ListRendererAPI, u as ListRendererOptions, v as LoadDirection, w as LoadMoreEvent, M as MasonryRenderItemProps, x as PluginConfig, y as PluginHooks, z as PluginInfo, B as PluginType, R as Range, C as RenderItemProps, D as ResizeEvent, S as ScrollAlignment, F as ScrollBehavior, H as ScrollControllerAPI, J as ScrollControllerOptions, N as ScrollDirection, O as ScrollEndEvent, Q as ScrollEvent, T as ScrollOptions, W as ScrollPosition, X as ScrollStartEvent, Y as ScrollToIndexOptions, Z as Unsubscribe, _ as Viewport, $ as VirtualItem, a0 as VisibleRangeChangeEvent, a1 as autoMeasurerPlugin, a2 as gridRendererPlugin, a3 as infiniteLoaderPlugin, a4 as listRendererPlugin, a5 as scrollControllerPlugin } from './scroll-controller-U4Zov88U.js';
4
4
 
5
5
  /**
6
6
  * VirtualList component with forwardRef.
@@ -301,5 +301,4 @@ declare const easings: {
301
301
  readonly easeInOutCubic: (t: number) => number;
302
302
  };
303
303
 
304
- export { Kernel, KernelOptions, Plugin, UseVirtualGridOptions, UseVirtualGridReturn, UseVirtualListOptions, UseVirtualListReturn, UseVirtualMasonryOptions, UseVirtualMasonryReturn, VirtualGrid, VirtualGridProps, VirtualList, VirtualListHandle, VirtualListProps, VirtualMasonry, VirtualMasonryProps, createKernel, createPlugin, easings, useMeasure, useMeasureMany, useScrollex, useScrollexRequired, useVirtualGrid, useVirtualList, useVirtualMasonry };
305
- export type { UseMeasureOptions, UseMeasureReturn };
304
+ export { Kernel, KernelOptions, Plugin, type UseMeasureOptions, type UseMeasureReturn, UseVirtualGridOptions, UseVirtualGridReturn, UseVirtualListOptions, UseVirtualListReturn, UseVirtualMasonryOptions, UseVirtualMasonryReturn, VirtualGrid, VirtualGridProps, VirtualList, VirtualListHandle, VirtualListProps, VirtualMasonry, VirtualMasonryProps, createKernel, createPlugin, easings, useMeasure, useMeasureMany, useScrollex, useScrollexRequired, useVirtualGrid, useVirtualList, useVirtualMasonry };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { listRendererPlugin, normalizeColumnCount, gridRendererPlugin, autoColumnCount, normalizeOverscan, cancelRaf, raf, clamp } from './chunk-CIB3EBBJ.js';
2
- export { autoMeasurerPlugin, gridRendererPlugin, infiniteLoaderPlugin, listRendererPlugin, scrollControllerPlugin } from './chunk-CIB3EBBJ.js';
1
+ import { listRendererPlugin, normalizeColumnCount, gridRendererPlugin, autoColumnCount, normalizeOverscan, cancelRaf, raf, clamp } from './chunk-2AWRSNQN.js';
2
+ export { autoMeasurerPlugin, gridRendererPlugin, infiniteLoaderPlugin, listRendererPlugin, scrollControllerPlugin } from './chunk-2AWRSNQN.js';
3
3
  import { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useCallback, useMemo, useState, useContext } from 'react';
4
4
  import { jsx, jsxs } from 'react/jsx-runtime';
5
5
 
@@ -270,7 +270,9 @@ var ScrollEngine = class {
270
270
  this.previousScrollPosition = { ...this.scrollPosition };
271
271
  this.reportedPosition = { ...this.scrollPosition };
272
272
  this.throttledHandleScroll = throttleRAF(this.processScroll.bind(this));
273
- this.boundHandleScroll = () => this.throttledHandleScroll?.();
273
+ this.boundHandleScroll = () => {
274
+ this.throttledHandleScroll?.();
275
+ };
274
276
  container.addEventListener("scroll", this.boundHandleScroll, { passive: true });
275
277
  }
276
278
  /**
@@ -894,9 +896,59 @@ var RangeCalculator = class {
894
896
  this.countTree = new Float64Array(1);
895
897
  this.sumTree = new Float64Array(1);
896
898
  this.treesValid = false;
899
+ // Items whose size came from sizeGetter (not from a measurement): a new getter sizes them again
900
+ this.sized = /* @__PURE__ */ new Set();
897
901
  this.itemCount = options.itemCount;
898
902
  this.overscan = options.overscan;
899
903
  this.measurementCache = new MeasurementCache(options.estimatedItemHeight);
904
+ this.sizeGetter = options.getItemSize;
905
+ }
906
+ /**
907
+ * Set (or clear) the function that gives the known size of an item. Unmeasured items take that size
908
+ * up front; measurements already taken are kept, and the items sized by the previous function are sized
909
+ * again by the new one.
910
+ *
911
+ * @param getItemSize - Size of an item, or undefined to size unmeasured items with the estimate
912
+ * @returns Whether any item size (or the total size) changed
913
+ */
914
+ setSizeGetter(getItemSize) {
915
+ if (getItemSize === this.sizeGetter) return false;
916
+ const hadGetter = this.sizeGetter !== void 0;
917
+ this.sizeGetter = getItemSize;
918
+ let changed = hadGetter !== (getItemSize !== void 0);
919
+ for (let index = 0; index < this.itemCount; index++) {
920
+ if (this.measurementCache.has(index) && !this.sized.has(index)) continue;
921
+ const size = getItemSize ? getItemSize(index) : NaN;
922
+ const previous = this.measurementCache.get(index);
923
+ if (Number.isFinite(size) && size >= 0) {
924
+ if (size !== previous) {
925
+ this.measurementCache.set(index, size);
926
+ this.sized.add(index);
927
+ changed = true;
928
+ }
929
+ } else if (previous !== void 0) {
930
+ this.measurementCache.delete(index);
931
+ this.sized.delete(index);
932
+ changed = true;
933
+ }
934
+ }
935
+ if (changed) this.treesValid = false;
936
+ return changed;
937
+ }
938
+ /**
939
+ * Size the unmeasured items with the known-size function.
940
+ */
941
+ applyKnownSizes() {
942
+ const getItemSize = this.sizeGetter;
943
+ if (!getItemSize) return;
944
+ for (let index = 0; index < this.itemCount; index++) {
945
+ if (this.measurementCache.has(index)) continue;
946
+ const size = getItemSize(index);
947
+ if (Number.isFinite(size) && size >= 0) {
948
+ this.measurementCache.set(index, size);
949
+ this.sized.add(index);
950
+ }
951
+ }
900
952
  }
901
953
  /**
902
954
  * Get the visible range of items.
@@ -975,6 +1027,7 @@ var RangeCalculator = class {
975
1027
  * @returns Item size
976
1028
  */
977
1029
  getItemSize(index) {
1030
+ if (this.sizeGetter) this.ensureTrees();
978
1031
  return this.measurementCache.getOrEstimate(index);
979
1032
  }
980
1033
  /**
@@ -993,6 +1046,7 @@ var RangeCalculator = class {
993
1046
  * @returns Previous height, or undefined if not measured
994
1047
  */
995
1048
  setItemHeight(index, height) {
1049
+ this.sized.delete(index);
996
1050
  const previousHeight = this.measurementCache.set(index, height);
997
1051
  this.track(index, previousHeight === void 0 ? 1 : 0, height - (previousHeight ?? 0));
998
1052
  return previousHeight;
@@ -1004,6 +1058,7 @@ var RangeCalculator = class {
1004
1058
  * @returns Cached height, or undefined if not measured
1005
1059
  */
1006
1060
  getCachedHeight(index) {
1061
+ if (this.sizeGetter) this.ensureTrees();
1007
1062
  return this.measurementCache.get(index);
1008
1063
  }
1009
1064
  /**
@@ -1013,15 +1068,24 @@ var RangeCalculator = class {
1013
1068
  */
1014
1069
  invalidate(index) {
1015
1070
  const previousHeight = this.measurementCache.get(index);
1071
+ this.sized.delete(index);
1016
1072
  if (this.measurementCache.delete(index)) {
1017
1073
  this.track(index, -1, -(previousHeight ?? 0));
1018
1074
  }
1075
+ if (this.sizeGetter && Number.isInteger(index) && index >= 0 && index < this.itemCount) {
1076
+ const size = this.sizeGetter(index);
1077
+ if (Number.isFinite(size) && size >= 0) {
1078
+ this.setItemHeight(index, size);
1079
+ this.sized.add(index);
1080
+ }
1081
+ }
1019
1082
  }
1020
1083
  /**
1021
1084
  * Invalidate all measurements.
1022
1085
  */
1023
1086
  invalidateAll() {
1024
1087
  this.measurementCache.clear();
1088
+ this.sized.clear();
1025
1089
  this.treesValid = false;
1026
1090
  }
1027
1091
  /**
@@ -1037,6 +1101,9 @@ var RangeCalculator = class {
1037
1101
  for (const measured of this.measurementCache.getMeasuredIndices()) {
1038
1102
  if (measured >= count) this.measurementCache.delete(measured);
1039
1103
  }
1104
+ for (const index of this.sized) {
1105
+ if (index >= count) this.sized.delete(index);
1106
+ }
1040
1107
  }
1041
1108
  this.treesValid = false;
1042
1109
  }
@@ -1062,6 +1129,7 @@ var RangeCalculator = class {
1062
1129
  * @returns Estimated height
1063
1130
  */
1064
1131
  getEstimatedHeight() {
1132
+ if (this.sizeGetter) this.ensureTrees();
1065
1133
  return this.measurementCache.getEstimatedHeight();
1066
1134
  }
1067
1135
  /**
@@ -1123,6 +1191,7 @@ var RangeCalculator = class {
1123
1191
  ensureTrees() {
1124
1192
  if (this.treesValid) return;
1125
1193
  const size = this.itemCount;
1194
+ this.applyKnownSizes();
1126
1195
  this.countTree = new Float64Array(size + 1);
1127
1196
  this.sumTree = new Float64Array(size + 1);
1128
1197
  for (const index of this.measurementCache.getMeasuredIndices()) {
@@ -1418,10 +1487,12 @@ function createKernel(options = {}) {
1418
1487
  const rangeCalculator = new RangeCalculator({
1419
1488
  itemCount: config.itemCount,
1420
1489
  estimatedItemHeight: config.estimatedItemHeight,
1421
- overscan: config.overscan
1490
+ overscan: config.overscan,
1491
+ getItemSize: config.getItemSize
1422
1492
  });
1423
1493
  const pluginRegistry = new PluginRegistry();
1424
1494
  const startPadding = () => config.paddingStart ?? 0;
1495
+ const listStart = () => (config.scrollMargin ?? 0) + startPadding();
1425
1496
  let rangeAnnounced = false;
1426
1497
  let currentRange = {
1427
1498
  startIndex: 0,
@@ -1450,7 +1521,7 @@ function createKernel(options = {}) {
1450
1521
  const horizontal = config.direction === "horizontal";
1451
1522
  const offset = horizontal ? position.scrollLeft : position.scrollTop;
1452
1523
  const viewport = viewportManager.getViewport();
1453
- const maxScroll = rangeCalculator.getTotalSize() + startPadding() - (horizontal ? viewport.width : viewport.height);
1524
+ const maxScroll = rangeCalculator.getTotalSize() + listStart() - (horizontal ? viewport.width : viewport.height);
1454
1525
  const percentage = maxScroll > 0 ? Math.min(1, Math.max(0, offset / maxScroll)) : 0;
1455
1526
  return { ...position, offset, percentage };
1456
1527
  },
@@ -1462,7 +1533,7 @@ function createKernel(options = {}) {
1462
1533
  },
1463
1534
  scrollToIndex(index, options2 = {}) {
1464
1535
  const { align = "auto", offset: additionalOffset = 0, ...scrollOptions } = options2;
1465
- const itemOffset = rangeCalculator.getItemOffset(index) + startPadding();
1536
+ const itemOffset = rangeCalculator.getItemOffset(index) + listStart();
1466
1537
  const itemSize = rangeCalculator.getItemSize(index);
1467
1538
  const viewport = viewportManager.getViewport();
1468
1539
  const horizontal = config.direction === "horizontal";
@@ -1494,7 +1565,7 @@ function createKernel(options = {}) {
1494
1565
  break;
1495
1566
  }
1496
1567
  }
1497
- const maxScroll = Math.max(0, rangeCalculator.getTotalSize() + startPadding() - viewportSize);
1568
+ const maxScroll = Math.max(0, rangeCalculator.getTotalSize() + listStart() - viewportSize);
1498
1569
  targetOffset = Math.max(0, Math.min(targetOffset + additionalOffset, maxScroll));
1499
1570
  scrollEngine.scrollTo(targetOffset, scrollOptions);
1500
1571
  },
@@ -1544,7 +1615,7 @@ function createKernel(options = {}) {
1544
1615
  return rangeCalculator.getEstimatedHeight();
1545
1616
  },
1546
1617
  getItemOffset(index) {
1547
- return rangeCalculator.getItemOffset(index) + startPadding();
1618
+ return rangeCalculator.getItemOffset(index) + listStart();
1548
1619
  },
1549
1620
  // Events
1550
1621
  emit(event) {
@@ -1575,6 +1646,14 @@ function createKernel(options = {}) {
1575
1646
  layoutChanged = newOptions.paddingStart !== startPadding();
1576
1647
  config.paddingStart = newOptions.paddingStart;
1577
1648
  }
1649
+ if (newOptions.scrollMargin !== void 0) {
1650
+ layoutChanged = layoutChanged || newOptions.scrollMargin !== (config.scrollMargin ?? 0);
1651
+ config.scrollMargin = newOptions.scrollMargin;
1652
+ }
1653
+ if ("getItemSize" in newOptions && newOptions.getItemSize !== config.getItemSize) {
1654
+ config.getItemSize = newOptions.getItemSize;
1655
+ layoutChanged = rangeCalculator.setSizeGetter(newOptions.getItemSize) || layoutChanged;
1656
+ }
1578
1657
  if (newOptions.estimatedItemHeight !== void 0) {
1579
1658
  layoutChanged = layoutChanged || newOptions.estimatedItemHeight !== config.estimatedItemHeight;
1580
1659
  config.estimatedItemHeight = newOptions.estimatedItemHeight;
@@ -1651,7 +1730,7 @@ function createKernel(options = {}) {
1651
1730
  if (!attached) return;
1652
1731
  const viewport = viewportManager.getViewport();
1653
1732
  const scrollPosition = scrollEngine.getScrollPosition();
1654
- const scrollOffset = (config.direction === "vertical" ? scrollPosition.scrollTop : scrollPosition.scrollLeft) - startPadding();
1733
+ const scrollOffset = (config.direction === "vertical" ? scrollPosition.scrollTop : scrollPosition.scrollLeft) - listStart();
1655
1734
  const viewportSize = config.direction === "vertical" ? viewport.height : viewport.width;
1656
1735
  const previousRange = { ...currentRange };
1657
1736
  currentRange = rangeCalculator.getVisibleRange(scrollOffset, viewportSize);
@@ -1740,6 +1819,7 @@ function useVirtualList(options) {
1740
1819
  overscan = 5,
1741
1820
  paddingStart = 0,
1742
1821
  paddingEnd = 0,
1822
+ scrollMargin = 0,
1743
1823
  initialOffset = 0,
1744
1824
  getItemKey = (index) => index,
1745
1825
  horizontal = false,
@@ -1754,7 +1834,10 @@ function useVirtualList(options) {
1754
1834
  overscan,
1755
1835
  direction: horizontal ? "horizontal" : "vertical",
1756
1836
  getItemKey,
1757
- paddingStart
1837
+ paddingStart,
1838
+ scrollMargin,
1839
+ // Known heights lay out every item up front, not only the rows attached with measureElement
1840
+ getItemSize: getItemHeight
1758
1841
  })
1759
1842
  );
1760
1843
  const [virtualItems, setVirtualItems] = useState([]);
@@ -1836,6 +1919,12 @@ function useVirtualList(options) {
1836
1919
  useEffect(() => {
1837
1920
  kernel.configure({ paddingStart });
1838
1921
  }, [paddingStart, kernel]);
1922
+ useEffect(() => {
1923
+ kernel.configure({ scrollMargin });
1924
+ }, [scrollMargin, kernel]);
1925
+ useEffect(() => {
1926
+ kernel.configure({ getItemSize: getItemHeight });
1927
+ }, [getItemHeight, kernel]);
1839
1928
  useEffect(() => {
1840
1929
  kernel.configure({ direction: horizontal ? "horizontal" : "vertical" });
1841
1930
  }, [horizontal, kernel]);
@@ -1879,7 +1968,7 @@ function useVirtualList(options) {
1879
1968
  observer?.observe(element);
1880
1969
  if (getItemHeight) {
1881
1970
  const size = getItemHeight(index);
1882
- kernel.measureItem(index, size);
1971
+ if (kernel.getCachedHeight(index) !== size) kernel.measureItem(index, size);
1883
1972
  } else {
1884
1973
  const rect = element.getBoundingClientRect();
1885
1974
  const size = horizontal ? rect.width : rect.height;