virtual-scroller 1.14.0 → 1.15.1
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/CHANGELOG.md +29 -0
- package/README.md +403 -254
- package/bundle/index-dom-bypass.html +197 -0
- package/bundle/index-dom-grid.html +203 -0
- package/bundle/index-dom-scrollableContainer.html +214 -0
- package/bundle/index-dom-tbody-scrollableContainer.html +81 -0
- package/bundle/index-dom-tbody.html +65 -0
- package/bundle/index-dom.html +114 -84
- package/bundle/index-react-bypass.html +194 -0
- package/bundle/{index-bypass.html → index-react-grid.html} +122 -120
- package/bundle/index-react-hook.html +209 -0
- package/bundle/index-react-scrollableContainer.html +207 -0
- package/bundle/index-react-strictMode.html +193 -0
- package/bundle/index-react-tbody-scrollableContainer.html +94 -0
- package/bundle/index-react-tbody.html +78 -0
- package/bundle/{messages.js → items.js} +1 -1
- package/bundle/lib/babel.min.js +25 -0
- package/bundle/lib/prop-types.min.js +1 -0
- package/bundle/lib/react-dom.development.js +29924 -0
- package/bundle/lib/react-dom.production.min.js +267 -0
- package/bundle/lib/react.development.js +3343 -0
- package/bundle/lib/react.production.min.js +31 -0
- package/bundle/style.base.css +33 -0
- package/{website/style.css → bundle/style.list.css} +10 -43
- package/bundle/style.list.grid.css +23 -0
- package/bundle/virtual-scroller-dom.js +1 -1
- package/bundle/virtual-scroller-dom.js.map +1 -1
- package/bundle/virtual-scroller-react.js +1 -1
- package/bundle/virtual-scroller-react.js.map +1 -1
- package/bundle/virtual-scroller.js +1 -1
- package/bundle/virtual-scroller.js.map +1 -1
- package/commonjs/BeforeResize.js +1 -2
- package/commonjs/BeforeResize.js.map +1 -1
- package/commonjs/DOM/VirtualScroller.js +7 -13
- package/commonjs/DOM/VirtualScroller.js.map +1 -1
- package/commonjs/DOM/tbody.js +6 -6
- package/commonjs/DOM/tbody.js.map +1 -1
- package/commonjs/ItemHeights.js +10 -13
- package/commonjs/ItemHeights.js.map +1 -1
- package/commonjs/Layout.defaults.js +21 -0
- package/commonjs/Layout.defaults.js.map +1 -0
- package/commonjs/Layout.js +75 -64
- package/commonjs/Layout.js.map +1 -1
- package/commonjs/Layout.test.js +8 -4
- package/commonjs/Layout.test.js.map +1 -1
- package/commonjs/VirtualScroller.constructor.js +38 -4
- package/commonjs/VirtualScroller.constructor.js.map +1 -1
- package/commonjs/VirtualScroller.items.js +50 -4
- package/commonjs/VirtualScroller.items.js.map +1 -1
- package/commonjs/VirtualScroller.js +23 -14
- package/commonjs/VirtualScroller.js.map +1 -1
- package/commonjs/VirtualScroller.layout.js +40 -29
- package/commonjs/VirtualScroller.layout.js.map +1 -1
- package/commonjs/VirtualScroller.onContainerResize.js +1 -2
- package/commonjs/VirtualScroller.onContainerResize.js.map +1 -1
- package/commonjs/VirtualScroller.state.js +10 -9
- package/commonjs/VirtualScroller.state.js.map +1 -1
- package/commonjs/VirtualScroller.verticalSpacing.js +39 -6
- package/commonjs/VirtualScroller.verticalSpacing.js.map +1 -1
- package/commonjs/react/VirtualScroller.js +124 -131
- package/commonjs/react/VirtualScroller.js.map +1 -1
- package/commonjs/react/useClassName.js +2 -2
- package/commonjs/react/useClassName.js.map +1 -1
- package/commonjs/react/useCreateVirtualScroller.js +64 -0
- package/commonjs/react/useCreateVirtualScroller.js.map +1 -0
- package/commonjs/react/useInstanceMethods.js +4 -4
- package/commonjs/react/useInstanceMethods.js.map +1 -1
- package/commonjs/react/useItemKeys.js +28 -5
- package/commonjs/react/useItemKeys.js.map +1 -1
- package/commonjs/react/useMergeRefs.js +52 -0
- package/commonjs/react/useMergeRefs.js.map +1 -0
- package/commonjs/react/useOnItemHeightDidChange.js +28 -12
- package/commonjs/react/useOnItemHeightDidChange.js.map +1 -1
- package/commonjs/react/useSetItemState.js +31 -12
- package/commonjs/react/useSetItemState.js.map +1 -1
- package/commonjs/react/{useVirtualScrollerStartStop.js → useStartStopVirtualScroller.js} +1 -1
- package/commonjs/react/{useVirtualScrollerStartStop.js.map → useStartStopVirtualScroller.js.map} +1 -1
- package/commonjs/react/useState.js +9 -9
- package/commonjs/react/useState.js.map +1 -1
- package/commonjs/react/{useStateNoStaleBug.js → useStateWithRepeatableRead.js} +3 -3
- package/commonjs/react/useStateWithRepeatableRead.js.map +1 -0
- package/commonjs/react/useStyle.js +28 -4
- package/commonjs/react/useStyle.js.map +1 -1
- package/commonjs/react/useValidateTableBodyItemsContainer.js +24 -0
- package/commonjs/react/useValidateTableBodyItemsContainer.js.map +1 -0
- package/commonjs/react/useVirtualScroller.js +142 -42
- package/commonjs/react/useVirtualScroller.js.map +1 -1
- package/commonjs/test/ItemsContainer.js +10 -10
- package/commonjs/test/ItemsContainer.js.map +1 -1
- package/commonjs/test/VirtualScroller.js +25 -10
- package/commonjs/test/VirtualScroller.js.map +1 -1
- package/dom/index.d.ts +6 -5
- package/index.d.ts +19 -8
- package/modules/BeforeResize.js +1 -2
- package/modules/BeforeResize.js.map +1 -1
- package/modules/DOM/VirtualScroller.js +7 -13
- package/modules/DOM/VirtualScroller.js.map +1 -1
- package/modules/DOM/tbody.js +4 -4
- package/modules/DOM/tbody.js.map +1 -1
- package/modules/ItemHeights.js +11 -14
- package/modules/ItemHeights.js.map +1 -1
- package/modules/Layout.defaults.js +11 -0
- package/modules/Layout.defaults.js.map +1 -0
- package/modules/Layout.js +74 -64
- package/modules/Layout.js.map +1 -1
- package/modules/Layout.test.js +8 -4
- package/modules/Layout.test.js.map +1 -1
- package/modules/VirtualScroller.constructor.js +37 -4
- package/modules/VirtualScroller.constructor.js.map +1 -1
- package/modules/VirtualScroller.items.js +51 -5
- package/modules/VirtualScroller.items.js.map +1 -1
- package/modules/VirtualScroller.js +23 -14
- package/modules/VirtualScroller.js.map +1 -1
- package/modules/VirtualScroller.layout.js +40 -29
- package/modules/VirtualScroller.layout.js.map +1 -1
- package/modules/VirtualScroller.onContainerResize.js +1 -2
- package/modules/VirtualScroller.onContainerResize.js.map +1 -1
- package/modules/VirtualScroller.state.js +10 -9
- package/modules/VirtualScroller.state.js.map +1 -1
- package/modules/VirtualScroller.verticalSpacing.js +38 -6
- package/modules/VirtualScroller.verticalSpacing.js.map +1 -1
- package/modules/react/VirtualScroller.js +122 -124
- package/modules/react/VirtualScroller.js.map +1 -1
- package/modules/react/useClassName.js +3 -3
- package/modules/react/useClassName.js.map +1 -1
- package/modules/react/useCreateVirtualScroller.js +53 -0
- package/modules/react/useCreateVirtualScroller.js.map +1 -0
- package/modules/react/useInstanceMethods.js +4 -4
- package/modules/react/useInstanceMethods.js.map +1 -1
- package/modules/react/useItemKeys.js +28 -5
- package/modules/react/useItemKeys.js.map +1 -1
- package/modules/react/useMergeRefs.js +44 -0
- package/modules/react/useMergeRefs.js.map +1 -0
- package/modules/react/useOnItemHeightDidChange.js +28 -12
- package/modules/react/useOnItemHeightDidChange.js.map +1 -1
- package/modules/react/useSetItemState.js +31 -12
- package/modules/react/useSetItemState.js.map +1 -1
- package/modules/react/{useVirtualScrollerStartStop.js → useStartStopVirtualScroller.js} +1 -1
- package/modules/react/{useVirtualScrollerStartStop.js.map → useStartStopVirtualScroller.js.map} +1 -1
- package/modules/react/useState.js +9 -9
- package/modules/react/useState.js.map +1 -1
- package/modules/react/{useStateNoStaleBug.js → useStateWithRepeatableRead.js} +2 -2
- package/modules/react/useStateWithRepeatableRead.js.map +1 -0
- package/modules/react/useStyle.js +27 -4
- package/modules/react/useStyle.js.map +1 -1
- package/modules/react/useValidateTableBodyItemsContainer.js +16 -0
- package/modules/react/useValidateTableBodyItemsContainer.js.map +1 -0
- package/modules/react/useVirtualScroller.js +136 -42
- package/modules/react/useVirtualScroller.js.map +1 -1
- package/modules/test/ItemsContainer.js +10 -10
- package/modules/test/ItemsContainer.js.map +1 -1
- package/modules/test/VirtualScroller.js +25 -10
- package/modules/test/VirtualScroller.js.map +1 -1
- package/package.json +4 -1
- package/react/as.d.ts +42 -0
- package/react/index.cjs +2 -1
- package/react/index.d.ts +248 -63
- package/react/index.js +1 -0
- package/rollup.config.mjs +15 -1
- package/source/BeforeResize.js +1 -2
- package/source/DOM/VirtualScroller.js +7 -13
- package/source/DOM/tbody.js +5 -5
- package/source/ItemHeights.js +11 -12
- package/source/Layout.defaults.js +8 -0
- package/source/Layout.js +66 -53
- package/source/Layout.test.js +7 -2
- package/source/VirtualScroller.constructor.js +27 -4
- package/source/VirtualScroller.items.js +47 -2
- package/source/VirtualScroller.js +23 -14
- package/source/VirtualScroller.layout.js +41 -28
- package/source/VirtualScroller.onContainerResize.js +1 -2
- package/source/VirtualScroller.state.js +10 -11
- package/source/VirtualScroller.verticalSpacing.js +32 -6
- package/source/react/VirtualScroller.js +135 -133
- package/source/react/useClassName.js +3 -3
- package/source/react/useCreateVirtualScroller.js +65 -0
- package/source/react/useInstanceMethods.js +12 -4
- package/source/react/useItemKeys.js +22 -4
- package/source/react/useMergeRefs.js +45 -0
- package/source/react/useOnItemHeightDidChange.js +29 -10
- package/source/react/useSetItemState.js +32 -10
- package/source/react/useState.js +6 -6
- package/source/react/{useStateNoStaleBug.js → useStateWithRepeatableRead.js} +1 -1
- package/source/react/useStyle.js +18 -2
- package/source/react/useValidateTableBodyItemsContainer.js +16 -0
- package/source/react/useVirtualScroller.js +155 -47
- package/source/test/ItemsContainer.js +10 -10
- package/source/test/VirtualScroller.js +16 -10
- package/website/index-dom-bypass.html +197 -0
- package/website/index-dom-grid.html +203 -0
- package/website/index-dom-scrollableContainer.html +214 -0
- package/website/index-dom-tbody-scrollableContainer.html +81 -0
- package/website/index-dom-tbody.html +65 -0
- package/website/index-dom.html +116 -84
- package/website/index-react-bypass.html +194 -0
- package/website/index-react-grid.html +197 -0
- package/website/index-react-hook.html +209 -0
- package/website/index-react-scrollableContainer.html +207 -0
- package/website/index-react-strictMode.html +193 -0
- package/website/index-react-tbody-scrollableContainer.html +94 -0
- package/website/index-react-tbody.html +78 -0
- package/website/index-react.html +193 -0
- package/website/index.html +120 -111
- package/website/{messages.js → items.js} +1 -1
- package/website/lib/babel.min.js +25 -0
- package/website/lib/prop-types.min.js +1 -0
- package/website/lib/react-dom.development.js +29924 -0
- package/website/lib/react-dom.production.min.js +267 -0
- package/website/lib/react.development.js +3343 -0
- package/website/lib/react.production.min.js +31 -0
- package/website/style.base.css +33 -0
- package/website/style.list.css +92 -0
- package/website/style.list.grid.css +23 -0
- package/bundle/index-grid.html +0 -216
- package/bundle/index-scrollableContainer.html +0 -208
- package/bundle/index-tbody-scrollableContainer.html +0 -70
- package/bundle/index-tbody.html +0 -57
- package/bundle/on-scroll-to-dom.js +0 -2
- package/bundle/on-scroll-to-dom.js.map +0 -1
- package/bundle/on-scroll-to-react.js +0 -2
- package/bundle/on-scroll-to-react.js.map +0 -1
- package/bundle/on-scroll-to.js +0 -2
- package/bundle/on-scroll-to.js.map +0 -1
- package/commonjs/react/useStateNoStaleBug.js.map +0 -1
- package/modules/react/useStateNoStaleBug.js.map +0 -1
- package/website/index-bypass.html +0 -185
- package/website/index-grid.html +0 -216
- package/website/index-scrollableContainer.html +0 -208
- package/website/index-tbody-scrollableContainer.html +0 -70
- package/website/index-tbody.html +0 -57
- package/website/lib/on-scroll-to-dom.js +0 -2
- package/website/lib/on-scroll-to-dom.js.map +0 -1
- package/website/lib/on-scroll-to-react.js +0 -2
- package/website/lib/on-scroll-to-react.js.map +0 -1
- /package/source/react/{useVirtualScrollerStartStop.js → useStartStopVirtualScroller.js} +0 -0
|
@@ -11,6 +11,8 @@ var _Engine = _interopRequireDefault(require("./DOM/Engine.js"));
|
|
|
11
11
|
|
|
12
12
|
var _Layout = _interopRequireWildcard(require("./Layout.js"));
|
|
13
13
|
|
|
14
|
+
var _LayoutDefaults = require("./Layout.defaults.js");
|
|
15
|
+
|
|
14
16
|
var _ScrollableContainerResizeHandler = _interopRequireDefault(require("./ScrollableContainerResizeHandler.js"));
|
|
15
17
|
|
|
16
18
|
var _BeforeResize = _interopRequireDefault(require("./BeforeResize.js"));
|
|
@@ -68,6 +70,7 @@ function VirtualScrollerConstructor(getItemsContainerElement, items) {
|
|
|
68
70
|
getItemId = options.getItemId,
|
|
69
71
|
estimatedItemHeight = options.estimatedItemHeight,
|
|
70
72
|
getEstimatedVisibleItemRowsCount = options.getEstimatedVisibleItemRowsCount,
|
|
73
|
+
getEstimatedInterItemVerticalSpacing = options.getEstimatedInterItemVerticalSpacing,
|
|
71
74
|
onItemInitialRender = options.onItemInitialRender,
|
|
72
75
|
onItemFirstRender = options.onItemFirstRender,
|
|
73
76
|
_useTimeoutInRenderLoop = options._useTimeoutInRenderLoop,
|
|
@@ -197,7 +200,9 @@ function VirtualScrollerConstructor(getItemsContainerElement, items) {
|
|
|
197
200
|
items: items
|
|
198
201
|
});
|
|
199
202
|
|
|
200
|
-
_VirtualScrollerVerticalSpacing["default"].call(this
|
|
203
|
+
_VirtualScrollerVerticalSpacing["default"].call(this, {
|
|
204
|
+
getEstimatedInterItemVerticalSpacing: getEstimatedInterItemVerticalSpacing
|
|
205
|
+
});
|
|
201
206
|
|
|
202
207
|
_VirtualScrollerColumns["default"].call(this, {
|
|
203
208
|
getColumnsCount: getColumnsCount
|
|
@@ -269,14 +274,43 @@ function createHelpers(_ref) {
|
|
|
269
274
|
return _this2.getState().itemHeights[i] = height;
|
|
270
275
|
}
|
|
271
276
|
});
|
|
277
|
+
|
|
278
|
+
this.getAverageItemHeight = function () {
|
|
279
|
+
var averageItemHeight = _this2.itemHeights.getAverageItemHeight();
|
|
280
|
+
|
|
281
|
+
if (typeof averageItemHeight === 'number') {
|
|
282
|
+
return averageItemHeight;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return _this2.getEstimatedItemHeight();
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
this.getEstimatedItemHeight = function () {
|
|
289
|
+
if (getEstimatedItemHeight) {
|
|
290
|
+
var estimatedItemHeight = getEstimatedItemHeight();
|
|
291
|
+
|
|
292
|
+
if (typeof estimatedItemHeight === 'number') {
|
|
293
|
+
return estimatedItemHeight;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
throw new Error('[virtual-scroller] `getEstimatedItemHeight()` must return a number');
|
|
297
|
+
} // `DEFAULT_ITEM_HEIGHT` will be used in server-side render
|
|
298
|
+
// unless `getEstimatedItemHeight()` parameter is specified.
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
return _LayoutDefaults.DEFAULT_ITEM_HEIGHT;
|
|
302
|
+
};
|
|
303
|
+
|
|
272
304
|
this.layout = new _Layout["default"]({
|
|
273
305
|
isInBypassMode: this.isInBypassMode,
|
|
274
|
-
|
|
275
|
-
getInitialEstimatedVisibleItemRowsCount: getEstimatedVisibleItemRowsCount,
|
|
306
|
+
getEstimatedVisibleItemRowsCountForInitialRender: getEstimatedVisibleItemRowsCount,
|
|
276
307
|
measureItemsBatchSize: measureItemsBatchSize,
|
|
277
308
|
getPrerenderMargin: function getPrerenderMargin() {
|
|
278
309
|
return _this2.getPrerenderMargin();
|
|
279
310
|
},
|
|
311
|
+
getPrerenderMarginRatio: function getPrerenderMarginRatio() {
|
|
312
|
+
return _this2.getPrerenderMarginRatio();
|
|
313
|
+
},
|
|
280
314
|
getVerticalSpacing: function getVerticalSpacing() {
|
|
281
315
|
return _this2.getVerticalSpacing();
|
|
282
316
|
},
|
|
@@ -299,7 +333,7 @@ function createHelpers(_ref) {
|
|
|
299
333
|
return _this2.getState().beforeResize ? _this2.getState().beforeResize.itemHeights.length : 0;
|
|
300
334
|
},
|
|
301
335
|
getAverageItemHeight: function getAverageItemHeight() {
|
|
302
|
-
return _this2.
|
|
336
|
+
return _this2.getAverageItemHeight();
|
|
303
337
|
},
|
|
304
338
|
// `this.scrollableContainer` is gonna be `undefined` during server-side rendering.
|
|
305
339
|
// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/30
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualScroller.constructor.js","names":["VirtualScrollerConstructor","getItemsContainerElement","items","options","bypass","render","state","getInitialItemState","onStateChange","initialScrollPosition","onScrollPositionChange","scrollableContainer","measureItemsBatchSize","getColumnsCount","getItemId","estimatedItemHeight","getEstimatedVisibleItemRowsCount","onItemInitialRender","onItemFirstRender","_useTimeoutInRenderLoop","_waitForScrollingToStop","engine","getEstimatedItemHeight","getScrollableContainer","log","DOMEngine","getState","setState","Error","_bypass","isItemEqual","a","b","item","warn","i","indexOf","length","createStateHelpers","call","createVerticalSpacingHelpers","createColumnsHelpers","createLayoutHelpers","createOnRenderHelpers","createScrollableContainerResizeHelpers","createItemsHelpers","createHelpers","waitForScrollingToStop","itemHeights","readItemHeightsFromState","beforeResize","initializeFromState","itemsContainer","createItemsContainer","clear","isItemsContainerElementTableBody","tagName","isInBypassMode","createScrollableContainer","ItemHeights","container","getItemHeight","setItemHeight","height","layout","Layout","getInitialEstimatedItemHeight","getInitialEstimatedVisibleItemRowsCount","getPrerenderMargin","getVerticalSpacing","getVerticalSpacingBeforeResize","getColumnsCountBeforeResize","columnsCount","getItemHeightBeforeResize","getBeforeResizeItemsCount","getAverageItemHeight","getAverage","getMaxVisibleAreaHeight","getHeight","getPreviouslyCalculatedLayout","previouslyCalculatedLayout","scrollableContainerResizeHandler","ScrollableContainerResizeHandler","getWidth","listenForResize","listener","onResize","onResizeStart","_isResizing","onResizeStop","undefined","onNoChange","onUpdateShownItemIndexes","reason","LAYOUT_REASON","VIEWPORT_SIZE_UNCHANGED","onHeightChange","VIEWPORT_HEIGHT_CHANGED","onWidthChange","prevWidth","newWidth","onContainerResize","scroll","Scroll","onScroll","delayed","STOPPED_SCROLLING","SCROLL","isImmediateLayoutScheduled","Boolean","layoutTimer","hasNonRenderedItemsAtTheTop","firstShownItemIndex","hasNonRenderedItemsAtTheBottom","lastShownItemIndex","getItemsCount","getLatestLayoutVisibleArea","latestLayoutVisibleArea","getListTopOffset","getListTopOffsetInsideScrollableContainer","listHeightMeasurement","ListHeightMeasurement","watchListTopOffset","listTopOffsetWatcher","onListTopOffsetChange","TOP_OFFSET_CHANGED","BeforeResize"],"sources":["../source/VirtualScroller.constructor.js"],"sourcesContent":["import DOMEngine from './DOM/Engine.js'\r\n\r\nimport Layout, { LAYOUT_REASON } from './Layout.js'\r\nimport ScrollableContainerResizeHandler from './ScrollableContainerResizeHandler.js'\r\nimport BeforeResize from './BeforeResize.js'\r\nimport Scroll from './Scroll.js'\r\nimport ListHeightMeasurement from './ListHeightMeasurement.js'\r\nimport ItemHeights from './ItemHeights.js'\r\n\r\nimport log, { warn } from './utility/debug.js'\r\n\r\nimport createStateHelpers from './VirtualScroller.state.js'\r\nimport createVerticalSpacingHelpers from './VirtualScroller.verticalSpacing.js'\r\nimport createColumnsHelpers from './VirtualScroller.columns.js'\r\nimport createLayoutHelpers from './VirtualScroller.layout.js'\r\nimport createOnRenderHelpers from './VirtualScroller.onRender.js'\r\nimport createScrollableContainerResizeHelpers from './VirtualScroller.onContainerResize.js'\r\nimport createItemsHelpers from './VirtualScroller.items.js'\r\n\r\n/**\r\n * @param {function} getItemsContainerElement — Returns the container DOM `Element`.\r\n * @param {any[]} items — The list of items.\r\n * @param {Object} [options] — See README.md.\r\n * @return {VirtualScroller}\r\n */\r\nexport default function VirtualScrollerConstructor(\r\n\tgetItemsContainerElement,\r\n\titems,\r\n\toptions = {}\r\n) {\r\n\tconst {\r\n\t\tbypass,\r\n\t\trender,\r\n\t\tstate,\r\n\t\tgetInitialItemState = () => {},\r\n\t\tonStateChange,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\t// `scrollableContainer` option is deprecated.\r\n\t\t// Use `getScrollableContainer()` option instead.\r\n\t\tscrollableContainer,\r\n\t\tmeasureItemsBatchSize = 50,\r\n\t\tgetColumnsCount,\r\n\t\tgetItemId,\r\n\t\t// `estimatedItemHeight` is deprecated, use `getEstimatedItemHeight()` instead.\r\n\t\testimatedItemHeight,\r\n\t\tgetEstimatedVisibleItemRowsCount,\r\n\t\tonItemInitialRender,\r\n\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\tonItemFirstRender,\r\n\t\t_useTimeoutInRenderLoop,\r\n\t\t_waitForScrollingToStop,\r\n\t\tengine\r\n\t} = options\r\n\r\n\tlet {\r\n\t\tgetEstimatedItemHeight,\r\n\t\tgetScrollableContainer\r\n\t} = options\r\n\r\n\tlog('~ Initialize ~')\r\n\r\n\t// Could support non-DOM rendering engines.\r\n\t// For example, React Native, `<canvas/>`, etc.\r\n\tthis.engine = engine || DOMEngine\r\n\r\n\tif (!getEstimatedItemHeight && typeof estimatedItemHeight === 'number') {\r\n\t\tgetEstimatedItemHeight = () => estimatedItemHeight\r\n\t}\r\n\r\n\t// `scrollableContainer` option is deprecated.\r\n\t// Use `getScrollableContainer()` option instead.\r\n\tif (!getScrollableContainer && scrollableContainer) {\r\n\t\tgetScrollableContainer = () => scrollableContainer\r\n\t}\r\n\r\n\t// Sometimes, when `new VirtualScroller()` instance is created,\r\n\t// `getItemsContainerElement()` might not be ready to return the \"container\" DOM Element yet\r\n\t// (for example, because it's not rendered yet). That's the reason why it's a getter function.\r\n\t// For example, in React `<VirtualScroller/>` component, a `VirtualScroller`\r\n\t// instance is created in the React component's `constructor()`, and at that time\r\n\t// the container Element is not yet available. The container Element is available\r\n\t// in `componentDidMount()`, but `componentDidMount()` is not executed on server,\r\n\t// which would mean that React `<VirtualScroller/>` wouldn't render at all\r\n\t// on server side, while with the `getItemsContainerElement()` approach, on server side,\r\n\t// it still \"renders\" a list with a predefined amount of items in it by default.\r\n\t// (`initiallyRenderedItemsCount`, or `1`).\r\n\tthis.getItemsContainerElement = getItemsContainerElement\r\n\r\n\t// if (prerenderMargin === undefined) {\r\n\t// \t// Renders items which are outside of the screen by this \"prerender margin\".\r\n\t// \t// Is the screen height by default: seems to be the optimal value\r\n\t// \t// for \"Page Up\" / \"Page Down\" navigation and optimized mouse wheel scrolling.\r\n\t// \tprerenderMargin = this.scrollableContainer ? this.scrollableContainer.getHeight() : 0\r\n\t// }\r\n\r\n\tif (options.getState || options.setState) {\r\n\t\tthrow new Error('[virtual-scroller] `getState`/`setState` options usage has changed in the new version. See the readme for more details.')\r\n\t}\r\n\r\n\tif (bypass) {\r\n\t\tlog('~ \"bypass\" mode ~')\r\n\t}\r\n\r\n\t// In `bypass` mode, `VirtualScroller` doesn't wait\r\n\t// for the user to scroll down to render all items:\r\n\t// instead, it renders all items right away, as if\r\n\t// the list is rendered without using `VirtualScroller`.\r\n\t// It was added just to measure how much is the\r\n\t// performance difference between using a `VirtualScroller`\r\n\t// and not using a `VirtualScroller`.\r\n\t// It turned out that unmounting large React component trees\r\n\t// is a very long process, so `VirtualScroller` does seem to\r\n\t// make sense when used in a React application.\r\n\tthis._bypass = bypass\r\n\t// this.bypassBatchSize = bypassBatchSize || 10\r\n\r\n\t// Using `setTimeout()` in render loop is a workaround\r\n\t// for avoiding a React error message:\r\n\t// \"Maximum update depth exceeded.\r\n\t// This can happen when a component repeatedly calls\r\n\t// `.setState()` inside `componentWillUpdate()` or `componentDidUpdate()`.\r\n\t// React limits the number of nested updates to prevent infinite loops.\"\r\n\tthis._useTimeoutInRenderLoop = _useTimeoutInRenderLoop\r\n\r\n\tif (getItemId) {\r\n\t\tthis.isItemEqual = (a, b) => getItemId(a) === getItemId(b)\r\n\t} else {\r\n\t\tthis.isItemEqual = (a, b) => a === b\r\n\t}\r\n\r\n\tif (onItemInitialRender) {\r\n\t\tthis.onItemInitialRender = onItemInitialRender\r\n\t}\r\n\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\telse if (onItemFirstRender) {\r\n\t\tthis.onItemInitialRender = (item) => {\r\n\t\t\twarn('`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.')\r\n\t\t\tconst { items } = this.getState()\r\n\t\t\tconst i = items.indexOf(item)\r\n\t\t\t// The `item` could also be non-found due to the inconsistency bug:\r\n\t\t\t// The reason is that `i` can be non-consistent with the `items`\r\n\t\t\t// passed to `<VirtualScroller/>` in React due to `updateState()` not being\r\n\t\t\t// instanteneous: when new `items` are passed to `<VirtualScroller/>`,\r\n\t\t\t// `VirtualScroller.updateState({ items })` is called, and if `onItemFirstRender(i)`\r\n\t\t\t// is called after the aforementioned `updateState()` is called but before it finishes,\r\n\t\t\t// `i` would point to an index in \"previous\" `items` while the application\r\n\t\t\t// would assume that `i` points to an index in the \"new\" `items`,\r\n\t\t\t// resulting in an incorrect item being assumed by the application\r\n\t\t\t// or even in an \"array index out of bounds\" error.\r\n\t\t\tif (i >= 0) {\r\n\t\t\t\tonItemFirstRender(i)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// If initial `state` is passed then use `items` from `state`\r\n\t// instead of the `items` argument.\r\n\tif (state) {\r\n\t\titems = state.items\r\n\t}\r\n\r\n\tlog('Items count', items.length)\r\n\tif (getEstimatedItemHeight) {\r\n\t\tlog('Estimated item height', getEstimatedItemHeight())\r\n\t}\r\n\r\n\tcreateStateHelpers.call(this, { state, getInitialItemState, onStateChange, render, items })\r\n\r\n\tcreateVerticalSpacingHelpers.call(this)\r\n\tcreateColumnsHelpers.call(this, { getColumnsCount })\r\n\r\n\tcreateLayoutHelpers.call(this)\r\n\tcreateOnRenderHelpers.call(this)\r\n\tcreateScrollableContainerResizeHelpers.call(this)\r\n\tcreateItemsHelpers.call(this)\r\n\r\n\tcreateHelpers.call(this, {\r\n\t\tgetScrollableContainer,\r\n\t\tgetEstimatedItemHeight,\r\n\t\tgetEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\twaitForScrollingToStop: _waitForScrollingToStop\r\n\t})\r\n\r\n\tif (state) {\r\n\t\t// Initialize `ItemHeights` from previously measured `state.itemHeights`.\r\n\t\tthis.itemHeights.readItemHeightsFromState(state)\r\n\r\n\t\t// Initialize some `BeforeResize` internal flags from a previously saved state.\r\n\t\tthis.beforeResize.initializeFromState(state)\r\n\t}\r\n}\r\n\r\nfunction createHelpers({\r\n\tgetScrollableContainer,\r\n\tgetEstimatedItemHeight,\r\n\tgetEstimatedVisibleItemRowsCount,\r\n\tmeasureItemsBatchSize,\r\n\tinitialScrollPosition,\r\n\tonScrollPositionChange,\r\n\twaitForScrollingToStop\r\n}) {\r\n\tthis.itemsContainer = this.engine.createItemsContainer(\r\n\t\tthis.getItemsContainerElement\r\n\t)\r\n\r\n\t// If the items \"container\" element is mounted at this stage,\r\n\t// remove any accidental text nodes from it (like whitespace).\r\n\t//\r\n\t// Also, this guards against cases when someone accidentally tries\r\n\t// using `VirtualScroller` on a non-empty element.\r\n\t//\r\n\tif (this.getItemsContainerElement()) {\r\n\t\tthis.itemsContainer.clear()\r\n\t}\r\n\r\n\tthis.isItemsContainerElementTableBody = () => {\r\n\t\treturn this.engine === DOMEngine &&\r\n\t\t\tthis.getItemsContainerElement().tagName === 'TBODY'\r\n\t}\r\n\r\n\tthis.isInBypassMode = () => this._bypass\r\n\r\n\tthis.scrollableContainer = this.engine.createScrollableContainer(\r\n\t\tgetScrollableContainer,\r\n\t\tthis.getItemsContainerElement\r\n\t)\r\n\r\n\t// Create `ItemHeights` instance.\r\n\tthis.itemHeights = new ItemHeights({\r\n\t\tcontainer: this.itemsContainer,\r\n\t\tgetItemHeight: (i) => this.getState().itemHeights[i],\r\n\t\tsetItemHeight: (i, height) => this.getState().itemHeights[i] = height\r\n\t})\r\n\r\n\tthis.layout = new Layout({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tgetInitialEstimatedItemHeight: getEstimatedItemHeight,\r\n\t\tgetInitialEstimatedVisibleItemRowsCount: getEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tgetPrerenderMargin: () => this.getPrerenderMargin(),\r\n\t\tgetVerticalSpacing: () => this.getVerticalSpacing(),\r\n\t\tgetVerticalSpacingBeforeResize: () => this.getVerticalSpacingBeforeResize(),\r\n\t\tgetColumnsCount: () => this.getColumnsCount(),\r\n\t\tgetColumnsCountBeforeResize: () => this.getState().beforeResize && this.getState().beforeResize.columnsCount,\r\n\t\tgetItemHeight: (i) => this.getState().itemHeights[i],\r\n\t\tgetItemHeightBeforeResize: (i) => this.getState().beforeResize && this.getState().beforeResize.itemHeights[i],\r\n\t\tgetBeforeResizeItemsCount: () => this.getState().beforeResize ? this.getState().beforeResize.itemHeights.length : 0,\r\n\t\tgetAverageItemHeight: () => this.itemHeights.getAverage(),\r\n\t\t// `this.scrollableContainer` is gonna be `undefined` during server-side rendering.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/30\r\n\t\tgetMaxVisibleAreaHeight: () => this.scrollableContainer && this.scrollableContainer.getHeight(),\r\n\t\t//\r\n\t\t// The \"previously calculated layout\" feature is not currently used.\r\n\t\t//\r\n\t\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t\t// rather than from scratch, which would be an optimization.\r\n\t\t//\r\n\t\tgetPreviouslyCalculatedLayout: () => this.previouslyCalculatedLayout\r\n\t})\r\n\r\n\tthis.scrollableContainerResizeHandler = new ScrollableContainerResizeHandler({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tgetWidth: () => this.scrollableContainer.getWidth(),\r\n\t\tgetHeight: () => this.scrollableContainer.getHeight(),\r\n\t\tlistenForResize: (listener) => this.scrollableContainer.onResize(listener),\r\n\t\tonResizeStart: () => {\r\n\t\t\tlog('~ Scrollable container resize started ~')\r\n\t\t\tthis._isResizing = true\r\n\t\t},\r\n\t\tonResizeStop: () => {\r\n\t\t\tlog('~ Scrollable container resize finished ~')\r\n\t\t\tthis._isResizing = undefined\r\n\t\t},\r\n\t\tonNoChange: () => {\r\n\t\t\t// There might have been some missed `this.onUpdateShownItemIndexes()` calls\r\n\t\t\t// due to setting `this._isResizing` flag to `true` during the resize.\r\n\t\t\t// So, update shown item indexes just in case.\r\n\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\treason: LAYOUT_REASON.VIEWPORT_SIZE_UNCHANGED\r\n\t\t\t})\r\n\t\t},\r\n\t\tonHeightChange: () => this.onUpdateShownItemIndexes({\r\n\t\t\treason: LAYOUT_REASON.VIEWPORT_HEIGHT_CHANGED\r\n\t\t}),\r\n\t\tonWidthChange: (prevWidth, newWidth) => {\r\n\t\t\tlog('~ Scrollable container width changed from', prevWidth, 'to', newWidth, '~')\r\n\t\t\tthis.onContainerResize()\r\n\t\t}\r\n\t})\r\n\r\n\tthis.scroll = new Scroll({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tscrollableContainer: this.scrollableContainer,\r\n\t\titemsContainer: this.itemsContainer,\r\n\t\twaitForScrollingToStop,\r\n\t\tonScroll: ({ delayed } = {}) => {\r\n\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\treason: delayed ? LAYOUT_REASON.STOPPED_SCROLLING : LAYOUT_REASON.SCROLL\r\n\t\t\t})\r\n\t\t},\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\tisImmediateLayoutScheduled: () => Boolean(this.layoutTimer),\r\n\t\thasNonRenderedItemsAtTheTop: () => this.getState().firstShownItemIndex > 0,\r\n\t\thasNonRenderedItemsAtTheBottom: () => this.getState().lastShownItemIndex < this.getItemsCount() - 1,\r\n\t\tgetLatestLayoutVisibleArea: () => this.latestLayoutVisibleArea,\r\n\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer,\r\n\t\tgetPrerenderMargin: () => this.getPrerenderMargin()\r\n\t})\r\n\r\n\tthis.listHeightMeasurement = new ListHeightMeasurement({\r\n\t\titemsContainer: this.itemsContainer,\r\n\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer\r\n\t})\r\n\r\n\tif (this.engine.watchListTopOffset) {\r\n\t\tthis.listTopOffsetWatcher = this.engine.watchListTopOffset({\r\n\t\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer,\r\n\t\t\tonListTopOffsetChange: ({ reason }) => this.onUpdateShownItemIndexes({\r\n\t\t\t\treason: LAYOUT_REASON.TOP_OFFSET_CHANGED\r\n\t\t\t})\r\n\t\t})\r\n\t}\r\n\r\n\tthis.beforeResize = new BeforeResize({\r\n\t\tgetState: this.getState,\r\n\t\tgetVerticalSpacing: this.getVerticalSpacing,\r\n\t\tgetColumnsCount: this.getColumnsCount\r\n\t})\r\n}"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,0BAAT,CACdC,wBADc,EAEdC,KAFc,EAIb;EAAA;;EAAA,IADDC,OACC,uEADS,EACT;EACD,IACCC,MADD,GAuBID,OAvBJ,CACCC,MADD;EAAA,IAECC,MAFD,GAuBIF,OAvBJ,CAECE,MAFD;EAAA,IAGCC,KAHD,GAuBIH,OAvBJ,CAGCG,KAHD;EAAA,4BAuBIH,OAvBJ,CAICI,mBAJD;EAAA,IAICA,mBAJD,sCAIuB,YAAM,CAAE,CAJ/B;EAAA,IAKCC,aALD,GAuBIL,OAvBJ,CAKCK,aALD;EAAA,IAMCC,qBAND,GAuBIN,OAvBJ,CAMCM,qBAND;EAAA,IAOCC,sBAPD,GAuBIP,OAvBJ,CAOCO,sBAPD;EAAA,IAUCC,mBAVD,GAuBIR,OAvBJ,CAUCQ,mBAVD;EAAA,4BAuBIR,OAvBJ,CAWCS,qBAXD;EAAA,IAWCA,qBAXD,sCAWyB,EAXzB;EAAA,IAYCC,eAZD,GAuBIV,OAvBJ,CAYCU,eAZD;EAAA,IAaCC,SAbD,GAuBIX,OAvBJ,CAaCW,SAbD;EAAA,IAeCC,mBAfD,GAuBIZ,OAvBJ,CAeCY,mBAfD;EAAA,IAgBCC,gCAhBD,GAuBIb,OAvBJ,CAgBCa,gCAhBD;EAAA,IAiBCC,mBAjBD,GAuBId,OAvBJ,CAiBCc,mBAjBD;EAAA,IAmBCC,iBAnBD,GAuBIf,OAvBJ,CAmBCe,iBAnBD;EAAA,IAoBCC,uB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AAI,CAACrF,QAAL,GAAgBsF,mBAAhB,GAAsC,CAA5C;IAAA,CAbL;IAcxBC,8BAA8B,EAAE;MAAA,OAAM,MAAI,CAACvF,QAAL,GAAgBwF,kBAAhB,GAAqC,MAAI,CAACC,aAAL,KAAuB,CAAlE;IAAA,CAdR;IAexBC,0BAA0B,EAAE;MAAA,OAAM,MAAI,CAACC,uBAAX;IAAA,CAfJ;IAgBxBC,gBAAgB,EAAE,KAAKC,yCAhBC;IAiBxBnD,kBAAkB,EAAE;MAAA,OAAM,MAAI,CAACA,kBAAL,EAAN;IAAA;EAjBI,CAAX,CAAd;EAoBA,KAAKoD,qBAAL,GAA6B,IAAIC,iCAAJ,CAA0B;IACtDrE,cAAc,EAAE,KAAKA,cADiC;IAEtDkE,gBAAgB,EAAE,KAAKC;EAF+B,CAA1B,CAA7B;;EAKA,IAAI,KAAKlG,MAAL,CAAYqG,kBAAhB,EAAoC;IACnC,KAAKC,oBAAL,GAA4B,KAAKtG,MAAL,CAAYqG,kBAAZ,CAA+B;MAC1DJ,gBAAgB,EAAE,KAAKC,yCADmC;MAE1DK,qBAAqB,EAAE;QAAA,IAAG/B,MAAH,SAAGA,MAAH;QAAA,OAAgB,MAAI,CAACD,wBAAL,CAA8B;UACpEC,MAAM,EAAEC,qBAAA,CAAc+B;QAD8C,CAA9B,CAAhB;MAAA;IAFmC,CAA/B,CAA5B;EAMA;;EAED,KAAK3E,YAAL,GAAoB,IAAI4E,wBAAJ,CAAiB;IACpCpG,QAAQ,EAAE,KAAKA,QADqB;IAEpC2C,kBAAkB,EAAE,KAAKA,kBAFW;IAGpCxD,eAAe,EAAE,KAAKA;EAHc,CAAjB,CAApB;AAKA"}
|
|
1
|
+
{"version":3,"file":"VirtualScroller.constructor.js","names":["VirtualScrollerConstructor","getItemsContainerElement","items","options","bypass","render","state","getInitialItemState","onStateChange","initialScrollPosition","onScrollPositionChange","scrollableContainer","measureItemsBatchSize","getColumnsCount","getItemId","estimatedItemHeight","getEstimatedVisibleItemRowsCount","getEstimatedInterItemVerticalSpacing","onItemInitialRender","onItemFirstRender","_useTimeoutInRenderLoop","_waitForScrollingToStop","engine","getEstimatedItemHeight","getScrollableContainer","log","DOMEngine","getState","setState","Error","_bypass","isItemEqual","a","b","item","warn","i","indexOf","length","createStateHelpers","call","createVerticalSpacingHelpers","createColumnsHelpers","createLayoutHelpers","createOnRenderHelpers","createScrollableContainerResizeHelpers","createItemsHelpers","createHelpers","waitForScrollingToStop","itemHeights","readItemHeightsFromState","beforeResize","initializeFromState","itemsContainer","createItemsContainer","clear","isItemsContainerElementTableBody","tagName","isInBypassMode","createScrollableContainer","ItemHeights","container","getItemHeight","setItemHeight","height","getAverageItemHeight","averageItemHeight","DEFAULT_ITEM_HEIGHT","layout","Layout","getEstimatedVisibleItemRowsCountForInitialRender","getPrerenderMargin","getPrerenderMarginRatio","getVerticalSpacing","getVerticalSpacingBeforeResize","getColumnsCountBeforeResize","columnsCount","getItemHeightBeforeResize","getBeforeResizeItemsCount","getMaxVisibleAreaHeight","getHeight","getPreviouslyCalculatedLayout","previouslyCalculatedLayout","scrollableContainerResizeHandler","ScrollableContainerResizeHandler","getWidth","listenForResize","listener","onResize","onResizeStart","_isResizing","onResizeStop","undefined","onNoChange","onUpdateShownItemIndexes","reason","LAYOUT_REASON","VIEWPORT_SIZE_UNCHANGED","onHeightChange","VIEWPORT_HEIGHT_CHANGED","onWidthChange","prevWidth","newWidth","onContainerResize","scroll","Scroll","onScroll","delayed","STOPPED_SCROLLING","SCROLL","isImmediateLayoutScheduled","Boolean","layoutTimer","hasNonRenderedItemsAtTheTop","firstShownItemIndex","hasNonRenderedItemsAtTheBottom","lastShownItemIndex","getItemsCount","getLatestLayoutVisibleArea","latestLayoutVisibleArea","getListTopOffset","getListTopOffsetInsideScrollableContainer","listHeightMeasurement","ListHeightMeasurement","watchListTopOffset","listTopOffsetWatcher","onListTopOffsetChange","TOP_OFFSET_CHANGED","BeforeResize"],"sources":["../source/VirtualScroller.constructor.js"],"sourcesContent":["import DOMEngine from './DOM/Engine.js'\r\n\r\nimport Layout, { LAYOUT_REASON } from './Layout.js'\r\nimport { DEFAULT_ITEM_HEIGHT } from './Layout.defaults.js'\r\nimport ScrollableContainerResizeHandler from './ScrollableContainerResizeHandler.js'\r\nimport BeforeResize from './BeforeResize.js'\r\nimport Scroll from './Scroll.js'\r\nimport ListHeightMeasurement from './ListHeightMeasurement.js'\r\nimport ItemHeights from './ItemHeights.js'\r\n\r\nimport log, { warn } from './utility/debug.js'\r\n\r\nimport createStateHelpers from './VirtualScroller.state.js'\r\nimport createVerticalSpacingHelpers from './VirtualScroller.verticalSpacing.js'\r\nimport createColumnsHelpers from './VirtualScroller.columns.js'\r\nimport createLayoutHelpers from './VirtualScroller.layout.js'\r\nimport createOnRenderHelpers from './VirtualScroller.onRender.js'\r\nimport createScrollableContainerResizeHelpers from './VirtualScroller.onContainerResize.js'\r\nimport createItemsHelpers from './VirtualScroller.items.js'\r\n\r\n/**\r\n * @param {function} getItemsContainerElement — Returns the container DOM `Element`.\r\n * @param {any[]} items — The list of items.\r\n * @param {Object} [options] — See README.md.\r\n * @return {VirtualScroller}\r\n */\r\nexport default function VirtualScrollerConstructor(\r\n\tgetItemsContainerElement,\r\n\titems,\r\n\toptions = {}\r\n) {\r\n\tconst {\r\n\t\tbypass,\r\n\t\trender,\r\n\t\tstate,\r\n\t\tgetInitialItemState = () => {},\r\n\t\tonStateChange,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\t// `scrollableContainer` option is deprecated.\r\n\t\t// Use `getScrollableContainer()` option instead.\r\n\t\tscrollableContainer,\r\n\t\tmeasureItemsBatchSize = 50,\r\n\t\tgetColumnsCount,\r\n\t\tgetItemId,\r\n\t\t// `estimatedItemHeight` is deprecated, use `getEstimatedItemHeight()` instead.\r\n\t\testimatedItemHeight,\r\n\t\tgetEstimatedVisibleItemRowsCount,\r\n\t\tgetEstimatedInterItemVerticalSpacing,\r\n\t\tonItemInitialRender,\r\n\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\tonItemFirstRender,\r\n\t\t_useTimeoutInRenderLoop,\r\n\t\t_waitForScrollingToStop,\r\n\t\tengine\r\n\t} = options\r\n\r\n\tlet {\r\n\t\tgetEstimatedItemHeight,\r\n\t\tgetScrollableContainer\r\n\t} = options\r\n\r\n\tlog('~ Initialize ~')\r\n\r\n\t// Could support non-DOM rendering engines.\r\n\t// For example, React Native, `<canvas/>`, etc.\r\n\tthis.engine = engine || DOMEngine\r\n\r\n\tif (!getEstimatedItemHeight && typeof estimatedItemHeight === 'number') {\r\n\t\tgetEstimatedItemHeight = () => estimatedItemHeight\r\n\t}\r\n\r\n\t// `scrollableContainer` option is deprecated.\r\n\t// Use `getScrollableContainer()` option instead.\r\n\tif (!getScrollableContainer && scrollableContainer) {\r\n\t\tgetScrollableContainer = () => scrollableContainer\r\n\t}\r\n\r\n\t// Sometimes, when `new VirtualScroller()` instance is created,\r\n\t// `getItemsContainerElement()` might not be ready to return the \"container\" DOM Element yet\r\n\t// (for example, because it's not rendered yet). That's the reason why it's a getter function.\r\n\t// For example, in React `<VirtualScroller/>` component, a `VirtualScroller`\r\n\t// instance is created in the React component's `constructor()`, and at that time\r\n\t// the container Element is not yet available. The container Element is available\r\n\t// in `componentDidMount()`, but `componentDidMount()` is not executed on server,\r\n\t// which would mean that React `<VirtualScroller/>` wouldn't render at all\r\n\t// on server side, while with the `getItemsContainerElement()` approach, on server side,\r\n\t// it still \"renders\" a list with a predefined amount of items in it by default.\r\n\t// (`initiallyRenderedItemsCount`, or `1`).\r\n\tthis.getItemsContainerElement = getItemsContainerElement\r\n\r\n\t// if (prerenderMargin === undefined) {\r\n\t// \t// Renders items which are outside of the screen by this \"prerender margin\".\r\n\t// \t// Is the screen height by default: seems to be the optimal value\r\n\t// \t// for \"Page Up\" / \"Page Down\" navigation and optimized mouse wheel scrolling.\r\n\t// \tprerenderMargin = this.scrollableContainer ? this.scrollableContainer.getHeight() : 0\r\n\t// }\r\n\r\n\tif (options.getState || options.setState) {\r\n\t\tthrow new Error('[virtual-scroller] `getState`/`setState` options usage has changed in the new version. See the readme for more details.')\r\n\t}\r\n\r\n\tif (bypass) {\r\n\t\tlog('~ \"bypass\" mode ~')\r\n\t}\r\n\r\n\t// In `bypass` mode, `VirtualScroller` doesn't wait\r\n\t// for the user to scroll down to render all items:\r\n\t// instead, it renders all items right away, as if\r\n\t// the list is rendered without using `VirtualScroller`.\r\n\t// It was added just to measure how much is the\r\n\t// performance difference between using a `VirtualScroller`\r\n\t// and not using a `VirtualScroller`.\r\n\t// It turned out that unmounting large React component trees\r\n\t// is a very long process, so `VirtualScroller` does seem to\r\n\t// make sense when used in a React application.\r\n\tthis._bypass = bypass\r\n\t// this.bypassBatchSize = bypassBatchSize || 10\r\n\r\n\t// Using `setTimeout()` in render loop is a workaround\r\n\t// for avoiding a React error message:\r\n\t// \"Maximum update depth exceeded.\r\n\t// This can happen when a component repeatedly calls\r\n\t// `.setState()` inside `componentWillUpdate()` or `componentDidUpdate()`.\r\n\t// React limits the number of nested updates to prevent infinite loops.\"\r\n\tthis._useTimeoutInRenderLoop = _useTimeoutInRenderLoop\r\n\r\n\tif (getItemId) {\r\n\t\tthis.isItemEqual = (a, b) => getItemId(a) === getItemId(b)\r\n\t} else {\r\n\t\tthis.isItemEqual = (a, b) => a === b\r\n\t}\r\n\r\n\tif (onItemInitialRender) {\r\n\t\tthis.onItemInitialRender = onItemInitialRender\r\n\t}\r\n\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\telse if (onItemFirstRender) {\r\n\t\tthis.onItemInitialRender = (item) => {\r\n\t\t\twarn('`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.')\r\n\t\t\tconst { items } = this.getState()\r\n\t\t\tconst i = items.indexOf(item)\r\n\t\t\t// The `item` could also be non-found due to the inconsistency bug:\r\n\t\t\t// The reason is that `i` can be non-consistent with the `items`\r\n\t\t\t// passed to `<VirtualScroller/>` in React due to `updateState()` not being\r\n\t\t\t// instanteneous: when new `items` are passed to `<VirtualScroller/>`,\r\n\t\t\t// `VirtualScroller.updateState({ items })` is called, and if `onItemFirstRender(i)`\r\n\t\t\t// is called after the aforementioned `updateState()` is called but before it finishes,\r\n\t\t\t// `i` would point to an index in \"previous\" `items` while the application\r\n\t\t\t// would assume that `i` points to an index in the \"new\" `items`,\r\n\t\t\t// resulting in an incorrect item being assumed by the application\r\n\t\t\t// or even in an \"array index out of bounds\" error.\r\n\t\t\tif (i >= 0) {\r\n\t\t\t\tonItemFirstRender(i)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// If initial `state` is passed then use `items` from `state`\r\n\t// instead of the `items` argument.\r\n\tif (state) {\r\n\t\titems = state.items\r\n\t}\r\n\r\n\tlog('Items count', items.length)\r\n\tif (getEstimatedItemHeight) {\r\n\t\tlog('Estimated item height', getEstimatedItemHeight())\r\n\t}\r\n\r\n\tcreateStateHelpers.call(this, { state, getInitialItemState, onStateChange, render, items })\r\n\r\n\tcreateVerticalSpacingHelpers.call(this, { getEstimatedInterItemVerticalSpacing })\r\n\tcreateColumnsHelpers.call(this, { getColumnsCount })\r\n\r\n\tcreateLayoutHelpers.call(this)\r\n\tcreateOnRenderHelpers.call(this)\r\n\tcreateScrollableContainerResizeHelpers.call(this)\r\n\tcreateItemsHelpers.call(this)\r\n\r\n\tcreateHelpers.call(this, {\r\n\t\tgetScrollableContainer,\r\n\t\tgetEstimatedItemHeight,\r\n\t\tgetEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\twaitForScrollingToStop: _waitForScrollingToStop\r\n\t})\r\n\r\n\tif (state) {\r\n\t\t// Initialize `ItemHeights` from previously measured `state.itemHeights`.\r\n\t\tthis.itemHeights.readItemHeightsFromState(state)\r\n\r\n\t\t// Initialize some `BeforeResize` internal flags from a previously saved state.\r\n\t\tthis.beforeResize.initializeFromState(state)\r\n\t}\r\n}\r\n\r\nfunction createHelpers({\r\n\tgetScrollableContainer,\r\n\tgetEstimatedItemHeight,\r\n\tgetEstimatedVisibleItemRowsCount,\r\n\tmeasureItemsBatchSize,\r\n\tinitialScrollPosition,\r\n\tonScrollPositionChange,\r\n\twaitForScrollingToStop\r\n}) {\r\n\tthis.itemsContainer = this.engine.createItemsContainer(\r\n\t\tthis.getItemsContainerElement\r\n\t)\r\n\r\n\t// If the items \"container\" element is mounted at this stage,\r\n\t// remove any accidental text nodes from it (like whitespace).\r\n\t//\r\n\t// Also, this guards against cases when someone accidentally tries\r\n\t// using `VirtualScroller` on a non-empty element.\r\n\t//\r\n\tif (this.getItemsContainerElement()) {\r\n\t\tthis.itemsContainer.clear()\r\n\t}\r\n\r\n\tthis.isItemsContainerElementTableBody = () => {\r\n\t\treturn this.engine === DOMEngine &&\r\n\t\t\tthis.getItemsContainerElement().tagName === 'TBODY'\r\n\t}\r\n\r\n\tthis.isInBypassMode = () => this._bypass\r\n\r\n\tthis.scrollableContainer = this.engine.createScrollableContainer(\r\n\t\tgetScrollableContainer,\r\n\t\tthis.getItemsContainerElement\r\n\t)\r\n\r\n\t// Create `ItemHeights` instance.\r\n\tthis.itemHeights = new ItemHeights({\r\n\t\tcontainer: this.itemsContainer,\r\n\t\tgetItemHeight: (i) => this.getState().itemHeights[i],\r\n\t\tsetItemHeight: (i, height) => this.getState().itemHeights[i] = height\r\n\t})\r\n\r\n\tthis.getAverageItemHeight = () => {\r\n\t\tconst averageItemHeight = this.itemHeights.getAverageItemHeight()\r\n\t\tif (typeof averageItemHeight === 'number') {\r\n\t\t\treturn averageItemHeight\r\n\t\t}\r\n\t\treturn this.getEstimatedItemHeight()\r\n\t}\r\n\r\n\tthis.getEstimatedItemHeight = () => {\r\n\t\tif (getEstimatedItemHeight) {\r\n\t\t\tconst estimatedItemHeight = getEstimatedItemHeight()\r\n\t\t\tif (typeof estimatedItemHeight === 'number') {\r\n\t\t\t\treturn estimatedItemHeight\r\n\t\t\t}\r\n\t\t\tthrow new Error('[virtual-scroller] `getEstimatedItemHeight()` must return a number')\r\n\t\t}\r\n\t\t// `DEFAULT_ITEM_HEIGHT` will be used in server-side render\r\n\t\t// unless `getEstimatedItemHeight()` parameter is specified.\r\n\t\treturn DEFAULT_ITEM_HEIGHT\r\n\t}\r\n\r\n\tthis.layout = new Layout({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tgetEstimatedVisibleItemRowsCountForInitialRender: getEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tgetPrerenderMargin: () => this.getPrerenderMargin(),\r\n\t\tgetPrerenderMarginRatio: () => this.getPrerenderMarginRatio(),\r\n\t\tgetVerticalSpacing: () => this.getVerticalSpacing(),\r\n\t\tgetVerticalSpacingBeforeResize: () => this.getVerticalSpacingBeforeResize(),\r\n\t\tgetColumnsCount: () => this.getColumnsCount(),\r\n\t\tgetColumnsCountBeforeResize: () => this.getState().beforeResize && this.getState().beforeResize.columnsCount,\r\n\t\tgetItemHeight: (i) => this.getState().itemHeights[i],\r\n\t\tgetItemHeightBeforeResize: (i) => this.getState().beforeResize && this.getState().beforeResize.itemHeights[i],\r\n\t\tgetBeforeResizeItemsCount: () => this.getState().beforeResize ? this.getState().beforeResize.itemHeights.length : 0,\r\n\t\tgetAverageItemHeight: () => this.getAverageItemHeight(),\r\n\t\t// `this.scrollableContainer` is gonna be `undefined` during server-side rendering.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/30\r\n\t\tgetMaxVisibleAreaHeight: () => this.scrollableContainer && this.scrollableContainer.getHeight(),\r\n\t\t//\r\n\t\t// The \"previously calculated layout\" feature is not currently used.\r\n\t\t//\r\n\t\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t\t// rather than from scratch, which would be an optimization.\r\n\t\t//\r\n\t\tgetPreviouslyCalculatedLayout: () => this.previouslyCalculatedLayout\r\n\t})\r\n\r\n\tthis.scrollableContainerResizeHandler = new ScrollableContainerResizeHandler({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tgetWidth: () => this.scrollableContainer.getWidth(),\r\n\t\tgetHeight: () => this.scrollableContainer.getHeight(),\r\n\t\tlistenForResize: (listener) => this.scrollableContainer.onResize(listener),\r\n\t\tonResizeStart: () => {\r\n\t\t\tlog('~ Scrollable container resize started ~')\r\n\t\t\tthis._isResizing = true\r\n\t\t},\r\n\t\tonResizeStop: () => {\r\n\t\t\tlog('~ Scrollable container resize finished ~')\r\n\t\t\tthis._isResizing = undefined\r\n\t\t},\r\n\t\tonNoChange: () => {\r\n\t\t\t// There might have been some missed `this.onUpdateShownItemIndexes()` calls\r\n\t\t\t// due to setting `this._isResizing` flag to `true` during the resize.\r\n\t\t\t// So, update shown item indexes just in case.\r\n\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\treason: LAYOUT_REASON.VIEWPORT_SIZE_UNCHANGED\r\n\t\t\t})\r\n\t\t},\r\n\t\tonHeightChange: () => this.onUpdateShownItemIndexes({\r\n\t\t\treason: LAYOUT_REASON.VIEWPORT_HEIGHT_CHANGED\r\n\t\t}),\r\n\t\tonWidthChange: (prevWidth, newWidth) => {\r\n\t\t\tlog('~ Scrollable container width changed from', prevWidth, 'to', newWidth, '~')\r\n\t\t\tthis.onContainerResize()\r\n\t\t}\r\n\t})\r\n\r\n\tthis.scroll = new Scroll({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tscrollableContainer: this.scrollableContainer,\r\n\t\titemsContainer: this.itemsContainer,\r\n\t\twaitForScrollingToStop,\r\n\t\tonScroll: ({ delayed } = {}) => {\r\n\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\treason: delayed ? LAYOUT_REASON.STOPPED_SCROLLING : LAYOUT_REASON.SCROLL\r\n\t\t\t})\r\n\t\t},\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\tisImmediateLayoutScheduled: () => Boolean(this.layoutTimer),\r\n\t\thasNonRenderedItemsAtTheTop: () => this.getState().firstShownItemIndex > 0,\r\n\t\thasNonRenderedItemsAtTheBottom: () => this.getState().lastShownItemIndex < this.getItemsCount() - 1,\r\n\t\tgetLatestLayoutVisibleArea: () => this.latestLayoutVisibleArea,\r\n\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer,\r\n\t\tgetPrerenderMargin: () => this.getPrerenderMargin()\r\n\t})\r\n\r\n\tthis.listHeightMeasurement = new ListHeightMeasurement({\r\n\t\titemsContainer: this.itemsContainer,\r\n\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer\r\n\t})\r\n\r\n\tif (this.engine.watchListTopOffset) {\r\n\t\tthis.listTopOffsetWatcher = this.engine.watchListTopOffset({\r\n\t\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer,\r\n\t\t\tonListTopOffsetChange: ({ reason }) => this.onUpdateShownItemIndexes({\r\n\t\t\t\treason: LAYOUT_REASON.TOP_OFFSET_CHANGED\r\n\t\t\t})\r\n\t\t})\r\n\t}\r\n\r\n\tthis.beforeResize = new BeforeResize({\r\n\t\tgetState: this.getState,\r\n\t\tgetVerticalSpacing: this.getVerticalSpacing,\r\n\t\tgetColumnsCount: this.getColumnsCount\r\n\t})\r\n}"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,0BAAT,CACdC,wBADc,EAEdC,KAFc,EAIb;EAAA;;EAAA,IADDC,OACC,uEADS,EACT;EACD,IACCC,MADD,GAwBID,OAxBJ,CACCC,MADD;EAAA,IAECC,MAFD,GAwBIF,OAxBJ,CAECE,MAFD;EAAA,IAGCC,KAHD,GAwBIH,OAxBJ,CAGCG,KAHD;EAAA,4BAw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length;
|
|
33
33
|
};
|
|
34
|
+
|
|
35
|
+
this._getItemIndexByItemOrIndex = function (itemOrIndex) {
|
|
36
|
+
var item = itemOrIndex;
|
|
37
|
+
|
|
38
|
+
var _this$getState = _this.getState(),
|
|
39
|
+
items = _this$getState.items; // Find the `item`'s index in the `items` array.
|
|
40
|
+
//
|
|
41
|
+
// Performance notes:
|
|
42
|
+
// Doing an `.indexOf()` operation on a very large array could be inefficient
|
|
43
|
+
// because it would have to check every element of the array.
|
|
44
|
+
// In case of any hypothetical performance-related issues,
|
|
45
|
+
// the code could use a `new Map()` as an "index" for finding individual items.
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
var i = items.indexOf(item); // validate that the `item` exists in the `items` array.
|
|
49
|
+
|
|
50
|
+
if (i >= 0) {
|
|
51
|
+
return i;
|
|
52
|
+
} // Legacy behavior: some functions used to accept an `i: number` item index as an argument.
|
|
53
|
+
// Later the argument was changed to `item: Item`.
|
|
54
|
+
//
|
|
55
|
+
// The old way of passing an `i: number` argument would only result in weird application behavior
|
|
56
|
+
// when all of the below circumstances are true, which is assumed extremely unlikely:
|
|
57
|
+
//
|
|
58
|
+
// BOTH use a previous version of `virtual-scroller` (ones before December 2025, with downloads count that is not very high)
|
|
59
|
+
// AND to be used with an `items` array of type `number[]`
|
|
60
|
+
// AND to use any of the "advanced" functions:
|
|
61
|
+
// * `setItemState(i, newState)`
|
|
62
|
+
// * `onItemHeightDidChange(i)`
|
|
63
|
+
// * `getItemScrollPosition(i)`
|
|
64
|
+
//
|
|
65
|
+
// The code below handles the legacy compatibility aspect of the old type of argument
|
|
66
|
+
// except maybe for those "extremely unlikely" cases in which the app is still unlikely to crash.
|
|
67
|
+
//
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if (typeof itemOrIndex === 'number') {
|
|
71
|
+
var _i = itemOrIndex; // Validate the item index argument.
|
|
72
|
+
|
|
73
|
+
if (_i >= 0 && _i < items.length) {
|
|
74
|
+
return _i;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
(0, _debug.reportError)("Item not found: ".concat(JSON.stringify(item)));
|
|
79
|
+
};
|
|
34
80
|
/**
|
|
35
81
|
* Updates `items`. For example, can prepend or append new items to the list.
|
|
36
82
|
* @param {any[]} newItems
|
|
@@ -41,8 +87,8 @@ function _default() {
|
|
|
41
87
|
this._setItems = function (newItems) {
|
|
42
88
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
43
89
|
|
|
44
|
-
var _this$
|
|
45
|
-
previousItems = _this$
|
|
90
|
+
var _this$getState2 = _this.getState(),
|
|
91
|
+
previousItems = _this$getState2.items; // Even if `newItems` are equal to `this.state.items`,
|
|
46
92
|
// still perform a `updateState()` call, because, if `updateState()` calls
|
|
47
93
|
// were "asynchronous", there could be a situation when a developer
|
|
48
94
|
// first calls `setItems(newItems)` and then `setItems(oldItems)`:
|
|
@@ -53,8 +99,8 @@ function _default() {
|
|
|
53
99
|
// and that wouldn't be what the developer intended.
|
|
54
100
|
|
|
55
101
|
|
|
56
|
-
var _this$
|
|
57
|
-
itemStates = _this$
|
|
102
|
+
var _this$getState3 = _this.getState(),
|
|
103
|
+
itemStates = _this$getState3.itemStates;
|
|
58
104
|
|
|
59
105
|
var _ref = _this.widthHasChanged ? _this.widthHasChanged.stateUpdate : _this.getState(),
|
|
60
106
|
itemHeights = _ref.itemHeights;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualScroller.items.js","names":["getItemsCount","getState","items","length","_setItems","newItems","options","previousItems","itemStates","widthHasChanged","stateUpdate","itemHeights","log","layoutUpdate","itemsUpdateInfo","itemsDiff","getItemsDiff","firstShownItemIndex","lastShownItemIndex","beforeItemsHeight","afterItemsHeight","shouldRestoreScrollPosition","preserveScrollPositionOnPrependItems","preserveScrollPosition","prependedItemsCount","appendedItemsCount","shouldResetGridLayout","layout","getLayoutUpdateForItemsDiff","itemsCount","columnsCount","getActualColumnsCount","onResetGridLayout","Array","concat","fillArray","i","getInitialItemState","listHeightMeasurement","snapshotListHeightBeforeAddingNewItems","firstNonMeasuredItemIndex","undefined","getInitialLayoutValues","prepend","append","reset","replace","onBeforeShowItems","newItemsWillBeRendered","count","newState","beforeResize","shouldIncludeBeforeResizeValuesInState","shouldDiscardBeforeResizeItemHeights","_isSettingNewItems","updateState","isItemEqual"],"sources":["../source/VirtualScroller.items.js"],"sourcesContent":["import log, { isDebug } from './utility/debug.js'\r\nimport getItemsDiff from './getItemsDiff.js'\r\nimport fillArray from './utility/fillArray.js'\r\n\r\nexport default function() {\r\n\tthis.getItemsCount = () => {\r\n\t\treturn this.getState().items.length\r\n\t}\r\n\r\n\t/**\r\n\t * Updates `items`. For example, can prepend or append new items to the list.\r\n\t * @param {any[]} newItems\r\n\t * @param {boolean} [options.preserveScrollPositionOnPrependItems] — Set to `true` to enable \"restore scroll position after prepending items\" feature (could be useful when implementing \"Show previous items\" button).\r\n\t */\r\n\tthis._setItems = (newItems, options = {}) => {\r\n\t\tconst {\r\n\t\t\titems: previousItems\r\n\t\t} = this.getState()\r\n\r\n\t\t// Even if `newItems` are equal to `this.state.items`,\r\n\t\t// still perform a `updateState()` call, because, if `updateState()` calls\r\n\t\t// were \"asynchronous\", there could be a situation when a developer\r\n\t\t// first calls `setItems(newItems)` and then `setItems(oldItems)`:\r\n\t\t// if this function did `return` `if (newItems === this.state.items)`\r\n\t\t// then `updateState({ items: newItems })` would be scheduled as part of\r\n\t\t// `setItems(newItems)` call, but the subsequent `setItems(oldItems)` call\r\n\t\t// wouldn't do anything resulting in `newItems` being set as a result,\r\n\t\t// and that wouldn't be what the developer intended.\r\n\r\n\t\tlet { itemStates } = this.getState()\r\n\t\tlet { itemHeights } = this.widthHasChanged\r\n\t\t\t? this.widthHasChanged.stateUpdate\r\n\t\t\t: this.getState()\r\n\r\n\t\tlog('~ Update items ~')\r\n\r\n\t\tlet layoutUpdate\r\n\t\tlet itemsUpdateInfo\r\n\r\n\t\t// Compare the new items to the current items.\r\n\t\tconst itemsDiff = this.getItemsDiff(previousItems, newItems)\r\n\r\n\t\t// See if it's an \"incremental\" items update.\r\n\t\tif (itemsDiff) {\r\n\t\t\tconst {\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tafterItemsHeight\r\n\t\t\t} = this.widthHasChanged\r\n\t\t\t\t? this.widthHasChanged.stateUpdate\r\n\t\t\t\t: this.getState()\r\n\r\n\t\t\tconst shouldRestoreScrollPosition = firstShownItemIndex === 0 &&\r\n\t\t\t\t// `preserveScrollPosition` option name is deprecated,\r\n\t\t\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\t\t\t(options.preserveScrollPositionOnPrependItems || options.preserveScrollPosition)\r\n\r\n\t\t\tconst {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t} = itemsDiff\r\n\r\n\t\t\tlet shouldResetGridLayout\r\n\r\n\t\t\tlayoutUpdate = this.layout.getLayoutUpdateForItemsDiff({\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tafterItemsHeight\r\n\t\t\t}, {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t}, {\r\n\t\t\t\titemsCount: newItems.length,\r\n\t\t\t\tcolumnsCount: this.getActualColumnsCount(),\r\n\t\t\t\tshouldRestoreScrollPosition,\r\n\t\t\t\tonResetGridLayout: () => shouldResetGridLayout = true\r\n\t\t\t})\r\n\r\n\t\t\tif (prependedItemsCount > 0) {\r\n\t\t\t\tlog('Prepend', prependedItemsCount, 'items')\r\n\r\n\t\t\t\titemHeights = new Array(prependedItemsCount).concat(itemHeights)\r\n\t\t\t\titemStates = fillArray(\r\n\t\t\t\t\tnew Array(prependedItemsCount),\r\n\t\t\t\t\t(i) => this.getInitialItemState(newItems[i])\r\n\t\t\t\t)\r\n\t\t\t\t\t.concat(itemStates)\r\n\r\n\t\t\t\t// Restore scroll position after prepending items (if requested).\r\n\t\t\t\tif (shouldRestoreScrollPosition) {\r\n\t\t\t\t\tlog('Will restore scroll position')\r\n\t\t\t\t\tthis.listHeightMeasurement.snapshotListHeightBeforeAddingNewItems({\r\n\t\t\t\t\t\tpreviousItems,\r\n\t\t\t\t\t\tnewItems,\r\n\t\t\t\t\t\tprependedItemsCount\r\n\t\t\t\t\t})\r\n\t\t\t\t\t// \"Seamless prepend\" scenario doesn't result in a re-layout,\r\n\t\t\t\t\t// so if any \"non measured item\" is currently pending,\r\n\t\t\t\t\t// it doesn't get reset and will be handled after `state` is updated.\r\n\t\t\t\t\tif (this.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\t\t\t\tthis.firstNonMeasuredItemIndex += prependedItemsCount\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tlog('Reset layout')\r\n\t\t\t\t\tif (shouldResetGridLayout) {\r\n\t\t\t\t\t\tlog('Reason: Prepended items count', prependedItemsCount, 'is not divisible by Columns Count', this.getActualColumnsCount())\r\n\t\t\t\t\t\t// Reset item heights because the whole grid is going to be rebalanced\r\n\t\t\t\t\t\t// and re-rendered in a different configuration.\r\n\t\t\t\t\t\titemHeights = new Array(newItems.length)\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\t// Reset layout because none of the prepended items have been measured.\r\n\t\t\t\t\t\tlog('Reason: Prepended items\\' heights are unknown')\r\n\t\t\t\t\t}\r\n\t\t\t\t\tlayoutUpdate = this.layout.getInitialLayoutValues({\r\n\t\t\t\t\t\titemsCount: newItems.length,\r\n\t\t\t\t\t\tcolumnsCount: this.getActualColumnsCount()\r\n\t\t\t\t\t})\r\n\t\t\t\t\t// Unschedule a potentially scheduled layout update\r\n\t\t\t\t\t// after measuring a previously non-measured item\r\n\t\t\t\t\t// because the list will be re-layout anyway\r\n\t\t\t\t\t// due to the new items being set.\r\n\t\t\t\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (appendedItemsCount > 0) {\r\n\t\t\t\tlog('Append', appendedItemsCount, 'items')\r\n\t\t\t\titemHeights = itemHeights.concat(new Array(appendedItemsCount))\r\n\t\t\t\titemStates = itemStates.concat(\r\n\t\t\t\t\tfillArray(\r\n\t\t\t\t\t\tnew Array(appendedItemsCount),\r\n\t\t\t\t\t\t(i) => this.getInitialItemState(newItems[prependedItemsCount + previousItems.length + i])\r\n\t\t\t\t\t)\r\n\t\t\t\t)\r\n\t\t\t}\r\n\r\n\t\t\titemsUpdateInfo = {\r\n\t\t\t\tprepend: prependedItemsCount > 0,\r\n\t\t\t\tappend: appendedItemsCount > 0\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tlog('Items have changed, and', (itemsDiff ? 'a re-layout from scratch has been requested.' : 'it\\'s not a simple append and/or prepend.'), 'Rerender the entire list from scratch.')\r\n\t\t\tlog('Previous items', previousItems)\r\n\t\t\tlog('New items', newItems)\r\n\r\n\t\t\t// Reset item heights and item states.\r\n\t\t\titemHeights = new Array(newItems.length)\r\n\t\t\titemStates = fillArray(\r\n\t\t\t\tnew Array(newItems.length),\r\n\t\t\t\t(i) => this.getInitialItemState(newItems[i])\r\n\t\t\t)\r\n\r\n\t\t\tlayoutUpdate = this.layout.getInitialLayoutValues({\r\n\t\t\t\titemsCount: newItems.length,\r\n\t\t\t\tcolumnsCount: this.getActualColumnsCount()\r\n\t\t\t})\r\n\r\n\t\t\t// Unschedule a potentially scheduled layout update\r\n\t\t\t// after measuring a previously non-measured item\r\n\t\t\t// because the list will be re-layout from scratch\r\n\t\t\t// due to the new items being set.\r\n\t\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\r\n\t\t\t// Also reset any potential pending scroll position restoration.\r\n\t\t\t// For example, imagine a developer first called `.setItems(incrementalItemsUpdate)`\r\n\t\t\t// and then called `.setItems(differentItems)` and there was no state update\r\n\t\t\t// in between those two calls. This could happen because state updates aren't\r\n\t\t\t// required to be \"synchronous\". On other words, calling `this.updateState()`\r\n\t\t\t// doesn't necessarily mean that the state is applied immediately.\r\n\t\t\t// Imagine also that such \"delayed\" state updates could be batched,\r\n\t\t\t// like they do in React inside event handlers (though that doesn't apply to this case):\r\n\t\t\t// https://github.com/facebook/react/issues/10231#issuecomment-316644950\r\n\t\t\t// If `this.listHeightMeasurement` wasn't reset on `.setItems(differentItems)`\r\n\t\t\t// and if the second `this.updateState()` call overwrites the first one\r\n\t\t\t// then it would attempt to restore scroll position in a situation when\r\n\t\t\t// it should no longer do that. Hence the reset here.\r\n\t\t\tthis.listHeightMeasurement.reset()\r\n\r\n\t\t\titemsUpdateInfo = {\r\n\t\t\t\treplace: true\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlog('~ Update state ~')\r\n\r\n\t\t// const layoutValuesAfterUpdate = {\r\n\t\t// \t...this.getState(),\r\n\t\t// \t...layoutUpdate\r\n\t\t// }\r\n\r\n\t\t// `layoutUpdate` is equivalent to `layoutValuesAfterUpdate` because\r\n\t\t// `layoutUpdate` contains all the relevant properties.\r\n\t\tlog('First shown item index', layoutUpdate.firstShownItemIndex)\r\n\t\tlog('Last shown item index', layoutUpdate.lastShownItemIndex)\r\n\t\tlog('Before items height', layoutUpdate.beforeItemsHeight)\r\n\t\tlog('After items height (actual or estimated)', layoutUpdate.afterItemsHeight)\r\n\r\n\t\t// Optionally preload items to be rendered.\r\n\t\t//\r\n\t\t// `layoutUpdate` is equivalent to `layoutValuesAfterUpdate` because\r\n\t\t// `layoutUpdate` contains all the relevant properties.\r\n\t\t//\r\n\t\tthis.onBeforeShowItems(\r\n\t\t\tnewItems,\r\n\t\t\titemHeights,\r\n\t\t\tlayoutUpdate.firstShownItemIndex,\r\n\t\t\tlayoutUpdate.lastShownItemIndex\r\n\t\t)\r\n\r\n\t\t// `this.newItemsWillBeRendered` signals that new `items` are being rendered,\r\n\t\t// and that `VirtualScroller` should temporarily stop all other updates.\r\n\t\t//\r\n\t\t// `this.newItemsWillBeRendered` is cleared in `onRender()`.\r\n\t\t//\r\n\t\t// The values in `this.newItemsWillBeRendered` are used, for example,\r\n\t\t// in `.onContainerResize()` handler in order to not break state consistency when\r\n\t\t// state updates are \"asynchronous\" (delayed) and there's a window resize event\r\n\t\t// in between calling `updateState()` below and that call actually being applied.\r\n\t\t//\r\n\t\tthis.newItemsWillBeRendered = {\r\n\t\t\t...itemsUpdateInfo,\r\n\t\t\tcount: newItems.length,\r\n\t\t\t// `layoutUpdate` now contains all layout-related properties, even if those that\r\n\t\t\t// didn't change. So `firstShownItemIndex` is always in `this.newItemsWillBeRendered`.\r\n\t\t\tlayout: layoutUpdate\r\n\t\t}\r\n\r\n\t\t// `layoutUpdate` now contains all layout-related properties, even if those that\r\n\t\t// didn't change. So this part is no longer relevant.\r\n\t\t//\r\n\t\t// // If `firstShownItemIndex` is gonna be modified as a result of setting new items\r\n\t\t// // then keep that \"new\" `firstShownItemIndex` in order for it to be used by\r\n\t\t// // `onResize()` handler when it calculates \"new\" `firstShownItemIndex`\r\n\t\t// // based on the new columns count (corresponding to the new window width).\r\n\t\t// if (layoutUpdate.firstShownItemIndex !== undefined) {\r\n\t\t// \tthis.newItemsWillBeRendered = {\r\n\t\t// \t\t...this.newItemsWillBeRendered,\r\n\t\t// \t\tfirstShownItemIndex: layoutUpdate.firstShownItemIndex\r\n\t\t// \t}\r\n\t\t// }\r\n\r\n\t\t// Update `VirtualScroller` state.\r\n\t\t//\r\n\t\t// This state update should overwrite all the `state` properties\r\n\t\t// that are also updated in the \"on scroll\" handler (`getShownItemIndexes()`):\r\n\t\t//\r\n\t\t// * `firstShownItemIndex`\r\n\t\t// * `lastShownItemIndex`\r\n\t\t// * `beforeItemsHeight`\r\n\t\t// * `afterItemsHeight`\r\n\t\t//\r\n\t\t// That's because this `updateState()` update has a higher priority\r\n\t\t// than that of the \"on scroll\" handler, so it should overwrite\r\n\t\t// any potential state changes dispatched by the \"on scroll\" handler.\r\n\t\t//\r\n\t\tconst newState = {\r\n\t\t\t...layoutUpdate,\r\n\t\t\titems: newItems,\r\n\t\t\titemStates,\r\n\t\t\titemHeights\r\n\t\t}\r\n\r\n\t\t// Introduced `shouldIncludeBeforeResizeValuesInState()` getter just to prevent\r\n\t\t// cluttering `state` with `beforeResize: undefined` property if `beforeResize`\r\n\t\t// hasn't ever been set in `state` previously.\r\n\t\tif (this.beforeResize.shouldIncludeBeforeResizeValuesInState()) {\r\n\t\t\tif (this.shouldDiscardBeforeResizeItemHeights()) {\r\n\t\t\t\t// Reset \"before resize\" item heights because now there're new items prepended\r\n\t\t\t\t// with unknown heights, or completely new items with unknown heights, so\r\n\t\t\t\t// `beforeItemsHeight` value won't be preserved anyway.\r\n\t\t\t\tnewState.beforeResize = undefined\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\t// Overwrite `beforeResize` property in `state` even if it wasn't modified\r\n\t\t\t\t// because state updates could be \"asynchronous\" and in that case there could be\r\n\t\t\t\t// some previous `updateState()` call from some previous `setItems()` call that\r\n\t\t\t\t// hasn't yet been applied, and that previous call might have scheduled setting\r\n\t\t\t\t// `state.beforeResize` property to `undefined` in order to reset it, but this\r\n\t\t\t\t// next `updateState()` call might not require resetting `state.beforeResize` property\r\n\t\t\t\t// so it should undo resetting it by simply overwriting it with its normal value.\r\n\t\t\t\tnewState.beforeResize = this.widthHasChanged\r\n\t\t\t\t\t? this.widthHasChanged.stateUpdate.beforeResize\r\n\t\t\t\t\t: this.getState().beforeResize\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `newState` should also overwrite all `state` properties that're updated in `onResize()`\r\n\t\t// because `setItems()`'s state updates always overwrite `onResize()`'s state updates.\r\n\t\t// (The least-priority ones are `onScroll()` state updates, but those're simply skipped\r\n\t\t// if there's a pending `setItems()` or `onResize()` update).\r\n\t\t//\r\n\t\t// `state` property exceptions:\r\n\t\t//\r\n\t\t// `verticalSpacing` property is not updated here because it's fine setting it to\r\n\t\t// `undefined` in `onResize()` — it will simply be re-measured after the component re-renders.\r\n\t\t//\r\n\t\t// `columnsCount` property is also not updated here because by definition it's only\r\n\t\t// updated in `onResize()`.\r\n\r\n\t\t// Render.\r\n\t\tthis._isSettingNewItems = true\r\n\t\tthis.updateState(newState)\r\n\t}\r\n\r\n\tthis.getItemsDiff = (previousItems, newItems) => {\r\n\t\treturn getItemsDiff(previousItems, newItems, this.isItemEqual)\r\n\t}\r\n}"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;;;AAEe,oBAAW;EAAA;;EACzB,KAAKA,aAAL,GAAqB,YAAM;IAC1B,OAAO,KAAI,CAACC,QAAL,GAAgBC,KAAhB,CAAsBC,MAA7B;EACA,CAFD;EAIA;AACD;AACA;AACA;AACA;;;EACC,KAAKC,SAAL,GAAiB,UAACC,QAAD,EAA4B;IAAA,IAAjBC,OAAiB,uEAAP,EAAO;;IAC5C,qBAEI,KAAI,CAACL,QAAL,EAFJ;IAAA,IACQM,aADR,kBACCL,KADD,CAD4C,CAK5C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;IAEA,sBAAqB,KAAI,CAACD,QAAL,EAArB;IAAA,IAAMO,UAAN,mBAAMA,UAAN;;IACA,WAAsB,KAAI,CAACC,eAAL,GACnB,KAAI,CAACA,eAAL,CAAqBC,WADF,GAEnB,KAAI,CAACT,QAAL,EAFH;IAAA,IAAMU,WAAN,QAAMA,WAAN;;IAIA,IAAAC,iBAAA,EAAI,kBAAJ;IAEA,IAAIC,YAAJ;IACA,IAAIC,eAAJ,CAvB4C,CAyB5C;;IACA,IAAMC,SAAS,GAAG,KAAI,CAACC,YAAL,CAAkBT,aAAlB,EAAiCF,QAAjC,CAAlB,CA1B4C,CA4B5C;;;IACA,IAAIU,SAAJ,EAAe;MACd,YAKI,KAAI,CAACN,eAAL,GACD,KAAI,CAACA,eAAL,CAAqBC,WADpB,GAED,KAAI,CAACT,QAAL,EAPH;MAAA,IACCgB,m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QAAL,GAAgBkD,YAFnB;MAGA;IACD,CAhR2C,CAkR5C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;;;IACA,KAAI,CAACG,kBAAL,GAA0B,IAA1B;;IACA,KAAI,CAACC,WAAL,CAAiBL,QAAjB;EACA,CAlSD;;EAoSA,KAAKlC,YAAL,GAAoB,UAACT,aAAD,EAAgBF,QAAhB,EAA6B;IAChD,OAAO,IAAAW,wBAAA,EAAaT,aAAb,EAA4BF,QAA5B,EAAsC,KAAI,CAACmD,WAA3C,CAAP;EACA,CAFD;AAGA"}
|
|
1
|
+
{"version":3,"file":"VirtualScroller.items.js","names":["getItemsCount","getState","items","length","_getItemIndexByItemOrIndex","itemOrIndex","item","i","indexOf","reportError","JSON","stringify","_setItems","newItems","options","previousItems","itemStates","widthHasChanged","stateUpdate","itemHeights","log","layoutUpdate","itemsUpdateInfo","itemsDiff","getItemsDiff","firstShownItemIndex","lastShownItemIndex","beforeItemsHeight","afterItemsHeight","shouldRestoreScrollPosition","preserveScrollPositionOnPrependItems","preserveScrollPosition","prependedItemsCount","appendedItemsCount","shouldResetGridLayout","layout","getLayoutUpdateForItemsDiff","itemsCount","columnsCount","getActualColumnsCount","onResetGridLayout","Array","concat","fillArray","getInitialItemState","listHeightMeasurement","snapshotListHeightBeforeAddingNewItems","firstNonMeasuredItemIndex","undefined","getInitialLayoutValues","prepend","append","reset","replace","onBeforeShowItems","newItemsWillBeRendered","count","newState","beforeResize","shouldIncludeBeforeResizeValuesInState","shouldDiscardBeforeResizeItemHeights","_isSettingNewItems","updateState","isItemEqual"],"sources":["../source/VirtualScroller.items.js"],"sourcesContent":["import log, { reportError } from './utility/debug.js'\r\nimport getItemsDiff from './getItemsDiff.js'\r\nimport fillArray from './utility/fillArray.js'\r\n\r\nexport default function() {\r\n\tthis.getItemsCount = () => {\r\n\t\treturn this.getState().items.length\r\n\t}\r\n\r\n\tthis._getItemIndexByItemOrIndex = (itemOrIndex) => {\r\n\t\tconst item = itemOrIndex\r\n\t\tconst { items } = this.getState()\r\n\t\t// Find the `item`'s index in the `items` array.\r\n\t\t//\r\n\t\t// Performance notes:\r\n\t\t// Doing an `.indexOf()` operation on a very large array could be inefficient\r\n\t\t// because it would have to check every element of the array.\r\n\t\t// In case of any hypothetical performance-related issues,\r\n\t\t// the code could use a `new Map()` as an \"index\" for finding individual items.\r\n\t\tconst i = items.indexOf(item)\r\n\t\t// validate that the `item` exists in the `items` array.\r\n\t\tif (i >= 0) {\r\n\t\t\treturn i\r\n\t\t}\r\n\r\n\t\t// Legacy behavior: some functions used to accept an `i: number` item index as an argument.\r\n\t\t// Later the argument was changed to `item: Item`.\r\n\t\t//\r\n\t\t// The old way of passing an `i: number` argument would only result in weird application behavior\r\n\t\t// when all of the below circumstances are true, which is assumed extremely unlikely:\r\n\t\t//\r\n\t\t// BOTH use a previous version of `virtual-scroller` (ones before December 2025, with downloads count that is not very high)\r\n\t\t// AND to be used with an `items` array of type `number[]`\r\n\t\t// AND to use any of the \"advanced\" functions:\r\n // * `setItemState(i, newState)`\r\n // * `onItemHeightDidChange(i)`\r\n // * `getItemScrollPosition(i)`\r\n\t\t//\r\n\t\t// The code below handles the legacy compatibility aspect of the old type of argument\r\n\t\t// except maybe for those \"extremely unlikely\" cases in which the app is still unlikely to crash.\r\n\t\t//\r\n\t\tif (typeof itemOrIndex === 'number') {\r\n\t\t\tconst i = itemOrIndex\r\n\t\t\t// Validate the item index argument.\r\n\t\t\tif (i >= 0 && i < items.length) {\r\n\t\t\t\treturn i\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treportError(`Item not found: ${JSON.stringify(item)}`)\r\n\t}\r\n\r\n\t/**\r\n\t * Updates `items`. For example, can prepend or append new items to the list.\r\n\t * @param {any[]} newItems\r\n\t * @param {boolean} [options.preserveScrollPositionOnPrependItems] — Set to `true` to enable \"restore scroll position after prepending items\" feature (could be useful when implementing \"Show previous items\" button).\r\n\t */\r\n\tthis._setItems = (newItems, options = {}) => {\r\n\t\tconst {\r\n\t\t\titems: previousItems\r\n\t\t} = this.getState()\r\n\r\n\t\t// Even if `newItems` are equal to `this.state.items`,\r\n\t\t// still perform a `updateState()` call, because, if `updateState()` calls\r\n\t\t// were \"asynchronous\", there could be a situation when a developer\r\n\t\t// first calls `setItems(newItems)` and then `setItems(oldItems)`:\r\n\t\t// if this function did `return` `if (newItems === this.state.items)`\r\n\t\t// then `updateState({ items: newItems })` would be scheduled as part of\r\n\t\t// `setItems(newItems)` call, but the subsequent `setItems(oldItems)` call\r\n\t\t// wouldn't do anything resulting in `newItems` being set as a result,\r\n\t\t// and that wouldn't be what the developer intended.\r\n\r\n\t\tlet { itemStates } = this.getState()\r\n\t\tlet { itemHeights } = this.widthHasChanged\r\n\t\t\t? this.widthHasChanged.stateUpdate\r\n\t\t\t: this.getState()\r\n\r\n\t\tlog('~ Update items ~')\r\n\r\n\t\tlet layoutUpdate\r\n\t\tlet itemsUpdateInfo\r\n\r\n\t\t// Compare the new items to the current items.\r\n\t\tconst itemsDiff = this.getItemsDiff(previousItems, newItems)\r\n\r\n\t\t// See if it's an \"incremental\" items update.\r\n\t\tif (itemsDiff) {\r\n\t\t\tconst {\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tafterItemsHeight\r\n\t\t\t} = this.widthHasChanged\r\n\t\t\t\t? this.widthHasChanged.stateUpdate\r\n\t\t\t\t: this.getState()\r\n\r\n\t\t\tconst shouldRestoreScrollPosition = firstShownItemIndex === 0 &&\r\n\t\t\t\t// `preserveScrollPosition` option name is deprecated,\r\n\t\t\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\t\t\t(options.preserveScrollPositionOnPrependItems || options.preserveScrollPosition)\r\n\r\n\t\t\tconst {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t} = itemsDiff\r\n\r\n\t\t\tlet shouldResetGridLayout\r\n\r\n\t\t\tlayoutUpdate = this.layout.getLayoutUpdateForItemsDiff({\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tafterItemsHeight\r\n\t\t\t}, {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t}, {\r\n\t\t\t\titemsCount: newItems.length,\r\n\t\t\t\tcolumnsCount: this.getActualColumnsCount(),\r\n\t\t\t\tshouldRestoreScrollPosition,\r\n\t\t\t\tonResetGridLayout: () => shouldResetGridLayout = true\r\n\t\t\t})\r\n\r\n\t\t\tif (prependedItemsCount > 0) {\r\n\t\t\t\tlog('Prepend', prependedItemsCount, 'items')\r\n\r\n\t\t\t\titemHeights = new Array(prependedItemsCount)\r\n\t\t\t\t\t.concat(itemHeights)\r\n\r\n\t\t\t\titemStates = fillArray(\r\n\t\t\t\t\tnew Array(prependedItemsCount),\r\n\t\t\t\t\t(i) => this.getInitialItemState(newItems[i])\r\n\t\t\t\t)\r\n\t\t\t\t\t.concat(itemStates)\r\n\r\n\t\t\t\t// Restore scroll position after prepending items (if requested).\r\n\t\t\t\tif (shouldRestoreScrollPosition) {\r\n\t\t\t\t\tlog('Will restore scroll position')\r\n\t\t\t\t\tthis.listHeightMeasurement.snapshotListHeightBeforeAddingNewItems({\r\n\t\t\t\t\t\tpreviousItems,\r\n\t\t\t\t\t\tnewItems,\r\n\t\t\t\t\t\tprependedItemsCount\r\n\t\t\t\t\t})\r\n\t\t\t\t\t// \"Seamless prepend\" scenario doesn't result in a re-layout,\r\n\t\t\t\t\t// so if any \"non measured item\" is currently pending,\r\n\t\t\t\t\t// it doesn't get reset and will be handled after `state` is updated.\r\n\t\t\t\t\tif (this.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\t\t\t\tthis.firstNonMeasuredItemIndex += prependedItemsCount\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tlog('Reset layout')\r\n\t\t\t\t\tif (shouldResetGridLayout) {\r\n\t\t\t\t\t\tlog('Reason: Prepended items count', prependedItemsCount, 'is not divisible by Columns Count', this.getActualColumnsCount())\r\n\t\t\t\t\t\t// Reset item heights because the whole grid is going to be rebalanced\r\n\t\t\t\t\t\t// and re-rendered in a different configuration.\r\n\t\t\t\t\t\titemHeights = new Array(newItems.length)\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\t// Reset layout because none of the prepended items have been measured.\r\n\t\t\t\t\t\tlog('Reason: Prepended items\\' heights are unknown')\r\n\t\t\t\t\t}\r\n\t\t\t\t\tlayoutUpdate = this.layout.getInitialLayoutValues({\r\n\t\t\t\t\t\titemsCount: newItems.length,\r\n\t\t\t\t\t\tcolumnsCount: this.getActualColumnsCount()\r\n\t\t\t\t\t})\r\n\t\t\t\t\t// Unschedule a potentially scheduled layout update\r\n\t\t\t\t\t// after measuring a previously non-measured item\r\n\t\t\t\t\t// because the list will be re-layout anyway\r\n\t\t\t\t\t// due to the new items being set.\r\n\t\t\t\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (appendedItemsCount > 0) {\r\n\t\t\t\tlog('Append', appendedItemsCount, 'items')\r\n\t\t\t\titemHeights = itemHeights.concat(new Array(appendedItemsCount))\r\n\t\t\t\titemStates = itemStates.concat(\r\n\t\t\t\t\tfillArray(\r\n\t\t\t\t\t\tnew Array(appendedItemsCount),\r\n\t\t\t\t\t\t(i) => this.getInitialItemState(newItems[prependedItemsCount + previousItems.length + i])\r\n\t\t\t\t\t)\r\n\t\t\t\t)\r\n\t\t\t}\r\n\r\n\t\t\titemsUpdateInfo = {\r\n\t\t\t\tprepend: prependedItemsCount > 0,\r\n\t\t\t\tappend: appendedItemsCount > 0\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tlog('Items have changed, and', (itemsDiff ? 'a re-layout from scratch has been requested.' : 'it\\'s not a simple append and/or prepend.'), 'Rerender the entire list from scratch.')\r\n\t\t\tlog('Previous items', previousItems)\r\n\t\t\tlog('New items', newItems)\r\n\r\n\t\t\t// Reset item heights and item states.\r\n\t\t\titemHeights = new Array(newItems.length)\r\n\t\t\titemStates = fillArray(\r\n\t\t\t\tnew Array(newItems.length),\r\n\t\t\t\t(i) => this.getInitialItemState(newItems[i])\r\n\t\t\t)\r\n\r\n\t\t\tlayoutUpdate = this.layout.getInitialLayoutValues({\r\n\t\t\t\titemsCount: newItems.length,\r\n\t\t\t\tcolumnsCount: this.getActualColumnsCount()\r\n\t\t\t})\r\n\r\n\t\t\t// Unschedule a potentially scheduled layout update\r\n\t\t\t// after measuring a previously non-measured item\r\n\t\t\t// because the list will be re-layout from scratch\r\n\t\t\t// due to the new items being set.\r\n\t\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\r\n\t\t\t// Also reset any potential pending scroll position restoration.\r\n\t\t\t// For example, imagine a developer first called `.setItems(incrementalItemsUpdate)`\r\n\t\t\t// and then called `.setItems(differentItems)` and there was no state update\r\n\t\t\t// in between those two calls. This could happen because state updates aren't\r\n\t\t\t// required to be \"synchronous\". On other words, calling `this.updateState()`\r\n\t\t\t// doesn't necessarily mean that the state is applied immediately.\r\n\t\t\t// Imagine also that such \"delayed\" state updates could be batched,\r\n\t\t\t// like they do in React inside event handlers (though that doesn't apply to this case):\r\n\t\t\t// https://github.com/facebook/react/issues/10231#issuecomment-316644950\r\n\t\t\t// If `this.listHeightMeasurement` wasn't reset on `.setItems(differentItems)`\r\n\t\t\t// and if the second `this.updateState()` call overwrites the first one\r\n\t\t\t// then it would attempt to restore scroll position in a situation when\r\n\t\t\t// it should no longer do that. Hence the reset here.\r\n\t\t\tthis.listHeightMeasurement.reset()\r\n\r\n\t\t\titemsUpdateInfo = {\r\n\t\t\t\treplace: true\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlog('~ Update state ~')\r\n\r\n\t\t// const layoutValuesAfterUpdate = {\r\n\t\t// \t...this.getState(),\r\n\t\t// \t...layoutUpdate\r\n\t\t// }\r\n\r\n\t\t// `layoutUpdate` is equivalent to `layoutValuesAfterUpdate` because\r\n\t\t// `layoutUpdate` contains all the relevant properties.\r\n\t\tlog('First shown item index', layoutUpdate.firstShownItemIndex)\r\n\t\tlog('Last shown item index', layoutUpdate.lastShownItemIndex)\r\n\t\tlog('Before items height', layoutUpdate.beforeItemsHeight)\r\n\t\tlog('After items height (actual or estimated)', layoutUpdate.afterItemsHeight)\r\n\r\n\t\t// Optionally preload items to be rendered.\r\n\t\t//\r\n\t\t// `layoutUpdate` is equivalent to `layoutValuesAfterUpdate` because\r\n\t\t// `layoutUpdate` contains all the relevant properties.\r\n\t\t//\r\n\t\tthis.onBeforeShowItems(\r\n\t\t\tnewItems,\r\n\t\t\titemHeights,\r\n\t\t\tlayoutUpdate.firstShownItemIndex,\r\n\t\t\tlayoutUpdate.lastShownItemIndex\r\n\t\t)\r\n\r\n\t\t// `this.newItemsWillBeRendered` signals that new `items` are being rendered,\r\n\t\t// and that `VirtualScroller` should temporarily stop all other updates.\r\n\t\t//\r\n\t\t// `this.newItemsWillBeRendered` is cleared in `onRender()`.\r\n\t\t//\r\n\t\t// The values in `this.newItemsWillBeRendered` are used, for example,\r\n\t\t// in `.onContainerResize()` handler in order to not break state consistency when\r\n\t\t// state updates are \"asynchronous\" (delayed) and there's a window resize event\r\n\t\t// in between calling `updateState()` below and that call actually being applied.\r\n\t\t//\r\n\t\tthis.newItemsWillBeRendered = {\r\n\t\t\t...itemsUpdateInfo,\r\n\t\t\tcount: newItems.length,\r\n\t\t\t// `layoutUpdate` now contains all layout-related properties, even if those that\r\n\t\t\t// didn't change. So `firstShownItemIndex` is always in `this.newItemsWillBeRendered`.\r\n\t\t\tlayout: layoutUpdate\r\n\t\t}\r\n\r\n\t\t// `layoutUpdate` now contains all layout-related properties, even if those that\r\n\t\t// didn't change. So this part is no longer relevant.\r\n\t\t//\r\n\t\t// // If `firstShownItemIndex` is gonna be modified as a result of setting new items\r\n\t\t// // then keep that \"new\" `firstShownItemIndex` in order for it to be used by\r\n\t\t// // `onResize()` handler when it calculates \"new\" `firstShownItemIndex`\r\n\t\t// // based on the new columns count (corresponding to the new window width).\r\n\t\t// if (layoutUpdate.firstShownItemIndex !== undefined) {\r\n\t\t// \tthis.newItemsWillBeRendered = {\r\n\t\t// \t\t...this.newItemsWillBeRendered,\r\n\t\t// \t\tfirstShownItemIndex: layoutUpdate.firstShownItemIndex\r\n\t\t// \t}\r\n\t\t// }\r\n\r\n\t\t// Update `VirtualScroller` state.\r\n\t\t//\r\n\t\t// This state update should overwrite all the `state` properties\r\n\t\t// that are also updated in the \"on scroll\" handler (`getShownItemIndexes()`):\r\n\t\t//\r\n\t\t// * `firstShownItemIndex`\r\n\t\t// * `lastShownItemIndex`\r\n\t\t// * `beforeItemsHeight`\r\n\t\t// * `afterItemsHeight`\r\n\t\t//\r\n\t\t// That's because this `updateState()` update has a higher priority\r\n\t\t// than that of the \"on scroll\" handler, so it should overwrite\r\n\t\t// any potential state changes dispatched by the \"on scroll\" handler.\r\n\t\t//\r\n\t\tconst newState = {\r\n\t\t\t...layoutUpdate,\r\n\t\t\titems: newItems,\r\n\t\t\titemStates,\r\n\t\t\titemHeights\r\n\t\t}\r\n\r\n\t\t// Introduced `shouldIncludeBeforeResizeValuesInState()` getter just to prevent\r\n\t\t// cluttering `state` with `beforeResize: undefined` property if `beforeResize`\r\n\t\t// hasn't ever been set in `state` previously.\r\n\t\tif (this.beforeResize.shouldIncludeBeforeResizeValuesInState()) {\r\n\t\t\tif (this.shouldDiscardBeforeResizeItemHeights()) {\r\n\t\t\t\t// Reset \"before resize\" item heights because now there're new items prepended\r\n\t\t\t\t// with unknown heights, or completely new items with unknown heights, so\r\n\t\t\t\t// `beforeItemsHeight` value won't be preserved anyway.\r\n\t\t\t\tnewState.beforeResize = undefined\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\t// Overwrite `beforeResize` property in `state` even if it wasn't modified\r\n\t\t\t\t// because state updates could be \"asynchronous\" and in that case there could be\r\n\t\t\t\t// some previous `updateState()` call from some previous `setItems()` call that\r\n\t\t\t\t// hasn't yet been applied, and that previous call might have scheduled setting\r\n\t\t\t\t// `state.beforeResize` property to `undefined` in order to reset it, but this\r\n\t\t\t\t// next `updateState()` call might not require resetting `state.beforeResize` property\r\n\t\t\t\t// so it should undo resetting it by simply overwriting it with its normal value.\r\n\t\t\t\tnewState.beforeResize = this.widthHasChanged\r\n\t\t\t\t\t? this.widthHasChanged.stateUpdate.beforeResize\r\n\t\t\t\t\t: this.getState().beforeResize\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `newState` should also overwrite all `state` properties that're updated in `onResize()`\r\n\t\t// because `setItems()`'s state updates always overwrite `onResize()`'s state updates.\r\n\t\t// (The least-priority ones are `onScroll()` state updates, but those're simply skipped\r\n\t\t// if there's a pending `setItems()` or `onResize()` update).\r\n\t\t//\r\n\t\t// `state` property exceptions:\r\n\t\t//\r\n\t\t// `verticalSpacing` property is not updated here because it's fine setting it to\r\n\t\t// `undefined` in `onResize()` — it will simply be re-measured after the component re-renders.\r\n\t\t//\r\n\t\t// `columnsCount` property is also not updated here because by definition it's only\r\n\t\t// updated in `onResize()`.\r\n\r\n\t\t// Render.\r\n\t\tthis._isSettingNewItems = true\r\n\t\tthis.updateState(newState)\r\n\t}\r\n\r\n\tthis.getItemsDiff = (previousItems, newItems) => {\r\n\t\treturn getItemsDiff(previousItems, newItems, this.isItemEqual)\r\n\t}\r\n}"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;;;AAEe,oBAAW;EAAA;;EACzB,KAAKA,aAAL,GAAqB,YAAM;IAC1B,OAAO,KAAI,CAACC,QAAL,GAAgBC,KAAhB,CAAsBC,MAA7B;EACA,CAFD;;EAIA,KAAKC,0BAAL,GAAkC,UAACC,WAAD,EAAiB;IAClD,IAAMC,IAAI,GAAGD,WAAb;;IACA,qBAAkB,KAAI,CAACJ,QAAL,EAAl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,CAACC,YAAT,GAAwB,KAAI,CAACzC,eAAL,GACrB,KAAI,CAACA,eAAL,CAAqBC,WAArB,CAAiCwC,YADZ,GAErB,KAAI,CAACzD,QAAL,GAAgByD,YAFnB;MAGA;IACD,CAlR2C,CAoR5C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;;;IACA,KAAI,CAACG,kBAAL,GAA0B,IAA1B;;IACA,KAAI,CAACC,WAAL,CAAiBL,QAAjB;EACA,CApSD;;EAsSA,KAAKjC,YAAL,GAAoB,UAACT,aAAD,EAAgBF,QAAhB,EAA6B;IAChD,OAAO,IAAAW,wBAAA,EAAaT,aAAb,EAA4BF,QAA5B,EAAsC,KAAI,CAACkD,WAA3C,CAAP;EACA,CAFD;AAGA"}
|
|
@@ -229,10 +229,19 @@ var VirtualScroller = /*#__PURE__*/function () {
|
|
|
229
229
|
value:
|
|
230
230
|
/**
|
|
231
231
|
* Returns the items's top offset relative to the scrollable container's top edge.
|
|
232
|
-
* @param {
|
|
232
|
+
* @param {any} item — Item
|
|
233
233
|
* @return {[number]} Returns the item's scroll Y position. Returns `undefined` if any of the previous items haven't been rendered yet.
|
|
234
234
|
*/
|
|
235
|
-
function getItemScrollPosition(
|
|
235
|
+
function getItemScrollPosition(itemOrIndex) {
|
|
236
|
+
// Item index.
|
|
237
|
+
var i = this._getItemIndexByItemOrIndex(itemOrIndex); // If the item wasn't found, the error was already reported,
|
|
238
|
+
// so just return some "sensible" default value.
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
if (i === undefined) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
236
245
|
var itemTopOffsetInList = this.layout.getItemTopOffset(i);
|
|
237
246
|
|
|
238
247
|
if (itemTopOffsetInList === undefined) {
|
|
@@ -248,32 +257,32 @@ var VirtualScroller = /*#__PURE__*/function () {
|
|
|
248
257
|
|
|
249
258
|
}, {
|
|
250
259
|
key: "onItemHeightChange",
|
|
251
|
-
value: function onItemHeightChange(
|
|
252
|
-
(0, _debug.warn)('`.onItemHeightChange(
|
|
253
|
-
this.onItemHeightDidChange(
|
|
260
|
+
value: function onItemHeightChange(item) {
|
|
261
|
+
(0, _debug.warn)('`.onItemHeightChange(item)` method was renamed to `.onItemHeightDidChange(item)`');
|
|
262
|
+
this.onItemHeightDidChange(item);
|
|
254
263
|
}
|
|
255
264
|
/**
|
|
256
265
|
* Forces a re-measure of an item's height.
|
|
257
|
-
* @param
|
|
266
|
+
* @param {any} item — Item. Legacy argument variant: Item index.
|
|
258
267
|
*/
|
|
259
268
|
|
|
260
269
|
}, {
|
|
261
270
|
key: "onItemHeightDidChange",
|
|
262
|
-
value: function onItemHeightDidChange(
|
|
271
|
+
value: function onItemHeightDidChange(itemOrIndex) {
|
|
263
272
|
// See the comments in the `setItemState()` function below for the rationale
|
|
264
273
|
// on why the `hasToBeStarted()` check was commented out.
|
|
265
274
|
// this.hasToBeStarted()
|
|
266
|
-
this._onItemHeightDidChange(
|
|
275
|
+
this._onItemHeightDidChange(itemOrIndex);
|
|
267
276
|
}
|
|
268
277
|
/**
|
|
269
278
|
* Updates an item's state in `state.itemStates[]`.
|
|
270
|
-
* @param {
|
|
271
|
-
* @param {any}
|
|
279
|
+
* @param {any} item — Item. Legacy argument variant: Item index.
|
|
280
|
+
* @param {any} newItemState — Item's new state
|
|
272
281
|
*/
|
|
273
282
|
|
|
274
283
|
}, {
|
|
275
284
|
key: "setItemState",
|
|
276
|
-
value: function setItemState(
|
|
285
|
+
value: function setItemState(itemOrIndex, newItemState) {
|
|
277
286
|
// There is an issue in React 18.2.0 when `useInsertionEffect()` doesn't run twice
|
|
278
287
|
// on mount unlike `useLayoutEffect()` in "strict" mode. That causes a bug in a React
|
|
279
288
|
// implementation of the `virtual-scroller`.
|
|
@@ -316,14 +325,14 @@ var VirtualScroller = /*#__PURE__*/function () {
|
|
|
316
325
|
// Commenting it out wouldn't result in any potential bugs because the code would work correctly
|
|
317
326
|
// in both cases.
|
|
318
327
|
// this.hasToBeStarted()
|
|
319
|
-
this._setItemState(
|
|
328
|
+
this._setItemState(itemOrIndex, newItemState);
|
|
320
329
|
} // (deprecated)
|
|
321
330
|
// Use `.setItemState()` method name instead.
|
|
322
331
|
|
|
323
332
|
}, {
|
|
324
333
|
key: "onItemStateChange",
|
|
325
|
-
value: function onItemStateChange(
|
|
326
|
-
this.setItemState(
|
|
334
|
+
value: function onItemStateChange(item, newItemState) {
|
|
335
|
+
this.setItemState(item, newItemState);
|
|
327
336
|
}
|
|
328
337
|
/**
|
|
329
338
|
* Updates `items`. For example, can prepend or append new items to the list.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualScroller.js","names":["VirtualScroller","getItemsContainerElement","items","options","_isActive","Error","log","scrollableContainerResizeHandler","stop","scroll","listTopOffsetWatcher","isStarted","cancelLayoutTimer","hasToBeStarted","onUpdateShownItemIndexes","reason","LAYOUT_REASON","MANUAL","_onRender","getState","previousState","VirtualScrollerConstructor","call","isRestart","setUpState","waitingForRender","_render","listHeightMeasurement","reset","_isResizing","undefined","_isSettingNewItems","isInBypassMode","isItemsContainerElementTableBody","supportsTbody","hasTbodyStyles","addTbodyStyles","reportError","BROWSER_NOT_SUPPORTED_ERROR","_bypass","stateUpdate","_afterRenderStateUpdateThatWasStopped","verticalSpacing","verticalSpacingStateUpdate","measureItemHeightsAndSpacing","start","scrollableContainerWidth","scrollableContainer","getWidth","newWidth","prevWidth","onContainerResize","_usesCustomStateStorage","columnsCount","getActualColumnsCount","columnsCountFromState","STARTED","i","itemTopOffsetInList","layout","getItemTopOffset","getListTopOffsetInsideScrollableContainer","warn","onItemHeightDidChange","_onItemHeightDidChange","newItemState","_setItemState","setItemState","newItems","_setItems"],"sources":["../source/VirtualScroller.js"],"sourcesContent":["import VirtualScrollerConstructor from './VirtualScroller.constructor.js'\r\nimport { LAYOUT_REASON } from './Layout.js'\r\nimport log, { warn, reportError } from './utility/debug.js'\r\n\r\nimport {\r\n\tsupportsTbody,\r\n\thasTbodyStyles,\r\n\taddTbodyStyles,\r\n\tBROWSER_NOT_SUPPORTED_ERROR\r\n} from './DOM/tbody.js'\r\n\r\nexport default class VirtualScroller {\r\n\t/**\r\n\t * @param {function} getItemsContainerElement — Returns the items container DOM `Element`.\r\n\t * @param {any[]} items — The list of items.\r\n\t * @param {Object} [options] — See README.md.\r\n\t * @return {VirtualScroller}\r\n\t */\r\n\tconstructor(\r\n\t\tgetItemsContainerElement,\r\n\t\titems,\r\n\t\toptions = {}\r\n\t) {\r\n\t\tVirtualScrollerConstructor.call(\r\n\t\t\tthis,\r\n\t\t\tgetItemsContainerElement,\r\n\t\t\titems,\r\n\t\t\toptions\r\n\t\t)\r\n\t}\r\n\r\n\t/**\r\n\t * Should be invoked after a \"container\" DOM Element is mounted (inserted into the DOM tree).\r\n\t */\r\n\tstart() {\r\n\t\tif (this._isActive) {\r\n\t\t\tthrow new Error('[virtual-scroller] `VirtualScroller` has already been started')\r\n\t\t}\r\n\r\n\t\t// If has been stopped previously.\r\n\t\tconst isRestart = this._isActive === false\r\n\r\n\t\tif (!isRestart) {\r\n\t\t\tthis.setUpState()\r\n\t\t\tthis.waitingForRender = true\r\n\t\t\t// If `render()` function parameter was passed,\r\n\t\t\t// perform an initial render.\r\n\t\t\tif (this._render) {\r\n\t\t\t\tthis._render(this.getState())\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (isRestart) {\r\n\t\t\tlog('~ Start (restart) ~')\r\n\t\t} else {\r\n\t\t\tlog('~ Start ~')\r\n\t\t}\r\n\r\n\t\t// `this._isActive = true` should be placed somewhere at the start of this function.\r\n\t\tthis._isActive = true\r\n\r\n\t\t// Reset `ListHeightMeasurement` just in case it has some \"leftover\" state.\r\n\t\tthis.listHeightMeasurement.reset()\r\n\r\n\t\t// Reset `_isResizing` flag just in case it has some \"leftover\" value.\r\n\t\tthis._isResizing = undefined\r\n\r\n\t\t// Reset `_isSettingNewItems` flag just in case it has some \"leftover\" value.\r\n\t\tthis._isSettingNewItems = undefined\r\n\r\n\t\t// When `<tbody/>` is used as an items container element,\r\n\t\t// `virtual-scroller` has to work around the HTML bug of\r\n\t\t// `padding` not working on a `<tbody/>` element.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1\r\n\t\tif (!this.isInBypassMode()) {\r\n\t\t\tif (this.isItemsContainerElementTableBody()) {\r\n\t\t\t\tif (supportsTbody()) {\r\n\t\t\t\t\tif (!hasTbodyStyles(this.getItemsContainerElement())) {\r\n\t\t\t\t\t\tlog('~ <tbody/> container ~')\r\n\t\t\t\t\t\taddTbodyStyles(this.getItemsContainerElement())\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tlog('~ <tbody/> container not supported ~')\r\n\t\t\t\t\treportError(BROWSER_NOT_SUPPORTED_ERROR)\r\n\t\t\t\t\tlog('~ enter \"bypass\" mode ~')\r\n\t\t\t\t\tthis._bypass = true\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If there was a pending \"after render\" state update that didn't get applied\r\n\t\t// because the `VirtualScroller` got stopped, then apply that pending \"after render\"\r\n\t\t// state update now. Such state update could include properties like:\r\n\t\t// * A `verticalSpacing` that has been measured in `onRender()`.\r\n\t\t// * A cleaned-up `beforeResize` object that was cleaned-up in `onRender()`.\r\n\t\tlet stateUpdate = this._afterRenderStateUpdateThatWasStopped\r\n\t\tthis._afterRenderStateUpdateThatWasStopped = undefined\r\n\r\n\t\t// Reset `this.verticalSpacing` so that it re-measures it in cases when\r\n\t\t// the `VirtualScroller` was previously stopped and is now being restarted.\r\n\t\t// The rationale is that a previously captured inter-item vertical spacing\r\n\t\t// can't be \"trusted\" in a sense that the user might have resized the window\r\n\t\t// after the previous `state` has been snapshotted.\r\n\t\t// If the user has resized the window, then changing window width might have\r\n\t\t// activated different CSS `@media()` \"queries\" resulting in a potentially different\r\n\t\t// vertical spacing after the restart.\r\n\t\t// If it's not a restart then `this.verticalSpacing` is `undefined` anyway.\r\n\t\tthis.verticalSpacing = undefined\r\n\r\n\t\tconst verticalSpacingStateUpdate = this.measureItemHeightsAndSpacing()\r\n\t\tif (verticalSpacingStateUpdate) {\r\n\t\t\tstateUpdate = {\r\n\t\t\t\t...stateUpdate,\r\n\t\t\t\t...verticalSpacingStateUpdate\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.scrollableContainerResizeHandler.start()\r\n\t\tthis.scroll.start()\r\n\r\n\t\t// If `scrollableContainerWidth` hasn't been measured yet,\r\n\t\t// measure it and write it to state.\r\n\t\tif (this.getState().scrollableContainerWidth === undefined) {\r\n\t\t\tconst scrollableContainerWidth = this.scrollableContainer.getWidth()\r\n\t\t\tstateUpdate = {\r\n\t\t\t\t...stateUpdate,\r\n\t\t\t\tscrollableContainerWidth\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t// Reset layout:\r\n\t\t\t// * If the scrollable container width has changed while stopped.\r\n\t\t\t// * If the restored state was calculated for another scrollable container width.\r\n\t\t\tconst newWidth = this.scrollableContainer.getWidth()\r\n\t\t\tconst prevWidth = this.getState().scrollableContainerWidth\r\n\t\t\tif (newWidth !== prevWidth) {\r\n\t\t\t\tlog('~ Scrollable container width changed from', prevWidth, 'to', newWidth, '~')\r\n\t\t\t\t// The pending state update (if present) won't be applied in this case.\r\n\t\t\t\t// That's ok because such state update could currently only originate in\r\n\t\t\t\t// `this.onContainerResize()` function. Therefore, alling `this.onContainerResize()` again\r\n\t\t\t\t// would rewrite all those `stateUpdate` properties anyway, so they're not passed.\r\n\t\t\t\treturn this.onContainerResize()\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If the `VirtualScroller` uses custom (external) state storage, then\r\n\t\t// check if the columns count has changed between calling `.getInitialState()`\r\n\t\t// and `.start()`. If it has, perform a re-layout \"from scratch\".\r\n\t\tif (this._usesCustomStateStorage) {\r\n\t\t\tconst columnsCount = this.getActualColumnsCount()\r\n\t\t\tconst columnsCountFromState = this.getState().columnsCount || 1\r\n\t\t\tif (columnsCount !== columnsCountFromState) {\r\n\t\t\t\treturn this.onContainerResize()\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Re-calculate layout and re-render the list.\r\n\t\t// Do that even if when an initial `state` parameter, containing layout values,\r\n\t\t// has been passed. The reason is that the `state` parameter can't be \"trusted\"\r\n\t\t// in a way that it could have been snapshotted for another window width and\r\n\t\t// the user might have resized their window since then.\r\n\t\tthis.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.STARTED, stateUpdate })\r\n\t}\r\n\r\n\t// Could be passed as a \"callback\" parameter, so bind it to `this`.\r\n\tstop = () => {\r\n\t\tif (!this._isActive) {\r\n\t\t\tthrow new Error('[virtual-scroller] Can\\'t stop a `VirtualScroller` that hasn\\'t been started')\r\n\t\t}\r\n\r\n\t\tthis._isActive = false\r\n\r\n\t\tlog('~ Stop ~')\r\n\r\n\t\tthis.scrollableContainerResizeHandler.stop()\r\n\t\tthis.scroll.stop()\r\n\r\n\t\t// Stop `ListTopOffsetWatcher` if it has been started.\r\n\t\t// There seems to be no need to restart `ListTopOffsetWatcher`.\r\n\t\t// It's mainly a hacky workaround for development mode anyway.\r\n\t\tif (this.listTopOffsetWatcher && this.listTopOffsetWatcher.isStarted()) {\r\n\t\t\tthis.listTopOffsetWatcher.stop()\r\n\t\t}\r\n\r\n\t\t// Cancel any scheduled layout.\r\n\t\tthis.cancelLayoutTimer({})\r\n\t}\r\n\r\n\thasToBeStarted() {\r\n\t\tif (!this._isActive) {\r\n\t\t\tthrow new Error('[virtual-scroller] `VirtualScroller` hasn\\'t been started')\r\n\t\t}\r\n\t}\r\n\r\n\t// Bind it to `this` because this function could hypothetically be passed\r\n\t// as a \"callback\" parameter.\r\n\tupdateLayout = () => {\r\n\t\tthis.hasToBeStarted()\r\n\t\tthis.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.MANUAL })\r\n\t}\r\n\r\n\t// Bind the function to `this` so that it could be passed as a callback\r\n\t// in a random application's code.\r\n\tonRender = () => {\r\n\t\tthis._onRender(this.getState(), this.previousState)\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the items's top offset relative to the scrollable container's top edge.\r\n\t * @param {number} i — Item index\r\n\t * @return {[number]} Returns the item's scroll Y position. Returns `undefined` if any of the previous items haven't been rendered yet.\r\n\t */\r\n\tgetItemScrollPosition(i) {\r\n\t\tconst itemTopOffsetInList = this.layout.getItemTopOffset(i)\r\n\t\tif (itemTopOffsetInList === undefined) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\treturn this.getListTopOffsetInsideScrollableContainer() + itemTopOffsetInList\r\n\t}\r\n\r\n\t/**\r\n\t * @deprecated\r\n\t * `.onItemHeightChange()` has been renamed to `.onItemHeightDidChange()`.\r\n\t */\r\n\tonItemHeightChange(i) {\r\n\t\twarn('`.onItemHeightChange(i)` method was renamed to `.onItemHeightDidChange(i)`')\r\n\t\tthis.onItemHeightDidChange(i)\r\n\t}\r\n\r\n\t/**\r\n\t * Forces a re-measure of an item's height.\r\n\t * @param {number} i — Item index\r\n\t */\r\n\tonItemHeightDidChange(i) {\r\n\t\t// See the comments in the `setItemState()` function below for the rationale\r\n\t\t// on why the `hasToBeStarted()` check was commented out.\r\n\t\t// this.hasToBeStarted()\r\n\t\tthis._onItemHeightDidChange(i)\r\n\t}\r\n\r\n\t/**\r\n\t * Updates an item's state in `state.itemStates[]`.\r\n\t * @param {number} i — Item index\r\n\t * @param {any} i — Item's new state\r\n\t */\r\n\tsetItemState(i, newItemState) {\r\n\t\t// There is an issue in React 18.2.0 when `useInsertionEffect()` doesn't run twice\r\n\t\t// on mount unlike `useLayoutEffect()` in \"strict\" mode. That causes a bug in a React\r\n\t\t// implementation of the `virtual-scroller`.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/33\r\n\t\t// https://github.com/facebook/react/issues/26320\r\n\t\t// A workaround for that bug is ignoring the second-initial run of the effects at mount.\r\n\t\t//\r\n\t\t// But in that case, if an `ItemComponent` calls `setItemState()` in `useLayoutEffect()`,\r\n\t\t// it could result in a bug.\r\n\t\t//\r\n\t\t// Consider a type of `useLayoutEffect()` that skips the initial mount:\r\n\t\t// `useLayoutEffectSkipInitialMount()`.\r\n\t\t// Suppose that effect is written in such a way that it only skips the first call of itself.\r\n\t\t// In that case, if React is run in \"strict\" mode, the effect will no longer work as expected\r\n\t\t// and it won't actually skip the initial mount and will be executed during the second initial run.\r\n\t\t// But the `VirtualScroller` itself has already implemented a workaround that prevents\r\n\t\t// its hooks from running twice on mount. This means that `useVirtualScrollerStartStop()`\r\n\t\t// of the React component would have already stopped the `VirtualScroller` by the time\r\n\t\t// `ItemComponent`'s incorrectly-behaving `useLayoutEffectSkipInitialMount()` effect is run,\r\n\t\t// resulting in an error: \"`VirtualScroller` hasn't been started\".\r\n\t\t//\r\n\t\t// The log when not in \"strict\" mode would be:\r\n\t\t//\r\n\t\t// * `useLayoutEffect()` is run in `ItemComponent` — skips the initial run.\r\n\t\t// * `useLayoutEffect()` is run in `useVirtualScrollerStartStop()`. It starts the `VirtualScroller`.\r\n\t\t// * Some dependency property gets updated inside `ItemComponent`.\r\n\t\t// * `useLayoutEffect()` is run in `ItemComponent` — no longer skips. Calls `setItemState()`.\r\n\t\t// * The `VirtualScroller` is started so it handles `setState()` correctly.\r\n\t\t//\r\n\t\t// The log when in \"strict\" mode would be:\r\n\t\t//\r\n\t\t// * `useLayoutEffect()` is run in `ItemComponent` — skips the initial run.\r\n\t\t// * `useLayoutEffect()` is run in `useVirtualScrollerStartStop()`. It starts the `VirtualScroller`.\r\n\t\t// * `useLayoutEffect()` is unmounted in `useVirtualScrollerStartStop()`. It stops the `VirtualScroller`.\r\n\t\t// * `useLayoutEffect()` is unmounted in `ItemComponent` — does nothing.\r\n\t\t// * `useLayoutEffect()` is run the second time in `ItemComponent` — no longer skips. Calls `setItemState()`.\r\n\t\t// * The `VirtualScroller` is stopped so it throws an error: \"`VirtualScroller` hasn't been started\".\r\n\t\t//\r\n\t\t// For that reason, the requirement of the `VirtualScroller` to be started was commented out.\r\n\t\t// Commenting it out wouldn't result in any potential bugs because the code would work correctly\r\n\t\t// in both cases.\r\n\t\t// this.hasToBeStarted()\r\n\t\tthis._setItemState(i, newItemState)\r\n\t}\r\n\r\n\t// (deprecated)\r\n\t// Use `.setItemState()` method name instead.\r\n\tonItemStateChange(i, newItemState) {\r\n\t\tthis.setItemState(i, newItemState)\r\n\t}\r\n\r\n\t/**\r\n\t * Updates `items`. For example, can prepend or append new items to the list.\r\n\t * @param {any[]} newItems\r\n\t * @param {boolean} [options.preserveScrollPositionOnPrependItems] — Set to `true` to enable \"restore scroll position after prepending items\" feature (could be useful when implementing \"Show previous items\" button).\r\n\t */\r\n\tsetItems(newItems, options = {}) {\r\n\t\tthis.hasToBeStarted()\r\n\t\treturn this._setItems(newItems, options)\r\n\t}\r\n}"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;IAOqBA,e;EACpB;AACD;AACA;AACA;AACA;AACA;EACC,yBACCC,wBADD,EAECC,KAFD,EAIE;IAAA;;IAAA,IADDC,OACC,uEADS,EACT;;IAAA;;IAAA,8BA8IK,YAAM;MACZ,IAAI,CAAC,KAAI,CAACC,SAAV,EAAqB;QACpB,MAAM,IAAIC,KAAJ,CAAU,8EAAV,CAAN;MACA;;MAED,KAAI,CAACD,SAAL,GAAiB,KAAjB;MAEA,IAAAE,iBAAA,EAAI,UAAJ;;MAEA,KAAI,CAACC,gCAAL,CAAsCC,IAAtC;;MACA,KAAI,CAACC,MAAL,CAAYD,IAAZ,GAVY,CAYZ;MACA;MACA;;;MACA,IAAI,KAAI,CAACE,oBAAL,IAA6B,KAAI,CAACA,oBAAL,CAA0BC,SAA1B,EAAjC,EAAwE;QACvE,KAAI,CAACD,oBAAL,CAA0BF,IAA1B;MACA,CAjBW,CAmBZ;;;MACA,KAAI,CAACI,iBAAL,CAAuB,EAAvB;IACA,CAnKC;;IAAA,sCA6Ka,YAAM;MACpB,KAAI,CAACC,cA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ACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,KAAKC,aAAL,CAAmBT,CAAnB,EAAsBQ,YAAtB;IACA,C,CAED;IACA;;;;WACA,2BAAkBR,CAAlB,EAAqBQ,YAArB,EAAmC;MAClC,KAAKE,YAAL,CAAkBV,CAAlB,EAAqBQ,YAArB;IACA;IAED;AACD;AACA;AACA;AACA;;;;WACC,kBAASG,QAAT,EAAiC;MAAA,IAAdjE,OAAc,uEAAJ,EAAI;MAChC,KAAKU,cAAL;MACA,OAAO,KAAKwD,SAAL,CAAeD,QAAf,EAAyBjE,OAAzB,CAAP;IACA"}
|
|
1
|
+
{"version":3,"file":"VirtualScroller.js","names":["VirtualScroller","getItemsContainerElement","items","options","_isActive","Error","log","scrollableContainerResizeHandler","stop","scroll","listTopOffsetWatcher","isStarted","cancelLayoutTimer","hasToBeStarted","onUpdateShownItemIndexes","reason","LAYOUT_REASON","MANUAL","_onRender","getState","previousState","VirtualScrollerConstructor","call","isRestart","setUpState","waitingForRender","_render","listHeightMeasurement","reset","_isResizing","undefined","_isSettingNewItems","isInBypassMode","isItemsContainerElementTableBody","supportsTbody","hasTbodyStyles","addTbodyStyles","reportError","BROWSER_NOT_SUPPORTED_ERROR","_bypass","stateUpdate","_afterRenderStateUpdateThatWasStopped","verticalSpacing","verticalSpacingStateUpdate","measureItemHeightsAndSpacing","start","scrollableContainerWidth","scrollableContainer","getWidth","newWidth","prevWidth","onContainerResize","_usesCustomStateStorage","columnsCount","getActualColumnsCount","columnsCountFromState","STARTED","itemOrIndex","i","_getItemIndexByItemOrIndex","itemTopOffsetInList","layout","getItemTopOffset","getListTopOffsetInsideScrollableContainer","item","warn","onItemHeightDidChange","_onItemHeightDidChange","newItemState","_setItemState","setItemState","newItems","_setItems"],"sources":["../source/VirtualScroller.js"],"sourcesContent":["import VirtualScrollerConstructor from './VirtualScroller.constructor.js'\r\nimport { LAYOUT_REASON } from './Layout.js'\r\nimport log, { warn, reportError } from './utility/debug.js'\r\n\r\nimport {\r\n\tsupportsTbody,\r\n\thasTbodyStyles,\r\n\taddTbodyStyles,\r\n\tBROWSER_NOT_SUPPORTED_ERROR\r\n} from './DOM/tbody.js'\r\n\r\nexport default class VirtualScroller {\r\n\t/**\r\n\t * @param {function} getItemsContainerElement — Returns the items container DOM `Element`.\r\n\t * @param {any[]} items — The list of items.\r\n\t * @param {Object} [options] — See README.md.\r\n\t * @return {VirtualScroller}\r\n\t */\r\n\tconstructor(\r\n\t\tgetItemsContainerElement,\r\n\t\titems,\r\n\t\toptions = {}\r\n\t) {\r\n\t\tVirtualScrollerConstructor.call(\r\n\t\t\tthis,\r\n\t\t\tgetItemsContainerElement,\r\n\t\t\titems,\r\n\t\t\toptions\r\n\t\t)\r\n\t}\r\n\r\n\t/**\r\n\t * Should be invoked after a \"container\" DOM Element is mounted (inserted into the DOM tree).\r\n\t */\r\n\tstart() {\r\n\t\tif (this._isActive) {\r\n\t\t\tthrow new Error('[virtual-scroller] `VirtualScroller` has already been started')\r\n\t\t}\r\n\r\n\t\t// If has been stopped previously.\r\n\t\tconst isRestart = this._isActive === false\r\n\r\n\t\tif (!isRestart) {\r\n\t\t\tthis.setUpState()\r\n\t\t\tthis.waitingForRender = true\r\n\t\t\t// If `render()` function parameter was passed,\r\n\t\t\t// perform an initial render.\r\n\t\t\tif (this._render) {\r\n\t\t\t\tthis._render(this.getState())\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (isRestart) {\r\n\t\t\tlog('~ Start (restart) ~')\r\n\t\t} else {\r\n\t\t\tlog('~ Start ~')\r\n\t\t}\r\n\r\n\t\t// `this._isActive = true` should be placed somewhere at the start of this function.\r\n\t\tthis._isActive = true\r\n\r\n\t\t// Reset `ListHeightMeasurement` just in case it has some \"leftover\" state.\r\n\t\tthis.listHeightMeasurement.reset()\r\n\r\n\t\t// Reset `_isResizing` flag just in case it has some \"leftover\" value.\r\n\t\tthis._isResizing = undefined\r\n\r\n\t\t// Reset `_isSettingNewItems` flag just in case it has some \"leftover\" value.\r\n\t\tthis._isSettingNewItems = undefined\r\n\r\n\t\t// When `<tbody/>` is used as an items container element,\r\n\t\t// `virtual-scroller` has to work around the HTML bug of\r\n\t\t// `padding` not working on a `<tbody/>` element.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1\r\n\t\tif (!this.isInBypassMode()) {\r\n\t\t\tif (this.isItemsContainerElementTableBody()) {\r\n\t\t\t\tif (supportsTbody()) {\r\n\t\t\t\t\tif (!hasTbodyStyles(this.getItemsContainerElement())) {\r\n\t\t\t\t\t\tlog('~ <tbody/> container ~')\r\n\t\t\t\t\t\taddTbodyStyles(this.getItemsContainerElement())\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tlog('~ <tbody/> container not supported ~')\r\n\t\t\t\t\treportError(BROWSER_NOT_SUPPORTED_ERROR)\r\n\t\t\t\t\tlog('~ enter \"bypass\" mode ~')\r\n\t\t\t\t\tthis._bypass = true\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If there was a pending \"after render\" state update that didn't get applied\r\n\t\t// because the `VirtualScroller` got stopped, then apply that pending \"after render\"\r\n\t\t// state update now. Such state update could include properties like:\r\n\t\t// * A `verticalSpacing` that has been measured in `onRender()`.\r\n\t\t// * A cleaned-up `beforeResize` object that was cleaned-up in `onRender()`.\r\n\t\tlet stateUpdate = this._afterRenderStateUpdateThatWasStopped\r\n\t\tthis._afterRenderStateUpdateThatWasStopped = undefined\r\n\r\n\t\t// Reset `this.verticalSpacing` so that it re-measures it in cases when\r\n\t\t// the `VirtualScroller` was previously stopped and is now being restarted.\r\n\t\t// The rationale is that a previously captured inter-item vertical spacing\r\n\t\t// can't be \"trusted\" in a sense that the user might have resized the window\r\n\t\t// after the previous `state` has been snapshotted.\r\n\t\t// If the user has resized the window, then changing window width might have\r\n\t\t// activated different CSS `@media()` \"queries\" resulting in a potentially different\r\n\t\t// vertical spacing after the restart.\r\n\t\t// If it's not a restart then `this.verticalSpacing` is `undefined` anyway.\r\n\t\tthis.verticalSpacing = undefined\r\n\r\n\t\tconst verticalSpacingStateUpdate = this.measureItemHeightsAndSpacing()\r\n\t\tif (verticalSpacingStateUpdate) {\r\n\t\t\tstateUpdate = {\r\n\t\t\t\t...stateUpdate,\r\n\t\t\t\t...verticalSpacingStateUpdate\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.scrollableContainerResizeHandler.start()\r\n\t\tthis.scroll.start()\r\n\r\n\t\t// If `scrollableContainerWidth` hasn't been measured yet,\r\n\t\t// measure it and write it to state.\r\n\t\tif (this.getState().scrollableContainerWidth === undefined) {\r\n\t\t\tconst scrollableContainerWidth = this.scrollableContainer.getWidth()\r\n\t\t\tstateUpdate = {\r\n\t\t\t\t...stateUpdate,\r\n\t\t\t\tscrollableContainerWidth\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t// Reset layout:\r\n\t\t\t// * If the scrollable container width has changed while stopped.\r\n\t\t\t// * If the restored state was calculated for another scrollable container width.\r\n\t\t\tconst newWidth = this.scrollableContainer.getWidth()\r\n\t\t\tconst prevWidth = this.getState().scrollableContainerWidth\r\n\t\t\tif (newWidth !== prevWidth) {\r\n\t\t\t\tlog('~ Scrollable container width changed from', prevWidth, 'to', newWidth, '~')\r\n\t\t\t\t// The pending state update (if present) won't be applied in this case.\r\n\t\t\t\t// That's ok because such state update could currently only originate in\r\n\t\t\t\t// `this.onContainerResize()` function. Therefore, alling `this.onContainerResize()` again\r\n\t\t\t\t// would rewrite all those `stateUpdate` properties anyway, so they're not passed.\r\n\t\t\t\treturn this.onContainerResize()\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If the `VirtualScroller` uses custom (external) state storage, then\r\n\t\t// check if the columns count has changed between calling `.getInitialState()`\r\n\t\t// and `.start()`. If it has, perform a re-layout \"from scratch\".\r\n\t\tif (this._usesCustomStateStorage) {\r\n\t\t\tconst columnsCount = this.getActualColumnsCount()\r\n\t\t\tconst columnsCountFromState = this.getState().columnsCount || 1\r\n\t\t\tif (columnsCount !== columnsCountFromState) {\r\n\t\t\t\treturn this.onContainerResize()\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Re-calculate layout and re-render the list.\r\n\t\t// Do that even if when an initial `state` parameter, containing layout values,\r\n\t\t// has been passed. The reason is that the `state` parameter can't be \"trusted\"\r\n\t\t// in a way that it could have been snapshotted for another window width and\r\n\t\t// the user might have resized their window since then.\r\n\t\tthis.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.STARTED, stateUpdate })\r\n\t}\r\n\r\n\t// Could be passed as a \"callback\" parameter, so bind it to `this`.\r\n\tstop = () => {\r\n\t\tif (!this._isActive) {\r\n\t\t\tthrow new Error('[virtual-scroller] Can\\'t stop a `VirtualScroller` that hasn\\'t been started')\r\n\t\t}\r\n\r\n\t\tthis._isActive = false\r\n\r\n\t\tlog('~ Stop ~')\r\n\r\n\t\tthis.scrollableContainerResizeHandler.stop()\r\n\t\tthis.scroll.stop()\r\n\r\n\t\t// Stop `ListTopOffsetWatcher` if it has been started.\r\n\t\t// There seems to be no need to restart `ListTopOffsetWatcher`.\r\n\t\t// It's mainly a hacky workaround for development mode anyway.\r\n\t\tif (this.listTopOffsetWatcher && this.listTopOffsetWatcher.isStarted()) {\r\n\t\t\tthis.listTopOffsetWatcher.stop()\r\n\t\t}\r\n\r\n\t\t// Cancel any scheduled layout.\r\n\t\tthis.cancelLayoutTimer({})\r\n\t}\r\n\r\n\thasToBeStarted() {\r\n\t\tif (!this._isActive) {\r\n\t\t\tthrow new Error('[virtual-scroller] `VirtualScroller` hasn\\'t been started')\r\n\t\t}\r\n\t}\r\n\r\n\t// Bind it to `this` because this function could hypothetically be passed\r\n\t// as a \"callback\" parameter.\r\n\tupdateLayout = () => {\r\n\t\tthis.hasToBeStarted()\r\n\t\tthis.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.MANUAL })\r\n\t}\r\n\r\n\t// Bind the function to `this` so that it could be passed as a callback\r\n\t// in a random application's code.\r\n\tonRender = () => {\r\n\t\tthis._onRender(this.getState(), this.previousState)\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the items's top offset relative to the scrollable container's top edge.\r\n\t * @param {any} item — Item\r\n\t * @return {[number]} Returns the item's scroll Y position. Returns `undefined` if any of the previous items haven't been rendered yet.\r\n\t */\r\n\tgetItemScrollPosition(itemOrIndex) {\r\n\t\t// Item index.\r\n\t\tconst i = this._getItemIndexByItemOrIndex(itemOrIndex)\r\n\r\n\t\t// If the item wasn't found, the error was already reported,\r\n\t\t// so just return some \"sensible\" default value.\r\n\t\tif (i === undefined) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tconst itemTopOffsetInList = this.layout.getItemTopOffset(i)\r\n\t\tif (itemTopOffsetInList === undefined) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\treturn this.getListTopOffsetInsideScrollableContainer() + itemTopOffsetInList\r\n\t}\r\n\r\n\t/**\r\n\t * @deprecated\r\n\t * `.onItemHeightChange()` has been renamed to `.onItemHeightDidChange()`.\r\n\t */\r\n\tonItemHeightChange(item) {\r\n\t\twarn('`.onItemHeightChange(item)` method was renamed to `.onItemHeightDidChange(item)`')\r\n\t\tthis.onItemHeightDidChange(item)\r\n\t}\r\n\r\n\t/**\r\n\t * Forces a re-measure of an item's height.\r\n\t * @param {any} item — Item. Legacy argument variant: Item index.\r\n\t */\r\n\tonItemHeightDidChange(itemOrIndex) {\r\n\t\t// See the comments in the `setItemState()` function below for the rationale\r\n\t\t// on why the `hasToBeStarted()` check was commented out.\r\n\t\t// this.hasToBeStarted()\r\n\t\tthis._onItemHeightDidChange(itemOrIndex)\r\n\t}\r\n\r\n\t/**\r\n\t * Updates an item's state in `state.itemStates[]`.\r\n\t * @param {any} item — Item. Legacy argument variant: Item index.\r\n\t * @param {any} newItemState — Item's new state\r\n\t */\r\n\tsetItemState(itemOrIndex, newItemState) {\r\n\t\t// There is an issue in React 18.2.0 when `useInsertionEffect()` doesn't run twice\r\n\t\t// on mount unlike `useLayoutEffect()` in \"strict\" mode. That causes a bug in a React\r\n\t\t// implementation of the `virtual-scroller`.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/33\r\n\t\t// https://github.com/facebook/react/issues/26320\r\n\t\t// A workaround for that bug is ignoring the second-initial run of the effects at mount.\r\n\t\t//\r\n\t\t// But in that case, if an `ItemComponent` calls `setItemState()` in `useLayoutEffect()`,\r\n\t\t// it could result in a bug.\r\n\t\t//\r\n\t\t// Consider a type of `useLayoutEffect()` that skips the initial mount:\r\n\t\t// `useLayoutEffectSkipInitialMount()`.\r\n\t\t// Suppose that effect is written in such a way that it only skips the first call of itself.\r\n\t\t// In that case, if React is run in \"strict\" mode, the effect will no longer work as expected\r\n\t\t// and it won't actually skip the initial mount and will be executed during the second initial run.\r\n\t\t// But the `VirtualScroller` itself has already implemented a workaround that prevents\r\n\t\t// its hooks from running twice on mount. This means that `useVirtualScrollerStartStop()`\r\n\t\t// of the React component would have already stopped the `VirtualScroller` by the time\r\n\t\t// `ItemComponent`'s incorrectly-behaving `useLayoutEffectSkipInitialMount()` effect is run,\r\n\t\t// resulting in an error: \"`VirtualScroller` hasn't been started\".\r\n\t\t//\r\n\t\t// The log when not in \"strict\" mode would be:\r\n\t\t//\r\n\t\t// * `useLayoutEffect()` is run in `ItemComponent` — skips the initial run.\r\n\t\t// * `useLayoutEffect()` is run in `useVirtualScrollerStartStop()`. It starts the `VirtualScroller`.\r\n\t\t// * Some dependency property gets updated inside `ItemComponent`.\r\n\t\t// * `useLayoutEffect()` is run in `ItemComponent` — no longer skips. Calls `setItemState()`.\r\n\t\t// * The `VirtualScroller` is started so it handles `setState()` correctly.\r\n\t\t//\r\n\t\t// The log when in \"strict\" mode would be:\r\n\t\t//\r\n\t\t// * `useLayoutEffect()` is run in `ItemComponent` — skips the initial run.\r\n\t\t// * `useLayoutEffect()` is run in `useVirtualScrollerStartStop()`. It starts the `VirtualScroller`.\r\n\t\t// * `useLayoutEffect()` is unmounted in `useVirtualScrollerStartStop()`. It stops the `VirtualScroller`.\r\n\t\t// * `useLayoutEffect()` is unmounted in `ItemComponent` — does nothing.\r\n\t\t// * `useLayoutEffect()` is run the second time in `ItemComponent` — no longer skips. Calls `setItemState()`.\r\n\t\t// * The `VirtualScroller` is stopped so it throws an error: \"`VirtualScroller` hasn't been started\".\r\n\t\t//\r\n\t\t// For that reason, the requirement of the `VirtualScroller` to be started was commented out.\r\n\t\t// Commenting it out wouldn't result in any potential bugs because the code would work correctly\r\n\t\t// in both cases.\r\n\t\t// this.hasToBeStarted()\r\n\t\tthis._setItemState(itemOrIndex, newItemState)\r\n\t}\r\n\r\n\t// (deprecated)\r\n\t// Use `.setItemState()` method name instead.\r\n\tonItemStateChange(item, newItemState) {\r\n\t\tthis.setItemState(item, newItemState)\r\n\t}\r\n\r\n\t/**\r\n\t * Updates `items`. For example, can prepend or append new items to the list.\r\n\t * @param {any[]} newItems\r\n\t * @param {boolean} [options.preserveScrollPositionOnPrependItems] — Set to `true` to enable \"restore scroll position after prepending items\" feature (could be useful when implementing \"Show previous items\" button).\r\n\t */\r\n\tsetItems(newItems, options = {}) {\r\n\t\tthis.hasToBeStarted()\r\n\t\treturn this._setItems(newItems, options)\r\n\t}\r\n}"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;IAOqBA,e;EACpB;AACD;AACA;AACA;AACA;AACA;EACC,yBACCC,wBADD,EAECC,KAFD,EAIE;IAAA;;IAAA,IADDC,OACC,uEADS,EACT;;IAAA;;IAAA,8BA8IK,YAAM;MACZ,IAAI,CAAC,KAAI,CAACC,SAAV,EAAqB;QACpB,MAAM,IAAIC,KAAJ,CAAU,8EAAV,CAAN;MACA;;MAED,KAAI,CAACD,SAAL,GAAiB,KAAjB;MAEA,IAAAE,iBAAA,EAAI,UAAJ;;MAEA,KAAI,CAACC,gCAAL,CAAsCC,IAAtC;;MACA,KAAI,CAACC,MAAL,CAAYD,IAAZ,GAV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