virtual-scroller 1.12.3 → 1.12.4
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 +0 -2
- package/bundle/index-bypass.html +2 -2
- package/bundle/index-grid.html +2 -2
- package/bundle/index-scrollableContainer.html +2 -2
- 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/Layout.js +9 -12
- package/commonjs/Layout.js.map +1 -1
- package/commonjs/Layout.test.js +20 -10
- package/commonjs/Layout.test.js.map +1 -1
- package/commonjs/{Resize.js → ScrollableContainerResizeHandler.js} +7 -7
- package/commonjs/ScrollableContainerResizeHandler.js.map +1 -0
- package/commonjs/VirtualScroller.constructor.js +5 -5
- package/commonjs/VirtualScroller.constructor.js.map +1 -1
- package/commonjs/VirtualScroller.items.js +1 -1
- package/commonjs/VirtualScroller.items.js.map +1 -1
- package/commonjs/VirtualScroller.js +5 -5
- package/commonjs/VirtualScroller.js.map +1 -1
- package/commonjs/VirtualScroller.layout.js +8 -12
- package/commonjs/VirtualScroller.layout.js.map +1 -1
- package/commonjs/{VirtualScroller.resize.js → VirtualScroller.onContainerResize.js} +2 -2
- package/commonjs/VirtualScroller.onContainerResize.js.map +1 -0
- package/modules/Layout.js +9 -12
- package/modules/Layout.js.map +1 -1
- package/modules/Layout.test.js +20 -10
- package/modules/Layout.test.js.map +1 -1
- package/modules/{Resize.js → ScrollableContainerResizeHandler.js} +7 -7
- package/modules/ScrollableContainerResizeHandler.js.map +1 -0
- package/modules/VirtualScroller.constructor.js +5 -5
- package/modules/VirtualScroller.constructor.js.map +1 -1
- package/modules/VirtualScroller.items.js +1 -1
- package/modules/VirtualScroller.items.js.map +1 -1
- package/modules/VirtualScroller.js +5 -5
- package/modules/VirtualScroller.js.map +1 -1
- package/modules/VirtualScroller.layout.js +8 -12
- package/modules/VirtualScroller.layout.js.map +1 -1
- package/modules/{VirtualScroller.resize.js → VirtualScroller.onContainerResize.js} +2 -2
- package/modules/VirtualScroller.onContainerResize.js.map +1 -0
- package/package.json +1 -1
- package/source/Layout.js +9 -12
- package/source/Layout.test.js +20 -10
- package/source/{Resize.js → ScrollableContainerResizeHandler.js} +1 -1
- package/source/VirtualScroller.constructor.js +5 -5
- package/source/VirtualScroller.items.js +1 -1
- package/source/VirtualScroller.js +5 -5
- package/source/VirtualScroller.layout.js +8 -12
- package/source/{VirtualScroller.resize.js → VirtualScroller.onContainerResize.js} +1 -1
- package/website/index-bypass.html +4 -14
- package/website/index-dom.html +1 -1
- package/website/index-grid.html +4 -4
- package/website/index-scrollableContainer.html +4 -4
- package/website/index-tbody-scrollableContainer.html +2 -0
- package/website/index-tbody.html +2 -0
- package/website/index.html +3 -3
- package/commonjs/Resize.js.map +0 -1
- package/commonjs/VirtualScroller.resize.js.map +0 -1
- package/modules/Resize.js.map +0 -1
- package/modules/VirtualScroller.resize.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualScroller.layout.js","names":["onUpdateShownItemIndexes","reason","stateUpdate","skip","updateState","newItemsWillBeRendered","widthHasChanged","_isResizing","getItemsCount","scroll","cancelScheduledLayout","cancelLayoutTimer","log","updateShownItemIndexes","call","startedAt","Date","now","getShownItemIndexes","firstShownItemIndex","lastShownItemIndex","shownItemsHeight","firstNonMeasuredItemIndex","listHeightMeasurement","hasSnapshot","getAnchorItemIndex","undefined","validateWillBeHiddenItemHeightsAreAccurate","beforeItemsHeight","layout","getBeforeItemsHeight","afterItemsHeight","getAfterItemsHeight","layoutDuration","bypass","SLOW_LAYOUT_DURATION","warn","getColumnsCount","itemHeights","getAverage","isDebug","getState","slice","itemStates","onBeforeShowItems","items","previouslyCalculatedLayout","getVisibleArea","visibleArea","getVisibleAreaBounds","latestLayoutVisibleArea","listTopOffsetInsideScrollableContainer","getListTopOffsetInsideScrollableContainer","top","bottom","itemsCount","visibleAreaTop","visibleAreaBottom","isVisible","itemsContainer","getHeight","getNonVisibleListShownItemIndexes","isValid","i","previouslyMeasuredItemHeight","actualItemHeight","remeasureItemHeight","updatePreviouslyCalculatedLayoutOnItemHeightChange","previousHeight","newHeight","prevLayout","heightDifference","listTopOffset","scrollableContainer","getItemsContainerTopOffset","listTopOffsetWatcher","onListTopOffset","_onItemHeightDidChange","reportError","error","ItemNotRenderedError","message","_isActive","waitingForRender","updateLayoutAfterRenderBecauseItemHeightChanged","LAYOUT_REASON","ITEM_HEIGHT_CHANGED","itemHeightsThatChangedWhileNewItemsWereBeingRendered","String","getPrerenderMargin","renderAheadMarginRatio","onItemInitialRender","measureItemHeightsAndSpacing","measureItemHeights","verticalSpacing","measureVerticalSpacingIfNotMeasured","layoutTimer","clearTimeout","layoutTimerStateUpdate","scheduleLayoutTimer","setTimeout"],"sources":["../source/VirtualScroller.layout.js"],"sourcesContent":["// For some weird reason, in Chrome, `setTimeout()` would lag up to a second (or more) behind.\r\n// Turns out, Chrome developers have deprecated `setTimeout()` API entirely without asking anyone.\r\n// Replacing `setTimeout()` with `requestAnimationFrame()` can work around that Chrome bug.\r\n// https://github.com/bvaughn/react-virtualized/issues/722\r\nimport { setTimeout, clearTimeout } from 'request-animation-frame-timeout'\r\n\r\nimport log, { warn, isDebug, reportError } from './utility/debug.js'\r\nimport { LAYOUT_REASON } from './Layout.js'\r\n\r\nimport ItemNotRenderedError from './ItemNotRenderedError.js'\r\n\r\nexport default function() {\r\n\tthis.onUpdateShownItemIndexes = ({ reason, stateUpdate }) => {\r\n\t\t// In case of \"don't do anything\".\r\n\t\tconst skip = () => {\r\n\t\t\tif (stateUpdate) {\r\n\t\t\t\tthis.updateState(stateUpdate)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If new `items` have been set and are waiting to be applied,\r\n\t\t// or if the viewport width has changed requiring a re-layout,\r\n\t\t// then temporarily stop all other updates like \"on scroll\" updates.\r\n\t\t// This prevents `state` being inconsistent, because, for example,\r\n\t\t// both `setItems()` and this function could update `VirtualScroller` state\r\n\t\t// and having them operate in parallel could result in incorrectly calculated\r\n\t\t// `beforeItemsHeight` / `afterItemsHeight` / `firstShownItemIndex` /\r\n\t\t// `lastShownItemIndex`, because, when operating in parallel, this function\r\n\t\t// would have different `items` than the `setItems()` function, so their\r\n\t\t// results could diverge.\r\n\t\tif (this.newItemsWillBeRendered || this.widthHasChanged || this._isResizing) {\r\n\t\t\treturn skip()\r\n\t\t}\r\n\r\n\t\t// If there're no items then there's no need to re-layout anything.\r\n\t\tif (this.getItemsCount() === 0) {\r\n\t\t\treturn skip()\r\n\t\t}\r\n\r\n\t\t// Cancel a \"re-layout when user stops scrolling\" timer.\r\n\t\tthis.scroll.cancelScheduledLayout()\r\n\r\n\t\t// Cancel a re-layout that is scheduled to run at the next \"frame\",\r\n\t\t// because a re-layout will be performed right now.\r\n\t\tstateUpdate = this.cancelLayoutTimer({ stateUpdate })\r\n\r\n\t\t// Perform a re-layout.\r\n\t\tlog(`~ Update Layout (on ${reason}) ~`)\r\n\t\tupdateShownItemIndexes.call(this, { stateUpdate })\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the \"from\" and \"to\" shown item indexes.\r\n\t * If the list is visible and some of the items being shown are new\r\n\t * and are required to be measured first, then\r\n\t * `firstNonMeasuredItemIndex` is defined.\r\n\t * If the list is visible and all items being shown have been encountered\r\n\t * (and measured) before, then `firstNonMeasuredItemIndex` is `undefined`.\r\n\t *\r\n\t * The `stateUpdate` parameter is just an optional \"additional\" state update.\r\n\t */\r\n\tfunction updateShownItemIndexes({ stateUpdate }) {\r\n\t\tconst startedAt = Date.now()\r\n\r\n\t\t// Get shown item indexes.\r\n\t\tlet {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tshownItemsHeight,\r\n\t\t\tfirstNonMeasuredItemIndex\r\n\t\t} = getShownItemIndexes.call(this)\r\n\r\n\t\t// If scroll position is scheduled to be restored after render,\r\n\t\t// then the \"anchor\" item must be rendered, and all of the prepended\r\n\t\t// items before it, all in a single pass. This way, all of the\r\n\t\t// prepended items' heights could be measured right after the render\r\n\t\t// has finished, and the scroll position can then be immediately restored.\r\n\t\tif (this.listHeightMeasurement.hasSnapshot()) {\r\n\t\t\tif (lastShownItemIndex < this.listHeightMeasurement.getAnchorItemIndex()) {\r\n\t\t\t\tlastShownItemIndex = this.listHeightMeasurement.getAnchorItemIndex()\r\n\t\t\t}\r\n\t\t\t// `firstShownItemIndex` is always `0` when prepending items.\r\n\t\t\t// And `lastShownItemIndex` always covers all prepended items in this case.\r\n\t\t\t// None of the prepended items have been rendered before,\r\n\t\t\t// so their heights are unknown. The code at the start of this function\r\n\t\t\t// did therefore set `firstNonMeasuredItemIndex` to non-`undefined`\r\n\t\t\t// in order to render just the first prepended item in order to\r\n\t\t\t// measure it, and only then make a decision on how many other\r\n\t\t\t// prepended items to render. But since we've instructed the code\r\n\t\t\t// to show all of the prepended items at once, there's no need to\r\n\t\t\t// \"redo layout after render\". Additionally, if layout was re-done\r\n\t\t\t// after render, then there would be a short interval of visual\r\n\t\t\t// \"jitter\" due to the scroll position not being restored because it'd\r\n\t\t\t// wait for the second layout to finish instead of being restored\r\n\t\t\t// right after the first one.\r\n\t\t\tfirstNonMeasuredItemIndex = undefined\r\n\t\t}\r\n\r\n\t\t// Validate the heights of items to be hidden on next render.\r\n\t\t// For example, a user could click a \"Show more\" button,\r\n\t\t// or an \"Expand YouTube video\" button, which would result\r\n\t\t// in the actual height of the list item being different\r\n\t\t// from what has been initially measured in `this.itemHeights[i]`,\r\n\t\t// if the developer didn't call `.setItemState(i, newState)` and `.onItemHeightDidChange(i)`.\r\n\t\tif (!validateWillBeHiddenItemHeightsAreAccurate.call(this, firstShownItemIndex, lastShownItemIndex)) {\r\n\t\t\tlog('~ Because some of the will-be-hidden item heights (listed above) have changed since they\\'ve last been measured, redo layout. ~')\r\n\t\t\t// Redo layout, now with the correct item heights.\r\n\t\t\treturn updateShownItemIndexes.call(this, { stateUpdate });\r\n\t\t}\r\n\r\n\t\t// Measure \"before\" items height.\r\n\t\tconst beforeItemsHeight = this.layout.getBeforeItemsHeight(\r\n\t\t\tfirstShownItemIndex\r\n\t\t)\r\n\r\n\t\t// Measure \"after\" items height.\r\n\t\tconst afterItemsHeight = this.layout.getAfterItemsHeight(\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tthis.getItemsCount()\r\n\t\t)\r\n\r\n\t\tconst layoutDuration = Date.now() - startedAt\r\n\r\n\t\t// Debugging.\r\n\t\tlog('~ Calculated Layout' + (this.bypass ? ' (bypass)' : '') + ' ~')\r\n\t\tif (layoutDuration < SLOW_LAYOUT_DURATION) {\r\n\t\t\t// log('Calculated in', layoutDuration, 'ms')\r\n\t\t} else {\r\n\t\t\twarn('Layout calculated in', layoutDuration, 'ms')\r\n\t\t}\r\n\t\tif (this.getColumnsCount()) {\r\n\t\t\tlog('Columns count', this.getColumnsCount())\r\n\t\t}\r\n\t\tlog('First shown item index', firstShownItemIndex)\r\n\t\tlog('Last shown item index', lastShownItemIndex)\r\n\t\tlog('Before items height', beforeItemsHeight)\r\n\t\tlog('After items height (actual or estimated)', afterItemsHeight)\r\n\t\tlog('Average item height (used for estimated after items height calculation)', this.itemHeights.getAverage())\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('Item heights', this.getState().itemHeights.slice())\r\n\t\t\tlog('Item states', this.getState().itemStates.slice())\r\n\t\t}\r\n\r\n\t\t// Optionally preload items to be rendered.\r\n\t\tthis.onBeforeShowItems(\r\n\t\t\tthis.getState().items,\r\n\t\t\tthis.getState().itemHeights,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t)\r\n\r\n\t\t// Set `this.firstNonMeasuredItemIndex`.\r\n\t\tthis.firstNonMeasuredItemIndex = firstNonMeasuredItemIndex\r\n\t\t// if (firstNonMeasuredItemIndex !== undefined) {\r\n\t\t// \tlog('Non-measured item index that will be measured at next layout', firstNonMeasuredItemIndex)\r\n\t\t// }\r\n\r\n\t\t// Set \"previously calculated layout\".\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\t// Currently, this feature is not used, and `shownItemsHeight` property\r\n\t\t// is not returned at all, so don't set any \"previously calculated layout\".\r\n\t\t//\r\n\t\tif (shownItemsHeight === undefined) {\r\n\t\t\tthis.previouslyCalculatedLayout = undefined\r\n\t\t} else {\r\n\t\t\t// If \"previously calculated layout\" feature would be implmeneted,\r\n\t\t\t// then this code would set \"previously calculate layout\" instance variable.\r\n\t\t\t//\r\n\t\t\t// What for would this instance variable be used?\r\n\t\t\t//\r\n\t\t\t// Instead of using a `this.previouslyCalculatedLayout` instance variable,\r\n\t\t\t// this code could use `this.getState()` because it reflects what's currently on screen,\r\n\t\t\t// but there's a single edge case when it could go out of sync —\r\n\t\t\t// updating item heights externally via `.onItemHeightDidChange(i)`.\r\n\t\t\t//\r\n\t\t\t// If, for example, an item height was updated externally via `.onItemHeightDidChange(i)`\r\n\t\t\t// then `this.getState().itemHeights` would get updated immediately but\r\n\t\t\t// `this.getState().beforeItemsHeight` or `this.getState().afterItemsHeight`\r\n\t\t\t// would still correspond to the previous item height, so those would be \"stale\".\r\n\t\t\t// On the other hand, same values in `this.previouslyCalculatedLayout` instance variable\r\n\t\t\t// can also be updated immediately, so they won't go out of sync with the updated item height.\r\n\t\t\t// That seems the only edge case when using a separate `this.previouslyCalculatedLayout`\r\n\t\t\t// instance variable instead of using `this.getState()` would theoretically be justified.\r\n\t\t\t//\r\n\t\t\tthis.previouslyCalculatedLayout = {\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tshownItemsHeight\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Update `VirtualScroller` state.\r\n\t\t// `VirtualScroller` automatically re-renders on state updates.\r\n\t\t//\r\n\t\t// All `state` properties updated here should be overwritten in\r\n\t\t// the implementation of `setItems()` and `onResize()` methods\r\n\t\t// so that the `state` is not left in an inconsistent state\r\n\t\t// whenever there're concurrent `updateState()` updates that could\r\n\t\t// possibly conflict with one another — instead, those state updates\r\n\t\t// should overwrite each other in terms of priority.\r\n\t\t// These \"on scroll\" updates have the lowest priority compared to\r\n\t\t// the state updates originating from `setItems()` and `onResize()` methods.\r\n\t\t//\r\n\t\tthis.updateState({\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight,\r\n\t\t\t...stateUpdate\r\n\t\t})\r\n\t}\r\n\r\n\tfunction getVisibleArea() {\r\n\t\tconst visibleArea = this.scroll.getVisibleAreaBounds()\r\n\t\tthis.latestLayoutVisibleArea = visibleArea\r\n\r\n\t\t// Subtract the top offset of the list inside the scrollable container.\r\n\t\tconst listTopOffsetInsideScrollableContainer = this.getListTopOffsetInsideScrollableContainer()\r\n\t\treturn {\r\n\t\t\ttop: visibleArea.top - listTopOffsetInsideScrollableContainer,\r\n\t\t\tbottom: visibleArea.bottom - listTopOffsetInsideScrollableContainer\r\n\t\t}\r\n\t}\r\n\r\n\tfunction getShownItemIndexes() {\r\n\t\tconst itemsCount = this.getItemsCount()\r\n\r\n\t\tconst {\r\n\t\t\ttop: visibleAreaTop,\r\n\t\t\tbottom: visibleAreaBottom\r\n\t\t} = getVisibleArea.call(this)\r\n\r\n\t\tif (this.bypass) {\r\n\t\t\treturn {\r\n\t\t\t\tfirstShownItemIndex: 0,\r\n\t\t\t\tlastShownItemIndex: itemsCount - 1,\r\n\t\t\t\t// shownItemsHeight: this.getState().itemHeights.reduce((sum, itemHeight) => sum + itemHeight, 0)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Find the indexes of the items that are currently visible\r\n\t\t// (or close to being visible) in the scrollable container.\r\n\t\t// For scrollable containers other than the main screen, it could also\r\n\t\t// check the visibility of such scrollable container itself, because it\r\n\t\t// might be not visible.\r\n\t\t// If such kind of an optimization would hypothetically be implemented,\r\n\t\t// then it would also require listening for \"scroll\" events on the screen.\r\n\t\t// Overall, I suppose that such \"actual visibility\" feature would be\r\n\t\t// a very minor optimization and not something I'd deal with.\r\n\t\tconst isVisible = visibleAreaTop < this.itemsContainer.getHeight() && visibleAreaBottom > 0\r\n\t\tif (!isVisible) {\r\n\t\t\tlog('The entire list is off-screen. No items are visible.')\r\n\t\t\treturn this.layout.getNonVisibleListShownItemIndexes()\r\n\t\t}\r\n\r\n\t\t// Get shown item indexes.\r\n\t\treturn this.layout.getShownItemIndexes({\r\n\t\t\titemsCount: this.getItemsCount(),\r\n\t\t\tvisibleAreaTop,\r\n\t\t\tvisibleAreaBottom\r\n\t\t})\r\n\t}\r\n\r\n\t/**\r\n\t * Validates the heights of items to be hidden on next render.\r\n\t * For example, a user could click a \"Show more\" button,\r\n\t * or an \"Expand YouTube video\" button, which would result\r\n\t * in the actual height of the list item being different\r\n\t * from what has been initially measured in `this.itemHeights[i]`,\r\n\t * if the developer didn't call `.setItemState(i, newState)` and `.onItemHeightDidChange(i)`.\r\n\t */\r\n\tfunction validateWillBeHiddenItemHeightsAreAccurate(firstShownItemIndex, lastShownItemIndex) {\r\n\t\tlet isValid = true\r\n\t\tlet i = this.getState().firstShownItemIndex\r\n\t\twhile (i <= this.getState().lastShownItemIndex) {\r\n\t\t\tif (i >= firstShownItemIndex && i <= lastShownItemIndex) {\r\n\t\t\t\t// The item's still visible.\r\n\t\t\t} else {\r\n\t\t\t\t// The item will be hidden. Re-measure its height.\r\n\t\t\t\t// The rationale is that there could be a situation when an item's\r\n\t\t\t\t// height has changed, and the developer has properly added an\r\n\t\t\t\t// `.onItemHeightDidChange(i)` call to notify `VirtualScroller`\r\n\t\t\t\t// about that change, but at the same time that wouldn't work.\r\n\t\t\t\t// For example, suppose there's a list of several items on a page,\r\n\t\t\t\t// and those items are in \"minimized\" state (having height 100px).\r\n\t\t\t\t// Then, a user clicks an \"Expand all items\" button, and all items\r\n\t\t\t\t// in the list are expanded (expanded item height is gonna be 700px).\r\n\t\t\t\t// `VirtualScroller` demands that `.onItemHeightDidChange(i)` is called\r\n\t\t\t\t// in such cases, and the developer has properly added the code to do that.\r\n\t\t\t\t// So, if there were 10 \"minimized\" items visible on a page, then there\r\n\t\t\t\t// will be 10 individual `.onItemHeightDidChange(i)` calls. No issues so far.\r\n\t\t\t\t// But, as the first `.onItemHeightDidChange(i)` call executes, it immediately\r\n\t\t\t\t// (\"synchronously\") triggers a re-layout, and that re-layout finds out\r\n\t\t\t\t// that now, because the first item is big, it occupies most of the screen\r\n\t\t\t\t// space, and only the first 3 items are visible on screen instead of 10,\r\n\t\t\t\t// and so it leaves the first 3 items mounted and unmounts the rest 7.\r\n\t\t\t\t// Then, after `VirtualScroller` has rerendered, the code returns to\r\n\t\t\t\t// where it was executing, and calls `.onItemHeightDidChange(i)` for the\r\n\t\t\t\t// second item. It also triggers an immediate re-layout that finds out\r\n\t\t\t\t// that only the first 2 items are visible on screen, and it unmounts\r\n\t\t\t\t// the third one too. After that, it calls `.onItemHeightDidChange(i)`\r\n\t\t\t\t// for the third item, but that item is no longer rendered, so its height\r\n\t\t\t\t// can't be measured, and the same's for all the rest of the original 10 items.\r\n\t\t\t\t// So, even though the developer has written their code properly, the\r\n\t\t\t\t// `VirtualScroller` still ends up having incorrect `itemHeights[]`:\r\n\t\t\t\t// `[700px, 700px, 100px, 100px, 100px, 100px, 100px, 100px, 100px, 100px]`\r\n\t\t\t\t// while it should have been `700px` for all of them.\r\n\t\t\t\t// To work around such issues, every item's height is re-measured before it\r\n\t\t\t\t// gets hidden.\r\n\t\t\t\tconst previouslyMeasuredItemHeight = this.getState().itemHeights[i]\r\n\t\t\t\tconst actualItemHeight = remeasureItemHeight.call(this, i)\r\n\t\t\t\tif (actualItemHeight !== previouslyMeasuredItemHeight) {\r\n\t\t\t\t\tif (isValid) {\r\n\t\t\t\t\t\tlog('~ Validate will-be-hidden item heights. ~')\r\n\t\t\t\t\t\t// Update or reset previously calculated layout.\r\n\t\t\t\t\t\tupdatePreviouslyCalculatedLayoutOnItemHeightChange.call(this, i, previouslyMeasuredItemHeight, actualItemHeight)\r\n\t\t\t\t\t}\r\n\t\t\t\t\tisValid = false\r\n\t\t\t\t\twarn('Item index', i, 'is no longer visible and will be unmounted. Its height has changed from', previouslyMeasuredItemHeight, 'to', actualItemHeight, 'since it was last measured. This is not necessarily a bug, and could happen, for example, on screen width change, or when there\\'re several `onItemHeightDidChange(i)` calls issued at the same time, and the first one triggers a re-layout before the rest of them have had a chance to be executed.')\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\ti++\r\n\t\t}\r\n\t\treturn isValid\r\n\t}\r\n\r\n\tfunction remeasureItemHeight(i) {\r\n\t\tconst { firstShownItemIndex } = this.getState()\r\n\t\treturn this.itemHeights.remeasureItemHeight(i, firstShownItemIndex)\r\n\t}\r\n\r\n\t// Updates the snapshot of the current layout when an item's height changes.\r\n\t//\r\n\t// The \"previously calculated layout\" feature is not currently used.\r\n\t//\r\n\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t// rather than from scratch, which would be an optimization.\r\n\t//\r\n\tfunction updatePreviouslyCalculatedLayoutOnItemHeightChange(i, previousHeight, newHeight) {\r\n\t\tconst prevLayout = this.previouslyCalculatedLayout\r\n\t\tif (prevLayout) {\r\n\t\t\tconst heightDifference = newHeight - previousHeight\r\n\t\t\tif (i < prevLayout.firstShownItemIndex) {\r\n\t\t\t\t// Patch `prevLayout`'s `.beforeItemsHeight`.\r\n\t\t\t\tprevLayout.beforeItemsHeight += heightDifference\r\n\t\t\t} else if (i > prevLayout.lastShownItemIndex) {\r\n\t\t\t\t// Could patch `.afterItemsHeight` of `prevLayout` here,\r\n\t\t\t\t// if `.afterItemsHeight` property existed in `prevLayout`.\r\n\t\t\t\tif (prevLayout.afterItemsHeight !== undefined) {\r\n\t\t\t\t\tprevLayout.afterItemsHeight += heightDifference\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\t// Patch `prevLayout`'s shown items height.\r\n\t\t\t\tprevLayout.shownItemsHeight += newHeight - previousHeight\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the list's top offset relative to the scrollable container's top edge.\r\n\t * @return {number}\r\n\t */\r\n\tthis.getListTopOffsetInsideScrollableContainer = () => {\r\n\t\tconst listTopOffset = this.scrollableContainer.getItemsContainerTopOffset()\r\n\t\tif (this.listTopOffsetWatcher) {\r\n\t\t\tthis.listTopOffsetWatcher.onListTopOffset(listTopOffset)\r\n\t\t}\r\n\t\treturn listTopOffset\r\n\t}\r\n\r\n\tthis._onItemHeightDidChange = (i) => {\r\n\t\tlog('~ On Item Height Did Change was called ~')\r\n\t\tlog('Item index', i)\r\n\r\n\t\tconst {\r\n\t\t\titemHeights,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t} = this.getState()\r\n\r\n\t\t// Check if the item is still rendered.\r\n\t\tif (!(i >= firstShownItemIndex && i <= lastShownItemIndex)) {\r\n\t\t\t// There could be valid cases when an item is no longer rendered\r\n\t\t\t// by the time `.onItemHeightDidChange(i)` gets called.\r\n\t\t\t// For example, suppose there's a list of several items on a page,\r\n\t\t\t// and those items are in \"minimized\" state (having height 100px).\r\n\t\t\t// Then, a user clicks an \"Expand all items\" button, and all items\r\n\t\t\t// in the list are expanded (expanded item height is gonna be 700px).\r\n\t\t\t// `VirtualScroller` demands that `.onItemHeightDidChange(i)` is called\r\n\t\t\t// in such cases, and the developer has properly added the code to do that.\r\n\t\t\t// So, if there were 10 \"minimized\" items visible on a page, then there\r\n\t\t\t// will be 10 individual `.onItemHeightDidChange(i)` calls. No issues so far.\r\n\t\t\t// But, as the first `.onItemHeightDidChange(i)` call executes, it immediately\r\n\t\t\t// (\"synchronously\") triggers a re-layout, and that re-layout finds out\r\n\t\t\t// that now, because the first item is big, it occupies most of the screen\r\n\t\t\t// space, and only the first 3 items are visible on screen instead of 10,\r\n\t\t\t// and so it leaves the first 3 items mounted and unmounts the rest 7.\r\n\t\t\t// Then, after `VirtualScroller` has rerendered, the code returns to\r\n\t\t\t// where it was executing, and calls `.onItemHeightDidChange(i)` for the\r\n\t\t\t// second item. It also triggers an immediate re-layout that finds out\r\n\t\t\t// that only the first 2 items are visible on screen, and it unmounts\r\n\t\t\t// the third one too. After that, it calls `.onItemHeightDidChange(i)`\r\n\t\t\t// for the third item, but that item is no longer rendered, so its height\r\n\t\t\t// can't be measured, and the same's for all the rest of the original 10 items.\r\n\t\t\t// So, even though the developer has written their code properly, there're\r\n\t\t\t// still situations when the item could be no longer rendered by the time\r\n\t\t\t// `.onItemHeightDidChange(i)` gets called.\r\n\t\t\treturn warn('The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when when a developer calls `onItemHeightDidChange(i)` while looping through a batch of items.')\r\n\t\t}\r\n\r\n\t\tconst previousHeight = itemHeights[i]\r\n\t\tif (previousHeight === undefined) {\r\n\t\t\treturn reportError(`\"onItemHeightDidChange()\" has been called for item index ${i} but the item hasn't been rendered before.`)\r\n\t\t}\r\n\r\n\t\tlog('~ Re-measure item height ~')\r\n\r\n\t\tlet newHeight\r\n\r\n\t\ttry {\r\n\t\t\tnewHeight = remeasureItemHeight.call(this, i)\r\n\t\t} catch (error) {\r\n\t\t\t// Successfully finishing an `onItemHeightDidChange(i)` call is not considered\r\n\t\t\t// critical for `VirtualScroller`'s operation, so such errors could be ignored.\r\n\t\t\tif (error instanceof ItemNotRenderedError) {\r\n\t\t\t\treturn reportError(`\"onItemHeightDidChange()\" has been called for item index ${i} but the item is not currently rendered and can\\'t be measured. The exact error was: ${error.message}`)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlog('Previous height', previousHeight)\r\n\t\tlog('New height', newHeight)\r\n\r\n\t\tif (previousHeight !== newHeight) {\r\n\t\t\tlog('~ Item height has changed. Should update layout. ~')\r\n\r\n\t\t\t// Update or reset a previously calculated layout with the new item height\r\n\t\t\t// so that the potential future \"diff\"s based on that \"previously calculated\" layout\r\n\t\t\t// would be correct.\r\n\t\t\t//\r\n\t\t\t// The \"previously calculated layout\" feature is not currently used\r\n\t\t\t// so this function call doesn't really affect anything.\r\n\t\t\t//\r\n\t\t\tupdatePreviouslyCalculatedLayoutOnItemHeightChange.call(this, i, previousHeight, newHeight)\r\n\r\n\t\t\t// Recalculate layout.\r\n\t\t\t//\r\n\t\t\t// If the `VirtualScroller` is already waiting for a state update to be rendered,\r\n\t\t\t// delay `onItemHeightDidChange(i)`'s re-layout until that state update is rendered.\r\n\t\t\t// The reason is that React `<VirtualScroller/>`'s `onHeightDidChange()` is meant to\r\n\t\t\t// be called inside `useLayoutEffect()` hook. Due to how React is implemented internally,\r\n\t\t\t// that might happen in the middle of the currently pending `setState()` operation\r\n\t\t\t// being applied, resulting in weird \"race condition\" bugs.\r\n\t\t\t//\r\n\t\t\tif (this._isActive) {\r\n\t\t\t\tif (this.waitingForRender) {\r\n\t\t\t\t\tlog('~ Another state update is already waiting to be rendered. Delay the layout update until then. ~')\r\n\t\t\t\t\tthis.updateLayoutAfterRenderBecauseItemHeightChanged = true\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.ITEM_HEIGHT_CHANGED })\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// If there was a request for `setState()` with new `items`, then the changes\r\n\t\t\t// to `currentState.itemHeights[]` made above in a `remeasureItemHeight()` call\r\n\t\t\t// would be overwritten when that pending `setState()` call gets applied.\r\n\t\t\t// To fix that, the updates to current `itemHeights[]` are noted in\r\n\t\t\t// `this.itemHeightsThatChangedWhileNewItemsWereBeingRendered` variable.\r\n\t\t\t// That variable is then checked when the `setState()` call with the new `items`\r\n\t\t\t// has been updated.\r\n\t\t\tif (this.newItemsWillBeRendered) {\r\n\t\t\t\tif (!this.itemHeightsThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\t\tthis.itemHeightsThatChangedWhileNewItemsWereBeingRendered = {}\r\n\t\t\t\t}\r\n\t\t\t\tthis.itemHeightsThatChangedWhileNewItemsWereBeingRendered[String(i)] = newHeight\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tthis.getPrerenderMargin = () => {\r\n\t\t// The list component renders not only the items that're currently visible\r\n\t\t// but also the items that lie within some extra vertical margin (called\r\n\t\t// \"prerender margin\") on top and bottom for future scrolling: this way,\r\n\t\t// there'll be significantly less layout recalculations as the user scrolls,\r\n\t\t// because now it doesn't have to recalculate layout on each scroll event.\r\n\t\t// By default, the \"prerender margin\" is equal to the screen height:\r\n\t\t// this seems to be the optimal value for \"Page Up\" / \"Page Down\" navigation\r\n\t\t// and optimized mouse wheel scrolling (a user is unlikely to continuously\r\n\t\t// scroll past the screen height, because they'd stop to read through\r\n\t\t// the newly visible items first, and when they do stop scrolling, that's\r\n\t\t// when layout gets recalculated).\r\n\t\tconst renderAheadMarginRatio = 1 // in scrollable container heights.\r\n\t\treturn this.scrollableContainer.getHeight() * renderAheadMarginRatio\r\n\t}\r\n\r\n\t/**\r\n\t * Calls `onItemFirstRender()` for items that haven't been\r\n\t * \"seen\" previously.\r\n\t * @param {any[]} items\r\n\t * @param {number[]} itemHeights\r\n\t * @param {number} firstShownItemIndex\r\n\t * @param {number} lastShownItemIndex\r\n\t */\r\n\tthis.onBeforeShowItems = (\r\n\t\titems,\r\n\t\titemHeights,\r\n\t\tfirstShownItemIndex,\r\n\t\tlastShownItemIndex\r\n\t) => {\r\n\t\tif (this.onItemInitialRender) {\r\n\t\t\tlet i = firstShownItemIndex\r\n\t\t\twhile (i <= lastShownItemIndex) {\r\n\t\t\t\tif (itemHeights[i] === undefined) {\r\n\t\t\t\t\tthis.onItemInitialRender(items[i])\r\n\t\t\t\t}\r\n\t\t\t\ti++\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tthis.measureItemHeightsAndSpacing = () => {\r\n\t\t// Measure \"newly shown\" item heights.\r\n\t\t// Also re-validate already measured items' heights.\r\n\t\tthis.itemHeights.measureItemHeights(\r\n\t\t\tthis.getState().firstShownItemIndex,\r\n\t\t\tthis.getState().lastShownItemIndex\r\n\t\t)\r\n\r\n\t\t// Measure item vertical spacing, if required.\r\n\t\tconst verticalSpacing = this.measureVerticalSpacingIfNotMeasured()\r\n\r\n\t\t// Return a state update if vertical spacing has been measured.\r\n\t\t// Doesn't set `verticalSpacing: 0` in `state` because it is effectively\r\n\t\t// same as `verticalSpacing: undefined` in terms code behavior and calculations.\r\n\t\t// Not having `verticalSpacing: 0` in `state` just makes the `state` object\r\n\t\t// a bit more cleaner and a bit less cluttered (easier for inspection).\r\n\t\tif (verticalSpacing && verticalSpacing !== 0) {\r\n\t\t\t// Return a state update.\r\n\t\t\t// Sets `verticalSpacing` property in `state`.\r\n\t\t\treturn {\r\n\t\t\t\tverticalSpacing\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tthis.cancelLayoutTimer = ({ stateUpdate }) => {\r\n\t\tif (this.layoutTimer) {\r\n\t\t\tclearTimeout(this.layoutTimer)\r\n\t\t\tthis.layoutTimer = undefined\r\n\t\t\t// Merge state updates.\r\n\t\t\tif (stateUpdate || this.layoutTimerStateUpdate) {\r\n\t\t\t\tstateUpdate = {\r\n\t\t\t\t\t...this.layoutTimerStateUpdate,\r\n\t\t\t\t\t...stateUpdate\r\n\t\t\t\t}\r\n\t\t\t\tthis.layoutTimerStateUpdate = undefined\r\n\t\t\t\treturn stateUpdate\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\treturn stateUpdate\r\n\t\t}\r\n\t}\r\n\r\n\tthis.scheduleLayoutTimer = ({ reason, stateUpdate }) => {\r\n\t\tthis.layoutTimerStateUpdate = stateUpdate\r\n\t\tthis.layoutTimer = setTimeout(() => {\r\n\t\t\tthis.layoutTimerStateUpdate = undefined\r\n\t\t\tthis.layoutTimer = undefined\r\n\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\treason,\r\n\t\t\t\tstateUpdate\r\n\t\t\t})\r\n\t\t}, 0)\r\n\t}\r\n}\r\n\r\nconst SLOW_LAYOUT_DURATION = 15 // in milliseconds."],"mappings":";;;;;;;;;AAIA;;AAEA;;AACA;;AAEA;;;;;;;;;;;;;;AAEe,oBAAW;EAAA;;EACzB,KAAKA,wBAAL,GAAgC,gBAA6B;IAAA,IAA1BC,MAA0B,QAA1BA,MAA0B;IAAA,IAAlBC,WAAkB,QAAlBA,WAAkB;;IAC5D;IACA,IAAMC,IAAI,GAAG,SAAPA,IAAO,GAAM;MAClB,IAAID,WAAJ,EAAiB;QAChB,KAAI,CAACE,WAAL,CAAiBF,WAAjB;MACA;IACD,CAJD,CAF4D,CAQ5D;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;IACA,IAAI,KAAI,CAACG,sBAAL,IAA+B,KAAI,CAACC,eAApC,IAAuD,KAAI,CAACC,WAAhE,EAA6E;MAC5E,OAAOJ,IAAI,EAAX;IACA,CApB2D,CAsB5D;;;IACA,IAAI,KAAI,CAACK,aAAL,OAAyB,CAA7B,EAAgC;MAC/B,OAAOL,IAAI,EAAX;IACA,CAzB2D,CA2B5D;;;IACA,KAAI,CAACM,MAAL,CAAYC,qBAAZ,GA5B4D,CA8B5D;IACA;;;IACAR,WAAW,GAAG,KAAI,CAACS,iBAAL,CAAuB;MAAET,WAAW,EAAXA;IAAF,CAAvB,CAAd,CAhC4D,CAkC5D;;IACA,IAAAU,iBAAA,gCAA2BX,MAA3B;IACAY,sBAAsB,CAACC,IAAvB,CAA4B,KAA5B,EAAkC;MAAEZ,WAAW,EAAXA;IAAF,CAAlC;EACA,C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lBC,WAAkB,SAAlBA,WAAkB;IACvD,KAAI,CAACgG,sBAAL,GAA8BhG,WAA9B;IACA,KAAI,CAAC8F,WAAL,GAAmB,IAAAI,wCAAA,EAAW,YAAM;MACnC,KAAI,CAACF,sBAAL,GAA8BxE,SAA9B;MACA,KAAI,CAACsE,WAAL,GAAmBtE,SAAnB;;MACA,KAAI,CAAC1B,wBAAL,CAA8B;QAC7BC,MAAM,EAANA,MAD6B;QAE7BC,WAAW,EAAXA;MAF6B,CAA9B;IAIA,CAPkB,EAOhB,CAPgB,CAAnB;EAQA,CAVD;AAWA;;AAED,IAAMiC,oBAAoB,GAAG,EAA7B,C,CAAgC"}
|
|
1
|
+
{"version":3,"file":"VirtualScroller.layout.js","names":["onUpdateShownItemIndexes","reason","stateUpdate","skip","updateState","newItemsWillBeRendered","widthHasChanged","_isResizing","getItemsCount","scroll","cancelScheduledLayout","cancelLayoutTimer","log","updateShownItemIndexes","call","startedAt","Date","now","getShownItemIndexes","firstShownItemIndex","lastShownItemIndex","shownItemsHeight","firstNonMeasuredItemIndex","listHeightMeasurement","hasSnapshot","getAnchorItemIndex","undefined","validateWillBeHiddenItemHeightsAreAccurate","beforeItemsHeight","layout","getBeforeItemsHeight","afterItemsHeight","getAfterItemsHeight","layoutDuration","bypass","SLOW_LAYOUT_DURATION","warn","getColumnsCount","itemHeights","getAverage","isDebug","getState","slice","itemStates","onBeforeShowItems","items","previouslyCalculatedLayout","getCoordinatesOfVisibleAreaInsideTheList","visibleAreaBounds","getVisibleAreaBounds","latestLayoutVisibleArea","listTopOffsetInsideScrollableContainer","getListTopOffsetInsideScrollableContainer","top","bottom","itemsCount","visibleAreaInsideTheList","isVisible","itemsContainer","getHeight","getPrerenderMargin","getNonVisibleListShownItemIndexes","isValid","i","previouslyMeasuredItemHeight","actualItemHeight","remeasureItemHeight","updatePreviouslyCalculatedLayoutOnItemHeightChange","previousHeight","newHeight","prevLayout","heightDifference","listTopOffset","scrollableContainer","getItemsContainerTopOffset","listTopOffsetWatcher","onListTopOffset","_onItemHeightDidChange","reportError","error","ItemNotRenderedError","message","_isActive","waitingForRender","updateLayoutAfterRenderBecauseItemHeightChanged","LAYOUT_REASON","ITEM_HEIGHT_CHANGED","itemHeightsThatChangedWhileNewItemsWereBeingRendered","String","renderAheadMarginRatio","onItemInitialRender","measureItemHeightsAndSpacing","measureItemHeights","verticalSpacing","measureVerticalSpacingIfNotMeasured","layoutTimer","clearTimeout","layoutTimerStateUpdate","scheduleLayoutTimer","setTimeout"],"sources":["../source/VirtualScroller.layout.js"],"sourcesContent":["// For some weird reason, in Chrome, `setTimeout()` would lag up to a second (or more) behind.\r\n// Turns out, Chrome developers have deprecated `setTimeout()` API entirely without asking anyone.\r\n// Replacing `setTimeout()` with `requestAnimationFrame()` can work around that Chrome bug.\r\n// https://github.com/bvaughn/react-virtualized/issues/722\r\nimport { setTimeout, clearTimeout } from 'request-animation-frame-timeout'\r\n\r\nimport log, { warn, isDebug, reportError } from './utility/debug.js'\r\nimport { LAYOUT_REASON } from './Layout.js'\r\n\r\nimport ItemNotRenderedError from './ItemNotRenderedError.js'\r\n\r\nexport default function() {\r\n\tthis.onUpdateShownItemIndexes = ({ reason, stateUpdate }) => {\r\n\t\t// In case of \"don't do anything\".\r\n\t\tconst skip = () => {\r\n\t\t\tif (stateUpdate) {\r\n\t\t\t\tthis.updateState(stateUpdate)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If new `items` have been set and are waiting to be applied,\r\n\t\t// or if the viewport width has changed requiring a re-layout,\r\n\t\t// then temporarily stop all other updates like \"on scroll\" updates.\r\n\t\t// This prevents `state` being inconsistent, because, for example,\r\n\t\t// both `setItems()` and this function could update `VirtualScroller` state\r\n\t\t// and having them operate in parallel could result in incorrectly calculated\r\n\t\t// `beforeItemsHeight` / `afterItemsHeight` / `firstShownItemIndex` /\r\n\t\t// `lastShownItemIndex`, because, when operating in parallel, this function\r\n\t\t// would have different `items` than the `setItems()` function, so their\r\n\t\t// results could diverge.\r\n\t\tif (this.newItemsWillBeRendered || this.widthHasChanged || this._isResizing) {\r\n\t\t\treturn skip()\r\n\t\t}\r\n\r\n\t\t// If there're no items then there's no need to re-layout anything.\r\n\t\tif (this.getItemsCount() === 0) {\r\n\t\t\treturn skip()\r\n\t\t}\r\n\r\n\t\t// Cancel a \"re-layout when user stops scrolling\" timer.\r\n\t\tthis.scroll.cancelScheduledLayout()\r\n\r\n\t\t// Cancel a re-layout that is scheduled to run at the next \"frame\",\r\n\t\t// because a re-layout will be performed right now.\r\n\t\tstateUpdate = this.cancelLayoutTimer({ stateUpdate })\r\n\r\n\t\t// Perform a re-layout.\r\n\t\tlog(`~ Update Layout (on ${reason}) ~`)\r\n\t\tupdateShownItemIndexes.call(this, { stateUpdate })\r\n\t}\r\n\r\n\t/**\r\n\t * Updates the \"from\" and \"to\" shown item indexes.\r\n\t * If the list is visible and some of the items being shown are new\r\n\t * and are required to be measured first, then\r\n\t * `firstNonMeasuredItemIndex` is defined.\r\n\t * If the list is visible and all items being shown have been encountered\r\n\t * (and measured) before, then `firstNonMeasuredItemIndex` is `undefined`.\r\n\t *\r\n\t * The `stateUpdate` parameter is just an optional \"additional\" state update.\r\n\t */\r\n\tfunction updateShownItemIndexes({ stateUpdate }) {\r\n\t\tconst startedAt = Date.now()\r\n\r\n\t\t// Get shown item indexes.\r\n\t\tlet {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tshownItemsHeight,\r\n\t\t\tfirstNonMeasuredItemIndex\r\n\t\t} = getShownItemIndexes.call(this)\r\n\r\n\t\t// If scroll position is scheduled to be restored after render,\r\n\t\t// then the \"anchor\" item must be rendered, and all of the prepended\r\n\t\t// items before it, all in a single pass. This way, all of the\r\n\t\t// prepended items' heights could be measured right after the render\r\n\t\t// has finished, and the scroll position can then be immediately restored.\r\n\t\tif (this.listHeightMeasurement.hasSnapshot()) {\r\n\t\t\tif (lastShownItemIndex < this.listHeightMeasurement.getAnchorItemIndex()) {\r\n\t\t\t\tlastShownItemIndex = this.listHeightMeasurement.getAnchorItemIndex()\r\n\t\t\t}\r\n\t\t\t// `firstShownItemIndex` is always `0` when prepending items.\r\n\t\t\t// And `lastShownItemIndex` always covers all prepended items in this case.\r\n\t\t\t// None of the prepended items have been rendered before,\r\n\t\t\t// so their heights are unknown. The code at the start of this function\r\n\t\t\t// did therefore set `firstNonMeasuredItemIndex` to non-`undefined`\r\n\t\t\t// in order to render just the first prepended item in order to\r\n\t\t\t// measure it, and only then make a decision on how many other\r\n\t\t\t// prepended items to render. But since we've instructed the code\r\n\t\t\t// to show all of the prepended items at once, there's no need to\r\n\t\t\t// \"redo layout after render\". Additionally, if layout was re-done\r\n\t\t\t// after render, then there would be a short interval of visual\r\n\t\t\t// \"jitter\" due to the scroll position not being restored because it'd\r\n\t\t\t// wait for the second layout to finish instead of being restored\r\n\t\t\t// right after the first one.\r\n\t\t\tfirstNonMeasuredItemIndex = undefined\r\n\t\t}\r\n\r\n\t\t// Validate the heights of items to be hidden on next render.\r\n\t\t// For example, a user could click a \"Show more\" button,\r\n\t\t// or an \"Expand YouTube video\" button, which would result\r\n\t\t// in the actual height of the list item being different\r\n\t\t// from what has been initially measured in `this.itemHeights[i]`,\r\n\t\t// if the developer didn't call `.setItemState(i, newState)` and `.onItemHeightDidChange(i)`.\r\n\t\tif (!validateWillBeHiddenItemHeightsAreAccurate.call(this, firstShownItemIndex, lastShownItemIndex)) {\r\n\t\t\tlog('~ Because some of the will-be-hidden item heights (listed above) have changed since they\\'ve last been measured, redo layout. ~')\r\n\t\t\t// Redo layout, now with the correct item heights.\r\n\t\t\treturn updateShownItemIndexes.call(this, { stateUpdate });\r\n\t\t}\r\n\r\n\t\t// Measure \"before\" items height.\r\n\t\tconst beforeItemsHeight = this.layout.getBeforeItemsHeight(\r\n\t\t\tfirstShownItemIndex\r\n\t\t)\r\n\r\n\t\t// Measure \"after\" items height.\r\n\t\tconst afterItemsHeight = this.layout.getAfterItemsHeight(\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tthis.getItemsCount()\r\n\t\t)\r\n\r\n\t\tconst layoutDuration = Date.now() - startedAt\r\n\r\n\t\t// Debugging.\r\n\t\tlog('~ Calculated Layout' + (this.bypass ? ' (bypass)' : '') + ' ~')\r\n\t\tif (layoutDuration < SLOW_LAYOUT_DURATION) {\r\n\t\t\t// log('Calculated in', layoutDuration, 'ms')\r\n\t\t} else {\r\n\t\t\twarn('Layout calculated in', layoutDuration, 'ms')\r\n\t\t}\r\n\t\tif (this.getColumnsCount()) {\r\n\t\t\tlog('Columns count', this.getColumnsCount())\r\n\t\t}\r\n\t\tlog('First shown item index', firstShownItemIndex)\r\n\t\tlog('Last shown item index', lastShownItemIndex)\r\n\t\tlog('Before items height', beforeItemsHeight)\r\n\t\tlog('After items height (actual or estimated)', afterItemsHeight)\r\n\t\tlog('Average item height (used for estimated after items height calculation)', this.itemHeights.getAverage())\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('Item heights', this.getState().itemHeights.slice())\r\n\t\t\tlog('Item states', this.getState().itemStates.slice())\r\n\t\t}\r\n\r\n\t\t// Optionally preload items to be rendered.\r\n\t\tthis.onBeforeShowItems(\r\n\t\t\tthis.getState().items,\r\n\t\t\tthis.getState().itemHeights,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t)\r\n\r\n\t\t// Set `this.firstNonMeasuredItemIndex`.\r\n\t\tthis.firstNonMeasuredItemIndex = firstNonMeasuredItemIndex\r\n\t\t// if (firstNonMeasuredItemIndex !== undefined) {\r\n\t\t// \tlog('Non-measured item index that will be measured at next layout', firstNonMeasuredItemIndex)\r\n\t\t// }\r\n\r\n\t\t// Set \"previously calculated layout\".\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\t// Currently, this feature is not used, and `shownItemsHeight` property\r\n\t\t// is not returned at all, so don't set any \"previously calculated layout\".\r\n\t\t//\r\n\t\tif (shownItemsHeight === undefined) {\r\n\t\t\tthis.previouslyCalculatedLayout = undefined\r\n\t\t} else {\r\n\t\t\t// If \"previously calculated layout\" feature would be implmeneted,\r\n\t\t\t// then this code would set \"previously calculate layout\" instance variable.\r\n\t\t\t//\r\n\t\t\t// What for would this instance variable be used?\r\n\t\t\t//\r\n\t\t\t// Instead of using a `this.previouslyCalculatedLayout` instance variable,\r\n\t\t\t// this code could use `this.getState()` because it reflects what's currently on screen,\r\n\t\t\t// but there's a single edge case when it could go out of sync —\r\n\t\t\t// updating item heights externally via `.onItemHeightDidChange(i)`.\r\n\t\t\t//\r\n\t\t\t// If, for example, an item height was updated externally via `.onItemHeightDidChange(i)`\r\n\t\t\t// then `this.getState().itemHeights` would get updated immediately but\r\n\t\t\t// `this.getState().beforeItemsHeight` or `this.getState().afterItemsHeight`\r\n\t\t\t// would still correspond to the previous item height, so those would be \"stale\".\r\n\t\t\t// On the other hand, same values in `this.previouslyCalculatedLayout` instance variable\r\n\t\t\t// can also be updated immediately, so they won't go out of sync with the updated item height.\r\n\t\t\t// That seems the only edge case when using a separate `this.previouslyCalculatedLayout`\r\n\t\t\t// instance variable instead of using `this.getState()` would theoretically be justified.\r\n\t\t\t//\r\n\t\t\tthis.previouslyCalculatedLayout = {\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tshownItemsHeight\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Update `VirtualScroller` state.\r\n\t\t// `VirtualScroller` automatically re-renders on state updates.\r\n\t\t//\r\n\t\t// All `state` properties updated here should be overwritten in\r\n\t\t// the implementation of `setItems()` and `onResize()` methods\r\n\t\t// so that the `state` is not left in an inconsistent state\r\n\t\t// whenever there're concurrent `updateState()` updates that could\r\n\t\t// possibly conflict with one another — instead, those state updates\r\n\t\t// should overwrite each other in terms of priority.\r\n\t\t// These \"on scroll\" updates have the lowest priority compared to\r\n\t\t// the state updates originating from `setItems()` and `onResize()` methods.\r\n\t\t//\r\n\t\tthis.updateState({\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight,\r\n\t\t\t...stateUpdate\r\n\t\t})\r\n\t}\r\n\r\n\tfunction getCoordinatesOfVisibleAreaInsideTheList() {\r\n\t\tconst visibleAreaBounds = this.scroll.getVisibleAreaBounds()\r\n\t\tthis.latestLayoutVisibleArea = visibleAreaBounds\r\n\r\n\t\t// Subtract the top offset of the list inside the scrollable container.\r\n\t\tconst listTopOffsetInsideScrollableContainer = this.getListTopOffsetInsideScrollableContainer()\r\n\t\treturn {\r\n\t\t\ttop: visibleAreaBounds.top - listTopOffsetInsideScrollableContainer,\r\n\t\t\tbottom: visibleAreaBounds.bottom - listTopOffsetInsideScrollableContainer\r\n\t\t}\r\n\t}\r\n\r\n\tfunction getShownItemIndexes() {\r\n\t\tconst itemsCount = this.getItemsCount()\r\n\r\n\t\tconst visibleAreaInsideTheList = getCoordinatesOfVisibleAreaInsideTheList.call(this)\r\n\r\n\t\tif (this.bypass) {\r\n\t\t\treturn {\r\n\t\t\t\tfirstShownItemIndex: 0,\r\n\t\t\t\tlastShownItemIndex: itemsCount - 1,\r\n\t\t\t\t// shownItemsHeight: this.getState().itemHeights.reduce((sum, itemHeight) => sum + itemHeight, 0)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Find the indexes of the items that are currently visible\r\n\t\t// (or close to being visible) in the scrollable container.\r\n\t\t// For scrollable containers other than the main screen, it could also\r\n\t\t// check the visibility of such scrollable container itself, because it\r\n\t\t// might be not visible.\r\n\t\t// If such kind of an optimization would hypothetically be implemented,\r\n\t\t// then it would also require listening for \"scroll\" events on the screen.\r\n\t\t// Overall, I suppose that such \"actual visibility\" feature would be\r\n\t\t// a very minor optimization and not something I'd deal with.\r\n\t\tconst isVisible = visibleAreaInsideTheList.top < this.itemsContainer.getHeight() + this.layout.getPrerenderMargin() && visibleAreaInsideTheList.bottom > 0 - this.layout.getPrerenderMargin()\r\n\t\tif (!isVisible) {\r\n\t\t\tlog('The entire list is off-screen. No items are visible.')\r\n\t\t\treturn this.layout.getNonVisibleListShownItemIndexes()\r\n\t\t}\r\n\r\n\t\t// Get shown item indexes.\r\n\t\treturn this.layout.getShownItemIndexes({\r\n\t\t\titemsCount: this.getItemsCount(),\r\n\t\t\tvisibleAreaInsideTheList\r\n\t\t})\r\n\t}\r\n\r\n\t/**\r\n\t * Validates the heights of items to be hidden on next render.\r\n\t * For example, a user could click a \"Show more\" button,\r\n\t * or an \"Expand YouTube video\" button, which would result\r\n\t * in the actual height of the list item being different\r\n\t * from what has been initially measured in `this.itemHeights[i]`,\r\n\t * if the developer didn't call `.setItemState(i, newState)` and `.onItemHeightDidChange(i)`.\r\n\t */\r\n\tfunction validateWillBeHiddenItemHeightsAreAccurate(firstShownItemIndex, lastShownItemIndex) {\r\n\t\tlet isValid = true\r\n\t\tlet i = this.getState().firstShownItemIndex\r\n\t\twhile (i <= this.getState().lastShownItemIndex) {\r\n\t\t\tif (i >= firstShownItemIndex && i <= lastShownItemIndex) {\r\n\t\t\t\t// The item's still visible.\r\n\t\t\t} else {\r\n\t\t\t\t// The item will be hidden. Re-measure its height.\r\n\t\t\t\t// The rationale is that there could be a situation when an item's\r\n\t\t\t\t// height has changed, and the developer has properly added an\r\n\t\t\t\t// `.onItemHeightDidChange(i)` call to notify `VirtualScroller`\r\n\t\t\t\t// about that change, but at the same time that wouldn't work.\r\n\t\t\t\t// For example, suppose there's a list of several items on a page,\r\n\t\t\t\t// and those items are in \"minimized\" state (having height 100px).\r\n\t\t\t\t// Then, a user clicks an \"Expand all items\" button, and all items\r\n\t\t\t\t// in the list are expanded (expanded item height is gonna be 700px).\r\n\t\t\t\t// `VirtualScroller` demands that `.onItemHeightDidChange(i)` is called\r\n\t\t\t\t// in such cases, and the developer has properly added the code to do that.\r\n\t\t\t\t// So, if there were 10 \"minimized\" items visible on a page, then there\r\n\t\t\t\t// will be 10 individual `.onItemHeightDidChange(i)` calls. No issues so far.\r\n\t\t\t\t// But, as the first `.onItemHeightDidChange(i)` call executes, it immediately\r\n\t\t\t\t// (\"synchronously\") triggers a re-layout, and that re-layout finds out\r\n\t\t\t\t// that now, because the first item is big, it occupies most of the screen\r\n\t\t\t\t// space, and only the first 3 items are visible on screen instead of 10,\r\n\t\t\t\t// and so it leaves the first 3 items mounted and unmounts the rest 7.\r\n\t\t\t\t// Then, after `VirtualScroller` has rerendered, the code returns to\r\n\t\t\t\t// where it was executing, and calls `.onItemHeightDidChange(i)` for the\r\n\t\t\t\t// second item. It also triggers an immediate re-layout that finds out\r\n\t\t\t\t// that only the first 2 items are visible on screen, and it unmounts\r\n\t\t\t\t// the third one too. After that, it calls `.onItemHeightDidChange(i)`\r\n\t\t\t\t// for the third item, but that item is no longer rendered, so its height\r\n\t\t\t\t// can't be measured, and the same's for all the rest of the original 10 items.\r\n\t\t\t\t// So, even though the developer has written their code properly, the\r\n\t\t\t\t// `VirtualScroller` still ends up having incorrect `itemHeights[]`:\r\n\t\t\t\t// `[700px, 700px, 100px, 100px, 100px, 100px, 100px, 100px, 100px, 100px]`\r\n\t\t\t\t// while it should have been `700px` for all of them.\r\n\t\t\t\t// To work around such issues, every item's height is re-measured before it\r\n\t\t\t\t// gets hidden.\r\n\t\t\t\tconst previouslyMeasuredItemHeight = this.getState().itemHeights[i]\r\n\t\t\t\tconst actualItemHeight = remeasureItemHeight.call(this, i)\r\n\t\t\t\tif (actualItemHeight !== previouslyMeasuredItemHeight) {\r\n\t\t\t\t\tif (isValid) {\r\n\t\t\t\t\t\tlog('~ Validate will-be-hidden item heights. ~')\r\n\t\t\t\t\t\t// Update or reset previously calculated layout.\r\n\t\t\t\t\t\tupdatePreviouslyCalculatedLayoutOnItemHeightChange.call(this, i, previouslyMeasuredItemHeight, actualItemHeight)\r\n\t\t\t\t\t}\r\n\t\t\t\t\tisValid = false\r\n\t\t\t\t\twarn('Item index', i, 'is no longer visible and will be unmounted. Its height has changed from', previouslyMeasuredItemHeight, 'to', actualItemHeight, 'since it was last measured. This is not necessarily a bug, and could happen, for example, on screen width change, or when there\\'re several `onItemHeightDidChange(i)` calls issued at the same time, and the first one triggers a re-layout before the rest of them have had a chance to be executed.')\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\ti++\r\n\t\t}\r\n\t\treturn isValid\r\n\t}\r\n\r\n\tfunction remeasureItemHeight(i) {\r\n\t\tconst { firstShownItemIndex } = this.getState()\r\n\t\treturn this.itemHeights.remeasureItemHeight(i, firstShownItemIndex)\r\n\t}\r\n\r\n\t// Updates the snapshot of the current layout when an item's height changes.\r\n\t//\r\n\t// The \"previously calculated layout\" feature is not currently used.\r\n\t//\r\n\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t// rather than from scratch, which would be an optimization.\r\n\t//\r\n\tfunction updatePreviouslyCalculatedLayoutOnItemHeightChange(i, previousHeight, newHeight) {\r\n\t\tconst prevLayout = this.previouslyCalculatedLayout\r\n\t\tif (prevLayout) {\r\n\t\t\tconst heightDifference = newHeight - previousHeight\r\n\t\t\tif (i < prevLayout.firstShownItemIndex) {\r\n\t\t\t\t// Patch `prevLayout`'s `.beforeItemsHeight`.\r\n\t\t\t\tprevLayout.beforeItemsHeight += heightDifference\r\n\t\t\t} else if (i > prevLayout.lastShownItemIndex) {\r\n\t\t\t\t// Could patch `.afterItemsHeight` of `prevLayout` here,\r\n\t\t\t\t// if `.afterItemsHeight` property existed in `prevLayout`.\r\n\t\t\t\tif (prevLayout.afterItemsHeight !== undefined) {\r\n\t\t\t\t\tprevLayout.afterItemsHeight += heightDifference\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\t// Patch `prevLayout`'s shown items height.\r\n\t\t\t\tprevLayout.shownItemsHeight += newHeight - previousHeight\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the list's top offset relative to the scrollable container's top edge.\r\n\t * @return {number}\r\n\t */\r\n\tthis.getListTopOffsetInsideScrollableContainer = () => {\r\n\t\tconst listTopOffset = this.scrollableContainer.getItemsContainerTopOffset()\r\n\t\tif (this.listTopOffsetWatcher) {\r\n\t\t\tthis.listTopOffsetWatcher.onListTopOffset(listTopOffset)\r\n\t\t}\r\n\t\treturn listTopOffset\r\n\t}\r\n\r\n\tthis._onItemHeightDidChange = (i) => {\r\n\t\tlog('~ On Item Height Did Change was called ~')\r\n\t\tlog('Item index', i)\r\n\r\n\t\tconst {\r\n\t\t\titemHeights,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t} = this.getState()\r\n\r\n\t\t// Check if the item is still rendered.\r\n\t\tif (!(i >= firstShownItemIndex && i <= lastShownItemIndex)) {\r\n\t\t\t// There could be valid cases when an item is no longer rendered\r\n\t\t\t// by the time `.onItemHeightDidChange(i)` gets called.\r\n\t\t\t// For example, suppose there's a list of several items on a page,\r\n\t\t\t// and those items are in \"minimized\" state (having height 100px).\r\n\t\t\t// Then, a user clicks an \"Expand all items\" button, and all items\r\n\t\t\t// in the list are expanded (expanded item height is gonna be 700px).\r\n\t\t\t// `VirtualScroller` demands that `.onItemHeightDidChange(i)` is called\r\n\t\t\t// in such cases, and the developer has properly added the code to do that.\r\n\t\t\t// So, if there were 10 \"minimized\" items visible on a page, then there\r\n\t\t\t// will be 10 individual `.onItemHeightDidChange(i)` calls. No issues so far.\r\n\t\t\t// But, as the first `.onItemHeightDidChange(i)` call executes, it immediately\r\n\t\t\t// (\"synchronously\") triggers a re-layout, and that re-layout finds out\r\n\t\t\t// that now, because the first item is big, it occupies most of the screen\r\n\t\t\t// space, and only the first 3 items are visible on screen instead of 10,\r\n\t\t\t// and so it leaves the first 3 items mounted and unmounts the rest 7.\r\n\t\t\t// Then, after `VirtualScroller` has rerendered, the code returns to\r\n\t\t\t// where it was executing, and calls `.onItemHeightDidChange(i)` for the\r\n\t\t\t// second item. It also triggers an immediate re-layout that finds out\r\n\t\t\t// that only the first 2 items are visible on screen, and it unmounts\r\n\t\t\t// the third one too. After that, it calls `.onItemHeightDidChange(i)`\r\n\t\t\t// for the third item, but that item is no longer rendered, so its height\r\n\t\t\t// can't be measured, and the same's for all the rest of the original 10 items.\r\n\t\t\t// So, even though the developer has written their code properly, there're\r\n\t\t\t// still situations when the item could be no longer rendered by the time\r\n\t\t\t// `.onItemHeightDidChange(i)` gets called.\r\n\t\t\treturn warn('The item is no longer rendered. This is not necessarily a bug, and could happen, for example, when when a developer calls `onItemHeightDidChange(i)` while looping through a batch of items.')\r\n\t\t}\r\n\r\n\t\tconst previousHeight = itemHeights[i]\r\n\t\tif (previousHeight === undefined) {\r\n\t\t\treturn reportError(`\"onItemHeightDidChange()\" has been called for item index ${i} but the item hasn't been rendered before.`)\r\n\t\t}\r\n\r\n\t\tlog('~ Re-measure item height ~')\r\n\r\n\t\tlet newHeight\r\n\r\n\t\ttry {\r\n\t\t\tnewHeight = remeasureItemHeight.call(this, i)\r\n\t\t} catch (error) {\r\n\t\t\t// Successfully finishing an `onItemHeightDidChange(i)` call is not considered\r\n\t\t\t// critical for `VirtualScroller`'s operation, so such errors could be ignored.\r\n\t\t\tif (error instanceof ItemNotRenderedError) {\r\n\t\t\t\treturn reportError(`\"onItemHeightDidChange()\" has been called for item index ${i} but the item is not currently rendered and can\\'t be measured. The exact error was: ${error.message}`)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlog('Previous height', previousHeight)\r\n\t\tlog('New height', newHeight)\r\n\r\n\t\tif (previousHeight !== newHeight) {\r\n\t\t\tlog('~ Item height has changed. Should update layout. ~')\r\n\r\n\t\t\t// Update or reset a previously calculated layout with the new item height\r\n\t\t\t// so that the potential future \"diff\"s based on that \"previously calculated\" layout\r\n\t\t\t// would be correct.\r\n\t\t\t//\r\n\t\t\t// The \"previously calculated layout\" feature is not currently used\r\n\t\t\t// so this function call doesn't really affect anything.\r\n\t\t\t//\r\n\t\t\tupdatePreviouslyCalculatedLayoutOnItemHeightChange.call(this, i, previousHeight, newHeight)\r\n\r\n\t\t\t// Recalculate layout.\r\n\t\t\t//\r\n\t\t\t// If the `VirtualScroller` is already waiting for a state update to be rendered,\r\n\t\t\t// delay `onItemHeightDidChange(i)`'s re-layout until that state update is rendered.\r\n\t\t\t// The reason is that React `<VirtualScroller/>`'s `onHeightDidChange()` is meant to\r\n\t\t\t// be called inside `useLayoutEffect()` hook. Due to how React is implemented internally,\r\n\t\t\t// that might happen in the middle of the currently pending `setState()` operation\r\n\t\t\t// being applied, resulting in weird \"race condition\" bugs.\r\n\t\t\t//\r\n\t\t\tif (this._isActive) {\r\n\t\t\t\tif (this.waitingForRender) {\r\n\t\t\t\t\tlog('~ Another state update is already waiting to be rendered. Delay the layout update until then. ~')\r\n\t\t\t\t\tthis.updateLayoutAfterRenderBecauseItemHeightChanged = true\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.ITEM_HEIGHT_CHANGED })\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// If there was a request for `setState()` with new `items`, then the changes\r\n\t\t\t// to `currentState.itemHeights[]` made above in a `remeasureItemHeight()` call\r\n\t\t\t// would be overwritten when that pending `setState()` call gets applied.\r\n\t\t\t// To fix that, the updates to current `itemHeights[]` are noted in\r\n\t\t\t// `this.itemHeightsThatChangedWhileNewItemsWereBeingRendered` variable.\r\n\t\t\t// That variable is then checked when the `setState()` call with the new `items`\r\n\t\t\t// has been updated.\r\n\t\t\tif (this.newItemsWillBeRendered) {\r\n\t\t\t\tif (!this.itemHeightsThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\t\tthis.itemHeightsThatChangedWhileNewItemsWereBeingRendered = {}\r\n\t\t\t\t}\r\n\t\t\t\tthis.itemHeightsThatChangedWhileNewItemsWereBeingRendered[String(i)] = newHeight\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tthis.getPrerenderMargin = () => {\r\n\t\t// The list component renders not only the items that're currently visible\r\n\t\t// but also the items that lie within some extra vertical margin (called\r\n\t\t// \"prerender margin\") on top and bottom for future scrolling: this way,\r\n\t\t// there'll be significantly less layout recalculations as the user scrolls,\r\n\t\t// because now it doesn't have to recalculate layout on each scroll event.\r\n\t\t// By default, the \"prerender margin\" is equal to the screen height:\r\n\t\t// this seems to be the optimal value for \"Page Up\" / \"Page Down\" navigation\r\n\t\t// and optimized mouse wheel scrolling (a user is unlikely to continuously\r\n\t\t// scroll past the screen height, because they'd stop to read through\r\n\t\t// the newly visible items first, and when they do stop scrolling, that's\r\n\t\t// when layout gets recalculated).\r\n\t\tconst renderAheadMarginRatio = 1 // in scrollable container heights.\r\n\t\treturn this.scrollableContainer.getHeight() * renderAheadMarginRatio\r\n\t}\r\n\r\n\t/**\r\n\t * Calls `onItemFirstRender()` for items that haven't been\r\n\t * \"seen\" previously.\r\n\t * @param {any[]} items\r\n\t * @param {number[]} itemHeights\r\n\t * @param {number} firstShownItemIndex\r\n\t * @param {number} lastShownItemIndex\r\n\t */\r\n\tthis.onBeforeShowItems = (\r\n\t\titems,\r\n\t\titemHeights,\r\n\t\tfirstShownItemIndex,\r\n\t\tlastShownItemIndex\r\n\t) => {\r\n\t\tif (this.onItemInitialRender) {\r\n\t\t\tlet i = firstShownItemIndex\r\n\t\t\twhile (i <= lastShownItemIndex) {\r\n\t\t\t\tif (itemHeights[i] === undefined) {\r\n\t\t\t\t\tthis.onItemInitialRender(items[i])\r\n\t\t\t\t}\r\n\t\t\t\ti++\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tthis.measureItemHeightsAndSpacing = () => {\r\n\t\t// Measure \"newly shown\" item heights.\r\n\t\t// Also re-validate already measured items' heights.\r\n\t\tthis.itemHeights.measureItemHeights(\r\n\t\t\tthis.getState().firstShownItemIndex,\r\n\t\t\tthis.getState().lastShownItemIndex\r\n\t\t)\r\n\r\n\t\t// Measure item vertical spacing, if required.\r\n\t\tconst verticalSpacing = this.measureVerticalSpacingIfNotMeasured()\r\n\r\n\t\t// Return a state update if vertical spacing has been measured.\r\n\t\t// Doesn't set `verticalSpacing: 0` in `state` because it is effectively\r\n\t\t// same as `verticalSpacing: undefined` in terms code behavior and calculations.\r\n\t\t// Not having `verticalSpacing: 0` in `state` just makes the `state` object\r\n\t\t// a bit more cleaner and a bit less cluttered (easier for inspection).\r\n\t\tif (verticalSpacing && verticalSpacing !== 0) {\r\n\t\t\t// Return a state update.\r\n\t\t\t// Sets `verticalSpacing` property in `state`.\r\n\t\t\treturn {\r\n\t\t\t\tverticalSpacing\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tthis.cancelLayoutTimer = ({ stateUpdate }) => {\r\n\t\tif (this.layoutTimer) {\r\n\t\t\tclearTimeout(this.layoutTimer)\r\n\t\t\tthis.layoutTimer = undefined\r\n\t\t\t// Merge state updates.\r\n\t\t\tif (stateUpdate || this.layoutTimerStateUpdate) {\r\n\t\t\t\tstateUpdate = {\r\n\t\t\t\t\t...this.layoutTimerStateUpdate,\r\n\t\t\t\t\t...stateUpdate\r\n\t\t\t\t}\r\n\t\t\t\tthis.layoutTimerStateUpdate = undefined\r\n\t\t\t\treturn stateUpdate\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\treturn stateUpdate\r\n\t\t}\r\n\t}\r\n\r\n\tthis.scheduleLayoutTimer = ({ reason, stateUpdate }) => {\r\n\t\tthis.layoutTimerStateUpdate = stateUpdate\r\n\t\tthis.layoutTimer = setTimeout(() => {\r\n\t\t\tthis.layoutTimerStateUpdate = undefined\r\n\t\t\tthis.layoutTimer = undefined\r\n\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\treason,\r\n\t\t\t\tstateUpdate\r\n\t\t\t})\r\n\t\t}, 0)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AAnB;;MACA,KAAI,CAAC1B,wBAAL,CAA8B;QAC7BC,MAAM,EAANA,MAD6B;QAE7BC,WAAW,EAAXA;MAF6B,CAA9B;IAIA,CAPkB,EAOhB,CAPgB,CAAnB;EAQA,CAVD;AAWA;;AAED,IAAMiC,oBAAoB,GAAG,EAA7B,C,CAAgC"}
|
|
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
12
12
|
function _default() {
|
|
13
13
|
var _this = this;
|
|
14
14
|
|
|
15
|
-
this.
|
|
15
|
+
this.onContainerResize = function () {
|
|
16
16
|
// Reset "previously calculated layout".
|
|
17
17
|
//
|
|
18
18
|
// The "previously calculated layout" feature is not currently used.
|
|
@@ -183,4 +183,4 @@ function _default() {
|
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
//# sourceMappingURL=VirtualScroller.
|
|
186
|
+
//# sourceMappingURL=VirtualScroller.onContainerResize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualScroller.onContainerResize.js","names":["onContainerResize","previouslyCalculatedLayout","undefined","listHeightMeasurement","reset","itemsCount","newItemsWillBeRendered","count","getState","itemHeights","length","layout","newState","scrollableContainerWidth","scrollableContainer","getWidth","firstShownItemIndex","lastShownItemIndex","beforeItemsHeight","afterItemsHeight","Array","columnsCount","getActualColumnsCountForState","verticalSpacing","newColumnsCount","getActualColumnsCount","newFirstShownItemIndex","Math","floor","newLastShownItemIndex","min","ceil","log","getVerticalSpacing","getColumnsCount","shouldDiscardBeforeResizeItemHeights","beforeResize","shouldIncludeBeforeResizeValuesInState","snapshotBeforeResizeItemHeights","widthHasChanged","stateUpdate","updateState","prepend","replace"],"sources":["../source/VirtualScroller.onContainerResize.js"],"sourcesContent":["import log from './utility/debug.js'\r\n\r\nexport default function() {\r\n\tthis.onContainerResize = () => {\r\n\t\t// Reset \"previously calculated layout\".\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\tthis.previouslyCalculatedLayout = undefined\r\n\r\n\t\t// Cancel any potential scheduled scroll position restoration.\r\n\t\tthis.listHeightMeasurement.reset()\r\n\r\n\t\t// Get the most recent items count.\r\n\t\t// If there're a \"pending\" `setItems()` call then use the items count from that call\r\n\t\t// instead of using the count of currently shown `items` from `state`.\r\n\t\t// A `setItems()` call is \"pending\" when `updateState()` operation is \"asynchronous\", that is\r\n\t\t// when `updateState()` calls aren't applied immediately, like in React.\r\n\t\tconst itemsCount = this.newItemsWillBeRendered\r\n\t\t\t? this.newItemsWillBeRendered.count\r\n\t\t\t: this.getState().itemHeights.length\r\n\r\n\t\t// If layout values have been calculated as a result of a \"pending\" `setItems()` call,\r\n\t\t// then don't discard those new layout values and use them instead of the ones from `state`.\r\n\t\t//\r\n\t\t// A `setItems()` call is \"pending\" when `updateState()` operation is \"asynchronous\", that is\r\n\t\t// when `updateState()` calls aren't applied immediately, like in React.\r\n\t\t//\r\n\t\tconst layout = this.newItemsWillBeRendered\r\n\t\t\t? this.newItemsWillBeRendered.layout\r\n\t\t\t: this.getState()\r\n\r\n\t\t// Update `VirtualScroller` state.\r\n\t\tconst newState = {\r\n\t\t\tscrollableContainerWidth: this.scrollableContainer.getWidth(),\r\n\r\n\t\t\t// This state update should also overwrite all the `state` properties\r\n\t\t\t// that are also updated in the \"on scroll\" handler (`getShownItemIndexes()`):\r\n\t\t\t//\r\n\t\t\t// * `firstShownItemIndex`\r\n\t\t\t// * `lastShownItemIndex`\r\n\t\t\t// * `beforeItemsHeight`\r\n\t\t\t// * `afterItemsHeight`\r\n\t\t\t//\r\n\t\t\t// That's because this `updateState()` update has a higher priority\r\n\t\t\t// than that of the \"on scroll\" handler, so it should overwrite\r\n\t\t\t// any potential state changes dispatched by the \"on scroll\" handler.\r\n\t\t\t//\r\n\t\t\t// All these properties might have changed, but they're not\r\n\t\t\t// recalculated here becase they'll be recalculated after\r\n\t\t\t// this new state is applied (rendered).\r\n\t\t\t//\r\n\t\t\tfirstShownItemIndex: layout.firstShownItemIndex,\r\n\t\t\tlastShownItemIndex: layout.lastShownItemIndex,\r\n\t\t\tbeforeItemsHeight: layout.beforeItemsHeight,\r\n\t\t\tafterItemsHeight: layout.afterItemsHeight,\r\n\r\n\t\t\t// Reset item heights, because if scrollable container's width (or height)\r\n\t\t\t// has changed, then the list width (or height) most likely also has changed,\r\n\t\t\t// and also some CSS `@media()` rules might have been added or removed.\r\n\t\t\t// So re-render the list entirely.\r\n\t\t\titemHeights: new Array(itemsCount),\r\n\r\n\t\t\tcolumnsCount: this.getActualColumnsCountForState(),\r\n\r\n\t\t\t// Re-measure vertical spacing after render because new CSS styles\r\n\t\t\t// might be applied for the new window width.\r\n\t\t\tverticalSpacing: undefined\r\n\t\t}\r\n\r\n\t\tconst { firstShownItemIndex, lastShownItemIndex } = layout\r\n\r\n\t\t// Get the `columnsCount` for the new window width.\r\n\t\tconst newColumnsCount = this.getActualColumnsCount()\r\n\r\n\t\t// Re-calculate `firstShownItemIndex` and `lastShownItemIndex`\r\n\t\t// based on the new `columnsCount` so that the whole row is visible.\r\n\t\tconst newFirstShownItemIndex = Math.floor(firstShownItemIndex / newColumnsCount) * newColumnsCount\r\n\t\tconst newLastShownItemIndex = Math.min(\r\n\t\t\tMath.ceil((lastShownItemIndex + 1) / newColumnsCount) * newColumnsCount,\r\n\t\t\titemsCount\r\n\t\t) - 1\r\n\r\n\t\t// Potentially update `firstShownItemIndex` if it needs to be adjusted in order to\r\n\t\t// correspond to the new `columnsCount`.\r\n\t\tif (newFirstShownItemIndex !== firstShownItemIndex) {\r\n\t\t\tlog('Columns Count changed from', this.getState().columnsCount || 1, 'to', newColumnsCount)\r\n\t\t\tlog('First Shown Item Index needs to change from', firstShownItemIndex, 'to', newFirstShownItemIndex)\r\n\t\t}\r\n\r\n\t\t// Always rewrite `firstShownItemIndex` and `lastShownItemIndex`\r\n\t\t// as part of the `state` update, even if it hasn't been modified.\r\n\t\t//\r\n\t\t// The reason is that there could be two subsequent `onResize()` calls:\r\n\t\t// the first one could be user resizing the window to half of its width,\r\n\t\t// resulting in an \"asynchronous\" `updateState()` call, and then, before that\r\n\t\t// `updateState()` call is applied, a second resize event happens when the user\r\n\t\t// has resized the window back to its original width, meaning that the\r\n\t\t// `columnsCount` is back to its original value.\r\n\t\t// In that case, the final `newFirstShownItemIndex` will be equal to the\r\n\t\t// original `firstShownItemIndex` that was in `state` before the user\r\n\t\t// has started resizing the window, so, in the end, `state.firstShownItemIndex`\r\n\t\t// property wouldn't have changed, but it still has to be part of the final\r\n\t\t// state update in order to overwrite the previous update of `firstShownItemIndex`\r\n\t\t// property that has been scheduled to be applied in state after the first resize\r\n\t\t// happened.\r\n\t\t//\r\n\t\tnewState.firstShownItemIndex = newFirstShownItemIndex\r\n\t\tnewState.lastShownItemIndex = newLastShownItemIndex\r\n\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\r\n\t\t// `beforeResize` is always overwritten in `state` here.\r\n\t\t// (once it has started being tracked in `state`)\r\n\t\tif (this.shouldDiscardBeforeResizeItemHeights() || newFirstShownItemIndex === 0) {\r\n\t\t\tif (this.beforeResize.shouldIncludeBeforeResizeValuesInState()) {\r\n\t\t\t\tnewState.beforeResize = undefined\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Snapshot \"before resize\" values in order to preserve the currently\r\n\t\t// shown items' vertical position on screen so that there's no \"content jumping\".\r\n\t\telse {\r\n\t\t\t// Keep \"before resize\" values in order to preserve the currently\r\n\t\t\t// shown items' vertical position on screen so that there's no\r\n\t\t\t// \"content jumping\". These \"before resize\" values will be discarded\r\n\t\t\t// when (if) the user scrolls back to the top of the list.\r\n\t\t\tnewState.beforeResize = {\r\n\t\t\t\tverticalSpacing,\r\n\t\t\t\tcolumnsCount,\r\n\t\t\t\titemHeights: this.beforeResize.snapshotBeforeResizeItemHeights({\r\n\t\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\t\tnewFirstShownItemIndex,\r\n\t\t\t\t\tnewColumnsCount\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `this.widthHasChanged` tells `VirtualScroller` that it should\r\n\t\t// temporarily stop other updates (like \"on scroll\" updates) and wait\r\n\t\t// for the new `state` to be applied, after which the `onRender()`\r\n\t\t// function will clear this flag and perform a re-layout.\r\n\t\t//\r\n\t\t// A re-layout is required because the layout parameters calculated above\r\n\t\t// are approximate ones, and the exact item heights aren't known at this point.\r\n\t\t// So the `updateState()` call below is just to re-render the `VirtualScroller`.\r\n\t\t// After it has been re-rendered, it will measure item heights and then calculate\r\n\t\t// correct layout parameters.\r\n\t\t//\r\n\t\tthis.widthHasChanged = {\r\n\t\t\tstateUpdate: newState\r\n\t\t}\r\n\r\n\t\t// Rerender.\r\n\t\tthis.updateState(newState)\r\n\t}\r\n\r\n\t// Returns whether \"before resize\" item heights should be discarded\r\n\t// as a result of calling `setItems()` with a new set of items\r\n\t// when an asynchronous `updateState()` call inside that function\r\n\t// hasn't been applied yet.\r\n\t//\r\n\t// If `setItems()` update was an \"incremental\" one and no items\r\n\t// have been prepended, then `firstShownItemIndex` is preserved,\r\n\t// and all items' heights before it should be kept in order to\r\n\t// preserve the top offset of the first shown item so that there's\r\n\t// no \"content jumping\".\r\n\t//\r\n\t// If `setItems()` update was an \"incremental\" one but there're\r\n\t// some prepended items, then it means that now there're new items\r\n\t// with unknown heights at the top, so the top offset of the first\r\n\t// shown item won't be preserved because there're no \"before resize\"\r\n\t// heights of those items.\r\n\t//\r\n\t// If `setItems()` update was not an \"incremental\" one, then don't\r\n\t// attempt to restore previous item heights after a potential window\r\n\t// width change because all item heights have been reset.\r\n\t//\r\n\tthis.shouldDiscardBeforeResizeItemHeights = () => {\r\n\t\tif (this.newItemsWillBeRendered) {\r\n\t\t\tconst { prepend, replace } = this.newItemsWillBeRendered\r\n\t\t\treturn prepend || replace\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;;AAAA;;;;AAEe,oBAAW;EAAA;;EACzB,KAAKA,iBAAL,GAAyB,YAAM;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAI,CAACC,0BAAL,GAAkCC,SAAlC,CAT8B,CAW9B;;IACA,KAAI,CAACC,qBAAL,CAA2BC,KAA3B,GAZ8B,CAc9B;IACA;IACA;IACA;IACA;;;IACA,IAAMC,UAAU,GAAG,KAAI,CAACC,sBAAL,GAChB,KAAI,CAACA,sBAAL,CAA4BC,KADZ,GAEhB,KAAI,CAACC,QAAL,GAAgBC,WAAhB,CAA4BC,MAF/B,CAnB8B,CAuB9B;IACA;IACA;IACA;IACA;IACA;;IACA,IAAMC,MAAM,GAAG,KAAI,CAACL,sBAAL,GACZ,KAAI,CAACA,sBAAL,CAA4BK,MADhB,GAEZ,KAAI,CAACH,QAAL,EAFH,CA7B8B,CAiC9B;;IACA,IAAMI,QAAQ,GAAG;MAChBC,wBAAwB,EAAE,KAAI,CAACC,mBAAL,CAAyBC,QAAzB,EADV;MAGhB;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACAC,mBAAmB,EAAEL,MAAM,CAACK,mBAnBZ;MAoBhBC,kBAAkB,EAAEN,MAAM,CAACM,kBApBX;MAqBhBC,iBAAiB,EAAEP,MAAM,CAACO,iBArBV;MAsBhBC,gBAAgB,EAAER,MAAM,CAACQ,gBAtBT;MAwBhB;MACA;MACA;MACA;MACAV,WAAW,EAAE,IAAIW,KAAJ,CAAUf,UAAV,CA5BG;MA8BhBgB,YAAY,EAAE,KAAI,CAACC,6BAAL,EA9BE;MAgChB;MACA;MACAC,eAAe,EAAErB;IAlCD,CAAjB;IAqCA,IAAQc,mBAAR,GAAoDL,MAApD,CAA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ACA;MACA;MACAU,QAAQ,CAACwB,YAAT,GAAwB;QACvBb,eAAe,EAAfA,eADuB;QAEvBF,YAAY,EAAZA,YAFuB;QAGvBZ,WAAW,EAAE,KAAI,CAAC2B,YAAL,CAAkBE,+BAAlB,CAAkD;UAC9DtB,mBAAmB,EAAnBA,mBAD8D;UAE9DU,sBAAsB,EAAtBA,sBAF8D;UAG9DF,eAAe,EAAfA;QAH8D,CAAlD;MAHU,CAAxB;IASA,CAzI6B,CA2I9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;IACA,KAAI,CAACe,eAAL,GAAuB;MACtBC,WAAW,EAAE5B;IADS,CAAvB,CAtJ8B,CA0J9B;;IACA,KAAI,CAAC6B,WAAL,CAAiB7B,QAAjB;EACA,CA5JD,CADyB,CA+JzB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;EACA,KAAKuB,oCAAL,GAA4C,YAAM;IACjD,IAAI,KAAI,CAAC7B,sBAAT,EAAiC;MAChC,4BAA6B,KAAI,CAACA,sBAAlC;MAAA,IAAQoC,OAAR,yBAAQA,OAAR;MAAA,IAAiBC,OAAjB,yBAAiBA,OAAjB;MACA,OAAOD,OAAO,IAAIC,OAAlB;IACA;EACD,CALD;AAMA"}
|
package/modules/Layout.js
CHANGED
|
@@ -357,14 +357,12 @@ var Layout = /*#__PURE__*/function () {
|
|
|
357
357
|
key: "getShownItemIndexes",
|
|
358
358
|
value: function getShownItemIndexes(_ref8) {
|
|
359
359
|
var itemsCount = _ref8.itemsCount,
|
|
360
|
-
|
|
361
|
-
visibleAreaBottom = _ref8.visibleAreaBottom;
|
|
360
|
+
visibleAreaInsideTheList = _ref8.visibleAreaInsideTheList;
|
|
362
361
|
|
|
363
362
|
var indexes = this._getShownItemIndex({
|
|
364
363
|
itemsCount: itemsCount,
|
|
365
364
|
fromIndex: 0,
|
|
366
|
-
|
|
367
|
-
visibleAreaBottom: visibleAreaBottom,
|
|
365
|
+
visibleAreaInsideTheList: visibleAreaInsideTheList,
|
|
368
366
|
findFirstShownItemIndex: true
|
|
369
367
|
});
|
|
370
368
|
|
|
@@ -383,8 +381,7 @@ var Layout = /*#__PURE__*/function () {
|
|
|
383
381
|
itemsCount: itemsCount,
|
|
384
382
|
fromIndex: firstShownItemIndex,
|
|
385
383
|
beforeItemsHeight: beforeItemsHeight,
|
|
386
|
-
|
|
387
|
-
visibleAreaBottom: visibleAreaBottom,
|
|
384
|
+
visibleAreaInsideTheList: visibleAreaInsideTheList,
|
|
388
385
|
findLastShownItemIndex: true
|
|
389
386
|
});
|
|
390
387
|
|
|
@@ -408,8 +405,7 @@ var Layout = /*#__PURE__*/function () {
|
|
|
408
405
|
value: function _getShownItemIndex(parameters) {
|
|
409
406
|
var beforeResize = parameters.beforeResize,
|
|
410
407
|
itemsCount = parameters.itemsCount,
|
|
411
|
-
|
|
412
|
-
visibleAreaBottom = parameters.visibleAreaBottom,
|
|
408
|
+
visibleAreaInsideTheList = parameters.visibleAreaInsideTheList,
|
|
413
409
|
findFirstShownItemIndex = parameters.findFirstShownItemIndex,
|
|
414
410
|
findLastShownItemIndex = parameters.findLastShownItemIndex;
|
|
415
411
|
var fromIndex = parameters.fromIndex,
|
|
@@ -436,7 +432,8 @@ var Layout = /*#__PURE__*/function () {
|
|
|
436
432
|
// If "previously calculated layout" would be used then it would first find
|
|
437
433
|
// `firstShownItemIndex` and then find `lastShownItemIndex` as part of two
|
|
438
434
|
// separate calls of this function, each with or without `backwards` flag,
|
|
439
|
-
// depending on whether `
|
|
435
|
+
// depending on whether `visibleAreaInsideTheList.top` and `visibleAreaInsideTheList.top`
|
|
436
|
+
// have shifted up or down.
|
|
440
437
|
|
|
441
438
|
var firstShownItemIndex;
|
|
442
439
|
var lastShownItemIndex; // It's not always required to pass `beforeItemsHeight` parameter:
|
|
@@ -511,7 +508,7 @@ var Layout = /*#__PURE__*/function () {
|
|
|
511
508
|
itemsCount: itemsCount,
|
|
512
509
|
firstShownItemIndex: findLastShownItemIndex ? fromIndex : undefined,
|
|
513
510
|
indexOfTheFirstItemInTheRow: currentRowFirstItemIndex,
|
|
514
|
-
nonMeasuredAreaHeight:
|
|
511
|
+
nonMeasuredAreaHeight: visibleAreaInsideTheList.bottom + this.getPrerenderMargin() - beforeItemsHeight
|
|
515
512
|
});
|
|
516
513
|
}
|
|
517
514
|
|
|
@@ -521,8 +518,8 @@ var Layout = /*#__PURE__*/function () {
|
|
|
521
518
|
}
|
|
522
519
|
|
|
523
520
|
var itemsHeightFromFirstRowToThisRow = beforeItemsHeight + currentRowHeight;
|
|
524
|
-
var rowStepsIntoVisibleAreaTop = itemsHeightFromFirstRowToThisRow >
|
|
525
|
-
var rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder = itemsHeightFromFirstRowToThisRow + verticalSpacingAfterCurrentRow >=
|
|
521
|
+
var rowStepsIntoVisibleAreaTop = itemsHeightFromFirstRowToThisRow > visibleAreaInsideTheList.top - this.getPrerenderMargin();
|
|
522
|
+
var rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder = itemsHeightFromFirstRowToThisRow + verticalSpacingAfterCurrentRow >= visibleAreaInsideTheList.bottom + this.getPrerenderMargin(); // if (backwards) {
|
|
526
523
|
// if (findFirstShownItemIndex) {
|
|
527
524
|
// if (rowStepsOutOfVisibleAreaTop) {
|
|
528
525
|
// return {
|
package/modules/Layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.js","names":["log","warn","ScrollableContainerNotReadyError","Layout","bypass","getInitialEstimatedItemHeight","getInitialEstimatedVisibleItemRowsCount","measureItemsBatchSize","getPrerenderMargin","getVerticalSpacing","getVerticalSpacingBeforeResize","getColumnsCount","getColumnsCountBeforeResize","getItemHeight","getItemHeightBeforeResize","getBeforeResizeItemsCount","getAverageItemHeight","getMaxVisibleAreaHeight","getPreviouslyCalculatedLayout","name","getValue","defaultValue","error","itemsCount","columnsCount","beforeStart","firstShownItemIndex","lastShownItemIndex","getLastShownItemIndex","getInitialLastShownItemIndex","getInitialLayoutValueWithFallback","beforeItemsHeight","afterItemsHeight","estimatedRowsCount","getEstimatedRowsCountForHeight","isNaN","Error","Math","min","height","estimatedItemHeight","getEstimatedItemHeight","verticalSpacing","ceil","averageItemHeight","prependedItemsCount","appendedItemsCount","shouldRestoreScrollPosition","onResetGridLayout","appendedRowsCount","addedHeightAfter","prependedRowsCount","addedHeightBefore","shownItemsCountBeforeItemsUpdate","afterItemsCount","i","nonMeasuredAreaHeight","indexOfTheFirstItemInTheRow","itemsCountToRenderForMeasurement","Infinity","undefined","firstNonMeasuredItemIndex","visibleAreaTop","visibleAreaBottom","indexes","_getShownItemIndex","fromIndex","findFirstShownItemIndex","getNonVisibleListShownItemIndexes","findLastShownItemIndex","parameters","beforeResize","beforeResizeItemsCount","notFound","beforeResizeItemsHeight","floor","currentRowFirstItemIndex","hasMoreRows","verticalSpacingAfterCurrentRow","currentRowHeight","columnIndex","itemHeight","getItemNotMeasuredIndexes","max","itemsHeightFromFirstRowToThisRow","rowStepsIntoVisibleAreaTop","rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder","layout","beforeItemsCount","getBeforeItemsHeight","rowHeight","lastShownRowIndex","topOffsetInsideScrollableContainer","beforeResizeRowsCount","maxBeforeResizeRowsCount","beforeResizeRowIndex","itemRowIndex","rowIndex","LAYOUT_REASON","SCROLL","STOPPED_SCROLLING","MANUAL","STARTED","NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED","VIEWPORT_WIDTH_CHANGED","VIEWPORT_HEIGHT_CHANGED","VIEWPORT_SIZE_UNCHANGED","ITEM_HEIGHT_CHANGED","ITEMS_CHANGED","TOP_OFFSET_CHANGED"],"sources":["../source/Layout.js"],"sourcesContent":["import log, { warn } from './utility/debug.js'\r\nimport ScrollableContainerNotReadyError from './ScrollableContainerNotReadyError.js'\r\n\r\nexport default class Layout {\r\n\tconstructor({\r\n\t\tbypass,\r\n\t\tgetInitialEstimatedItemHeight,\r\n\t\tgetInitialEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tgetPrerenderMargin,\r\n\t\tgetVerticalSpacing,\r\n\t\tgetVerticalSpacingBeforeResize,\r\n\t\tgetColumnsCount,\r\n\t\tgetColumnsCountBeforeResize,\r\n\t\tgetItemHeight,\r\n\t\tgetItemHeightBeforeResize,\r\n\t\tgetBeforeResizeItemsCount,\r\n\t\tgetAverageItemHeight,\r\n\t\tgetMaxVisibleAreaHeight,\r\n\t\tgetPreviouslyCalculatedLayout\r\n\t}) {\r\n\t\tthis.bypass = bypass\r\n\t\tthis.getInitialEstimatedItemHeight = getInitialEstimatedItemHeight\r\n\t\tthis.getInitialEstimatedVisibleItemRowsCount = getInitialEstimatedVisibleItemRowsCount\r\n\t\tthis.measureItemsBatchSize = measureItemsBatchSize\r\n\t\tthis.getPrerenderMargin = getPrerenderMargin\r\n\t\tthis.getVerticalSpacing = getVerticalSpacing\r\n\t\tthis.getVerticalSpacingBeforeResize = getVerticalSpacingBeforeResize\r\n\t\tthis.getColumnsCount = getColumnsCount\r\n\t\tthis.getColumnsCountBeforeResize = getColumnsCountBeforeResize\r\n\t\tthis.getItemHeight = getItemHeight\r\n\t\tthis.getItemHeightBeforeResize = getItemHeightBeforeResize\r\n\t\tthis.getBeforeResizeItemsCount = getBeforeResizeItemsCount\r\n\t\tthis.getAverageItemHeight = getAverageItemHeight\r\n\t\tthis.getMaxVisibleAreaHeight = getMaxVisibleAreaHeight\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\tthis.getPreviouslyCalculatedLayout = getPreviouslyCalculatedLayout\r\n\t}\r\n\r\n\t// React `<VirtualScroller/>` component attempts to create the initial state\r\n\t// before the component tree has mounted. This could result in an inability to\r\n\t// calculate some initial layout values like `columnsCount` or `lastShownItemIndex`.\r\n\t// Such errors aren't considered critical because layout will be re-calculated\r\n\t// after the component mounts. The workaround is to use some sane default values\r\n\t// until the scrollable container has mounted.\r\n\tgetInitialLayoutValueWithFallback(name, getValue, defaultValue) {\r\n\t\ttry {\r\n\t\t\treturn getValue()\r\n\t\t} catch (error) {\r\n\t\t\tif (error instanceof ScrollableContainerNotReadyError) {\r\n\t\t\t\tlog(`Scrollable container size is not known at this point, so \"${name}\" can't be calculated yet. Default to`, defaultValue);\r\n\t\t\t\treturn defaultValue\r\n\t\t\t} else {\r\n\t\t\t\tthrow error\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetInitialLayoutValues({\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tbeforeStart\r\n\t}) {\r\n\t\tlet firstShownItemIndex\r\n\t\tlet lastShownItemIndex\r\n\t\t// If there're no items then `firstShownItemIndex` stays `undefined`.\r\n\t\tif (itemsCount > 0) {\r\n\t\t\tconst getLastShownItemIndex = () => {\r\n\t\t\t\treturn this.getInitialLastShownItemIndex({\r\n\t\t\t\t\titemsCount,\r\n\t\t\t\t\tcolumnsCount,\r\n\t\t\t\t\tfirstShownItemIndex\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t\tfirstShownItemIndex = 0\r\n\t\t\tlastShownItemIndex = beforeStart\r\n\t\t\t\t? this.getInitialLayoutValueWithFallback(\r\n\t\t\t\t\t'lastShownItemIndex',\r\n\t\t\t\t\tgetLastShownItemIndex,\r\n\t\t\t\t\t0\r\n\t\t\t\t)\r\n\t\t\t\t: getLastShownItemIndex()\r\n\t\t}\r\n\t\treturn {\r\n\t\t\tbeforeItemsHeight: 0,\r\n\t\t\tafterItemsHeight: 0,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\tgetInitialLastShownItemIndex({\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tfirstShownItemIndex\r\n\t}) {\r\n\t\tif (this.bypass) {\r\n\t\t\treturn itemsCount - 1\r\n\t\t}\r\n\t\t// On server side, at initialization time,\r\n\t\t// `scrollableContainer` is `undefined`,\r\n\t\t// so default to `1` estimated rows count.\r\n\t\tlet estimatedRowsCount = 1\r\n\t\tif (this.getMaxVisibleAreaHeight()) {\r\n\t\t\testimatedRowsCount = this.getEstimatedRowsCountForHeight(this.getMaxVisibleAreaHeight() + this.getPrerenderMargin())\r\n\t\t} else if (this.getInitialEstimatedVisibleItemRowsCount) {\r\n\t\t\testimatedRowsCount = this.getInitialEstimatedVisibleItemRowsCount()\r\n\t\t\tif (isNaN(estimatedRowsCount)) {\r\n\t\t\t\tthrow new Error('[virtual-scroller] `getEstimatedVisibleItemRowsCount()` must return a number')\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn Math.min(\r\n\t\t\tfirstShownItemIndex + (estimatedRowsCount * columnsCount - 1),\r\n\t\t\titemsCount - 1\r\n\t\t)\r\n\t}\r\n\r\n\tgetEstimatedRowsCountForHeight(height) {\r\n\t\tconst estimatedItemHeight = this.getEstimatedItemHeight()\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\t\tif (estimatedItemHeight) {\r\n\t\t\treturn Math.ceil((height + verticalSpacing) / (estimatedItemHeight + verticalSpacing))\r\n\t\t} else {\r\n\t\t\t// If no items have been rendered yet, and no `estimatedItemHeight` option\r\n\t\t\t// has been passed, then default to `1` estimated rows count in any `height`.\r\n\t\t\treturn 1\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns estimated list item height.\r\n\t * (depends on which items have been previously rendered and measured).\r\n\t * @return {number}\r\n\t */\r\n\tgetEstimatedItemHeight() {\r\n\t\tconst averageItemHeight = this.getAverageItemHeight()\r\n\t\tif (averageItemHeight) {\r\n\t\t\treturn averageItemHeight\r\n\t\t}\r\n\t\tif (this.getInitialEstimatedItemHeight) {\r\n\t\t\tconst estimatedItemHeight = this.getInitialEstimatedItemHeight()\r\n\t\t\tif (isNaN(estimatedItemHeight)) {\r\n\t\t\t\tthrow new Error('[virtual-scroller] `getInitialEstimatedItemHeight()` must return a number')\r\n\t\t\t}\r\n\t\t\treturn estimatedItemHeight\r\n\t\t}\r\n\t\treturn 0\r\n\t}\r\n\r\n\tgetLayoutUpdateForItemsDiff({\r\n\t\tfirstShownItemIndex,\r\n\t\tlastShownItemIndex,\r\n\t\tbeforeItemsHeight,\r\n\t\tafterItemsHeight\r\n\t}, {\r\n\t\tprependedItemsCount,\r\n\t\tappendedItemsCount\r\n\t}, {\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tshouldRestoreScrollPosition,\r\n\t\tonResetGridLayout\r\n\t}) {\r\n\t\t// const layoutUpdate = {}\r\n\r\n\t\t// If the layout stays the same, then simply increase\r\n\t\t// the top and bottom margins proportionally to the amount\r\n\t\t// of the items added.\r\n\t\tconst averageItemHeight = this.getAverageItemHeight()\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\r\n\t\tif (appendedItemsCount > 0) {\r\n\t\t\tconst appendedRowsCount = Math.ceil(appendedItemsCount / columnsCount)\r\n\t\t\tconst addedHeightAfter = appendedRowsCount * (verticalSpacing + averageItemHeight)\r\n\r\n\t\t\tafterItemsHeight += addedHeightAfter\r\n\r\n\t\t\t// layoutUpdate = {\r\n\t\t\t// \t...layoutUpdate,\r\n\t\t\t// \tafterItemsHeight\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\tif (prependedItemsCount > 0) {\r\n\t\t\tconst prependedRowsCount = Math.ceil(prependedItemsCount / columnsCount)\r\n\t\t\tconst addedHeightBefore = prependedRowsCount * (averageItemHeight + verticalSpacing)\r\n\r\n\t\t\tfirstShownItemIndex += prependedItemsCount\r\n\t\t\tlastShownItemIndex += prependedItemsCount\r\n\t\t\tbeforeItemsHeight += addedHeightBefore\r\n\r\n\t\t\t// If the currently shown items position on screen should be preserved\r\n\t\t\t// when prepending new items, then it means that:\r\n\t\t\t// * The current scroll position should be snapshotted.\r\n\t\t\t// * The current list height should be snapshotted.\r\n\t\t\t// * All prepended items should be shown so that their height could be\r\n\t\t\t// measured after they're rendered. Based on the prepended items' height,\r\n\t\t\t// the scroll position will be restored so that there's no \"jump of content\".\r\n\t\t\tif (shouldRestoreScrollPosition) {\r\n\t\t\t\tfirstShownItemIndex = 0\r\n\t\t\t\tbeforeItemsHeight = 0\r\n\t\t\t}\r\n\r\n\t\t\tif (prependedItemsCount % columnsCount > 0) {\r\n\t\t\t\t// Rows will be rebalanced as a result of prepending new items,\r\n\t\t\t\t// and row heights can change as a result, so re-layout items\r\n\t\t\t\t// after they've been measured (after the upcoming re-render).\r\n\t\t\t\t//\r\n\t\t\t\t// For example, consider a web page where item rows are `display: flex`.\r\n\t\t\t\t// Suppose there're 3 columns and it shows items from 4 to 6.\r\n\t\t\t\t//\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Apples are | Bananas | Cranberries |\r\n\t\t\t\t// | green | | |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Dates | Elderberry | Figs are |\r\n\t\t\t\t// | | | tasty |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t//\r\n\t\t\t\t// Now, 1 item gets prepended. As a result, all existing rows will have\r\n\t\t\t\t// a different set of items, which means that the row heights will change.\r\n\t\t\t\t//\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Zucchini | Apples are | Bananas |\r\n\t\t\t\t// | | green | |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Cranberries | Dates | Elderberry |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Figs |\r\n\t\t\t\t// | are tasty |\r\n\t\t\t\t// ---------------\r\n\t\t\t\t//\r\n\t\t\t\t// As it can be seen above, the second row's height has changed from 2 to 1.\r\n\t\t\t\t// Not only that, but `itemHeights` have changed as well, so if you thought\r\n\t\t\t\t// that the library could easily recalculate row heights using `Math.max()` — \r\n\t\t\t\t// turns out it's not always the case.\r\n\t\t\t\t//\r\n\t\t\t\t// There could be an explicit opt-in option for automatically recalculating\r\n\t\t\t\t// row heights, but I don't want to write code for such an extremely rare\r\n\t\t\t\t// use case. Instead, use the `getColumnsCount()` parameter function when\r\n\t\t\t\t// fetching previous items.\r\n\r\n\t\t\t\tonResetGridLayout()\r\n\r\n\t\t\t\twarn('~ Prepended items count', prependedItemsCount, 'is not divisible by Columns Count', columnsCount, '~')\r\n\t\t\t\twarn('Layout reset required')\r\n\r\n\t\t\t\tconst shownItemsCountBeforeItemsUpdate = lastShownItemIndex - firstShownItemIndex + 1\r\n\r\n\t\t\t\tfirstShownItemIndex = 0\r\n\t\t\t\tbeforeItemsHeight = 0\r\n\r\n\t\t\t\tif (!shouldRestoreScrollPosition) {\r\n\t\t\t\t\t// Limit shown items count if too many items have been prepended.\r\n\t\t\t\t\tif (prependedItemsCount > shownItemsCountBeforeItemsUpdate) {\r\n\t\t\t\t\t\tlastShownItemIndex = this.getInitialLastShownItemIndex({\r\n\t\t\t\t\t\t\titemsCount,\r\n\t\t\t\t\t\t\tcolumnsCount,\r\n\t\t\t\t\t\t\tfirstShownItemIndex\r\n\t\t\t\t\t\t})\r\n\r\n\t\t\t\t\t\t// Approximate `afterItemsHeight` calculation.\r\n\t\t\t\t\t\tconst afterItemsCount = itemsCount - (lastShownItemIndex + 1)\r\n\t\t\t\t\t\tafterItemsHeight = Math.ceil(afterItemsCount / columnsCount) * (verticalSpacing + averageItemHeight)\r\n\r\n\t\t\t\t\t\t// layoutUpdate = {\r\n\t\t\t\t\t\t// \t...layoutUpdate,\r\n\t\t\t\t\t\t// \tafterItemsHeight\r\n\t\t\t\t\t\t// }\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// layoutUpdate = {\r\n\t\t\t// \t...layoutUpdate,\r\n\t\t\t// \tbeforeItemsHeight,\r\n\t\t\t// \tfirstShownItemIndex,\r\n\t\t\t// \tlastShownItemIndex\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\t// return layoutUpdate\r\n\r\n\t\t// Overwrite all four props in all scenarios.\r\n\t\t// The reason is that only this way subsequent `setItems()` calls\r\n\t\t// will be truly \"stateless\" when a chain of `setItems()` calls\r\n\t\t// could be replaced with just the last one in a scenario when\r\n\t\t// `updateState()` calls are \"asynchronous\" (delayed execution).\r\n\t\t//\r\n\t\t// So, for example, the user calls `setItems()` with one set of items.\r\n\t\t// A `updateState()` call has been dispatched but the `state` hasn't been updated yet.\r\n\t\t// Then the user calls `setItems()` with another set of items.\r\n\t\t// If this function only returned a minimal set of properties that actually change,\r\n\t\t// the other layout properties of the second `setItems()` call wouldn't overwrite the ones\r\n\t\t// scheduled for update during the first `setItems()` call, resulting in an inconsistent `state`.\r\n\t\t//\r\n\t\t// For example, the first `setItems()` call does a `updateState()` call where it updates\r\n\t\t// `afterItemsHeight`, and then the second `setItems()` call only updates `beforeItemsHeight`\r\n\t\t// and `firstShownItemIndex` and `lastShownItemIndex`. If the second `setItems()` call was to\r\n\t\t// overwrite any effects of the pending-but-not-yet-applied first `setItems()` call, it would\r\n\t\t// have to call `updateState()` with an `afterItemsHeight` property too, even though it hasn't change.\r\n\t\t// That would be just to revert the change to `afterItemsHeight` state property already scheduled\r\n\t\t// by the first `setItems()` call.\r\n\t\t//\r\n\t\treturn {\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t// If an item that hasn't been shown (and measured) yet is encountered\r\n\t// then show such item and then retry after it has been measured.\r\n\tgetItemNotMeasuredIndexes(i, {\r\n\t\titemsCount,\r\n\t\tfirstShownItemIndex,\r\n\t\tnonMeasuredAreaHeight,\r\n\t\tindexOfTheFirstItemInTheRow\r\n\t}) {\r\n\t\tlog('Item index', i, 'height is required for calculations but hasn\\'t been measured yet. Mark the item as \"shown\", rerender the list, measure the item\\'s height and redo the layout.')\r\n\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\r\n\t\tconst itemsCountToRenderForMeasurement = Math.min(\r\n\t\t\tthis.getEstimatedRowsCountForHeight(nonMeasuredAreaHeight) * columnsCount,\r\n\t\t\tthis.measureItemsBatchSize || Infinity,\r\n\t\t)\r\n\r\n\t\tif (firstShownItemIndex === undefined) {\r\n\t\t\tfirstShownItemIndex = indexOfTheFirstItemInTheRow\r\n\t\t}\r\n\r\n\t\tconst lastShownItemIndex = Math.min(\r\n\t\t\tindexOfTheFirstItemInTheRow + itemsCountToRenderForMeasurement - 1,\r\n\t\t\t// Guard against index overflow.\r\n\t\t\titemsCount - 1\r\n\t\t)\r\n\r\n\t\treturn {\r\n\t\t\tfirstNonMeasuredItemIndex: i,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Finds the indexes of the currently visible items.\r\n\t * @return {object} `{ firstShownItemIndex: number, lastShownItemIndex: number, firstNonMeasuredItemIndex: number? }`\r\n\t */\r\n\tgetShownItemIndexes({\r\n\t\titemsCount,\r\n\t\tvisibleAreaTop,\r\n\t\tvisibleAreaBottom\r\n\t}) {\r\n\t\tlet indexes = this._getShownItemIndex({\r\n\t\t\titemsCount,\r\n\t\t\tfromIndex: 0,\r\n\t\t\tvisibleAreaTop,\r\n\t\t\tvisibleAreaBottom,\r\n\t\t\tfindFirstShownItemIndex: true\r\n\t\t})\r\n\r\n\t\tif (indexes === null) {\r\n\t\t\treturn this.getNonVisibleListShownItemIndexes()\r\n\t\t}\r\n\r\n\t\tif (indexes.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\treturn indexes\r\n\t\t}\r\n\r\n\t\tconst { firstShownItemIndex, beforeItemsHeight } = indexes\r\n\r\n\t\tindexes = this._getShownItemIndex({\r\n\t\t\titemsCount,\r\n\t\t\tfromIndex: firstShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tvisibleAreaTop,\r\n\t\t\tvisibleAreaBottom,\r\n\t\t\tfindLastShownItemIndex: true\r\n\t\t})\r\n\r\n\t\tif (indexes === null) {\r\n\t\t\treturn this.getNonVisibleListShownItemIndexes()\r\n\t\t}\r\n\r\n\t\tif (indexes.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\treturn indexes\r\n\t\t}\r\n\r\n\t\tconst { lastShownItemIndex } = indexes\r\n\r\n\t\treturn {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t_getShownItemIndex(parameters) {\r\n\t\tconst {\r\n\t\t\tbeforeResize,\r\n\t\t\titemsCount,\r\n\t\t\tvisibleAreaTop,\r\n\t\t\tvisibleAreaBottom,\r\n\t\t\tfindFirstShownItemIndex,\r\n\t\t\tfindLastShownItemIndex,\r\n\t\t\t// backwards\r\n\t\t} = parameters\r\n\r\n\t\tlet {\r\n\t\t\tfromIndex,\r\n\t\t\tbeforeItemsHeight\r\n\t\t} = parameters\r\n\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\t\t//\r\n\t\t// If someone would attempt to use a \"previously calculated layout\" here\r\n\t\t// then `shownItemsHeight` would also have to be returned from this function:\r\n\t\t// the total height of all shown items including vertical spacing between them.\r\n\t\t//\r\n\t\t// If \"previously calculated layout\" would be used then it would first find\r\n\t\t// `firstShownItemIndex` and then find `lastShownItemIndex` as part of two\r\n\t\t// separate calls of this function, each with or without `backwards` flag,\r\n\t\t// depending on whether `visibleAreaTop` and `visibleAreBottom` have shifted up or down.\r\n\r\n\t\tlet firstShownItemIndex\r\n\t\tlet lastShownItemIndex\r\n\r\n\t\t// It's not always required to pass `beforeItemsHeight` parameter:\r\n\t\t// when `fromIndex` is `0`, it's also assumed to be `0`.\r\n\t\tif (fromIndex === 0) {\r\n\t\t\tbeforeItemsHeight = 0\r\n\t\t}\r\n\r\n\t\tif (beforeItemsHeight === undefined) {\r\n\t\t\tthrow new Error('[virtual-scroller] `beforeItemsHeight` not passed to `Layout.getShownItemIndexes()` when starting from index ' + fromIndex);\r\n\t\t}\r\n\r\n\t\t// const backwards = false\r\n\t\t// while (backwards ? i >= 0 : i < itemsCount) {}\r\n\r\n\t\tif (!beforeResize) {\r\n\t\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\t\t\tif (beforeResizeItemsCount > fromIndex) {\r\n\t\t\t\t// First search for the item in \"before resize\" items.\r\n\t\t\t\tconst {\r\n\t\t\t\t\tnotFound,\r\n\t\t\t\t\tbeforeItemsHeight: beforeResizeItemsHeight,\r\n\t\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\t\tlastShownItemIndex\r\n\t\t\t\t} = this._getShownItemIndex({\r\n\t\t\t\t\t...parameters,\r\n\t\t\t\t\tbeforeResize: true,\r\n\t\t\t\t\titemsCount: beforeResizeItemsCount\r\n\t\t\t\t})\r\n\r\n\t\t\t\t// If the item was not found in \"before resize\" items\r\n\t\t\t\t// then search in regular items skipping \"before resize\" ones.\r\n\t\t\t\tif (notFound) {\r\n\t\t\t\t\tbeforeItemsHeight = beforeResizeItemsHeight\r\n\t\t\t\t\tfromIndex += beforeResizeItemsCount\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// If the item was found in \"before resize\" items\r\n\t\t\t\t\t// then return the result.\r\n\t\t\t\t\t// Rebalance first / last shown item indexes based on\r\n\t\t\t\t\t// the current columns count, if required.\r\n\t\t\t\t\tconst columnsCount = this.getColumnsCount()\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tfirstShownItemIndex: firstShownItemIndex === undefined\r\n\t\t\t\t\t\t\t? undefined\r\n\t\t\t\t\t\t\t: Math.floor(firstShownItemIndex / columnsCount) * columnsCount,\r\n\t\t\t\t\t\tlastShownItemIndex: lastShownItemIndex === undefined\r\n\t\t\t\t\t\t\t? undefined\r\n\t\t\t\t\t\t\t: Math.floor(lastShownItemIndex / columnsCount) * columnsCount,\r\n\t\t\t\t\t\tbeforeItemsHeight: beforeResizeItemsHeight\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst columnsCount = beforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\tconst verticalSpacing = beforeResize ? this.getVerticalSpacingBeforeResize() : this.getVerticalSpacing()\r\n\r\n\t\tlet i = fromIndex\r\n\t\twhile (i < itemsCount) {\r\n\t\t\tconst currentRowFirstItemIndex = i\r\n\r\n\t\t\tconst hasMoreRows = itemsCount > currentRowFirstItemIndex + columnsCount\r\n\t\t\tconst verticalSpacingAfterCurrentRow = hasMoreRows ? verticalSpacing : 0\r\n\r\n\t\t\tlet currentRowHeight = 0\r\n\r\n\t\t\t// Calculate current row height.\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < columnsCount && i < itemsCount) {\r\n\t\t\t\tconst itemHeight = beforeResize ? this.getItemHeightBeforeResize(i) : this.getItemHeight(i)\r\n\r\n\t\t\t\t// If this item hasn't been measured yet (or re-measured after a resize)\r\n\t\t\t\t// then mark it as the first non-measured one.\r\n\t\t\t\t//\r\n\t\t\t\t// Can't happen by definition when `beforeResize` parameter is `true`.\r\n\t\t\t\t//\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\treturn this.getItemNotMeasuredIndexes(i, {\r\n\t\t\t\t\t\titemsCount,\r\n\t\t\t\t\t\tfirstShownItemIndex: findLastShownItemIndex ? fromIndex : undefined,\r\n\t\t\t\t\t\tindexOfTheFirstItemInTheRow: currentRowFirstItemIndex,\r\n\t\t\t\t\t\tnonMeasuredAreaHeight: (visibleAreaBottom + this.getPrerenderMargin()) - beforeItemsHeight\r\n\t\t\t\t\t})\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcurrentRowHeight = Math.max(currentRowHeight, itemHeight)\r\n\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t\ti++\r\n\t\t\t}\r\n\r\n\t\t\tconst itemsHeightFromFirstRowToThisRow = beforeItemsHeight + currentRowHeight\r\n\r\n\t\t\tconst rowStepsIntoVisibleAreaTop = itemsHeightFromFirstRowToThisRow > visibleAreaTop - this.getPrerenderMargin()\r\n\t\t\tconst rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder = itemsHeightFromFirstRowToThisRow + verticalSpacingAfterCurrentRow >= visibleAreaBottom + this.getPrerenderMargin()\r\n\r\n\t\t\t// if (backwards) {\r\n\t\t\t// \tif (findFirstShownItemIndex) {\r\n\t\t\t// \t\tif (rowStepsOutOfVisibleAreaTop) {\r\n\t\t\t// \t\t\treturn {\r\n\t\t\t// \t\t\t\tfirstShownItemIndex: currentRowFirstItemIndex + columnsCount\r\n\t\t\t// \t\t\t}\r\n\t\t\t// \t\t}\r\n\t\t\t// \t} else if (findLastShownItemIndex) {\r\n\t\t\t// \t\tif (rowStepsIntoVisibleAreaBottom) {\r\n\t\t\t// \t\t\treturn {\r\n\t\t\t// \t\t\t\tlastShownItemIndex: currentRowFirstItemIndex + columnsCount - 1\r\n\t\t\t// \t\t\t}\r\n\t\t\t// \t\t}\r\n\t\t\t// \t}\r\n\t\t\t// }\r\n\r\n\t\t\tif (findFirstShownItemIndex) {\r\n\t\t\t\tif (rowStepsIntoVisibleAreaTop) {\r\n\t\t\t\t\t// If item is the first one visible in the viewport\r\n\t\t\t\t\t// then start showing items from this row.\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tfirstShownItemIndex: currentRowFirstItemIndex,\r\n\t\t\t\t\t\tbeforeItemsHeight\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else if (findLastShownItemIndex) {\r\n\t\t\t\tif (rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder) {\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tlastShownItemIndex: Math.min(\r\n\t\t\t\t\t\t\t// The index of the last item in the current row.\r\n\t\t\t\t\t\t\tcurrentRowFirstItemIndex + columnsCount - 1,\r\n\t\t\t\t\t\t\t// Guards against index overflow.\r\n\t\t\t\t\t\t\titemsCount - 1\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbeforeItemsHeight += currentRowHeight + verticalSpacingAfterCurrentRow\r\n\r\n\t\t\t// if (backwards) {\r\n\t\t\t// \t// Set `i` to be the first item of the current row.\r\n\t\t\t// \ti -= columnsCount\r\n\t\t\t// \tconst prevoiusRowIsBeforeResize = i - 1 < this.getBeforeResizeItemsCount()\r\n\t\t\t// \tconst previousRowColumnsCount = prevoiusRowIsBeforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\t\t// \t// Set `i` to be the first item of the previous row.\r\n\t\t\t// \ti -= previousRowColumnsCount\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\t// if (backwards) {\r\n\t\t// \tif (findFirstShownItemIndex) {\r\n\t\t// \t\twarn('The list is supposed to be visible but no visible item has been found (while traversing backwards)')\r\n\t\t// \t\treturn null\r\n\t\t// \t} else if (findLastShownItemIndex) {\r\n\t\t// \t\treturn {\r\n\t\t// \t\t\tfirstShownItemIndex: 0\r\n\t\t// \t\t}\r\n\t\t// \t}\r\n\t\t// }\r\n\r\n\t\tif (beforeResize) {\r\n\t\t\treturn {\r\n\t\t\t\tnotFound: true,\r\n\t\t\t\tbeforeItemsHeight\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// This case isn't supposed to happen but it could hypothetically happen\r\n\t\t// because the list height is measured from the user's screen and\r\n\t\t// not necessarily can be trusted.\r\n\t\tif (findFirstShownItemIndex) {\r\n\t\t\twarn('The list is supposed to be visible but no visible item has been found')\r\n\t\t\treturn null\r\n\t\t} else if (findLastShownItemIndex) {\r\n\t\t\treturn {\r\n\t\t\t\tlastShownItemIndex: itemsCount - 1\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetNonVisibleListShownItemIndexes() {\r\n\t\tconst layout = {\r\n\t\t\tfirstShownItemIndex: 0,\r\n\t\t\tlastShownItemIndex: 0\r\n\t\t}\r\n\t\tif (this.getItemHeight(0) === undefined) {\r\n\t\t\tlayout.firstNonMeasuredItemIndex = 0\r\n\t\t}\r\n\t\treturn layout\r\n\t}\r\n\r\n\t/**\r\n\t * Measures \"before\" items height.\r\n\t * @param {number} beforeItemsCount — Basically, first shown item index.\r\n\t * @return {number}\r\n\t */\r\n\tgetBeforeItemsHeight(\r\n\t\tbeforeItemsCount,\r\n\t\t{ beforeResize } = {}\r\n\t) {\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\r\n\t\tlet beforeItemsHeight = 0\r\n\t\tlet i = 0\r\n\r\n\t\tif (!beforeResize) {\r\n\t\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\r\n\t\t\tif (beforeResizeItemsCount > 0) {\r\n\t\t\t\t// First add all \"before resize\" item heights.\r\n\t\t\t\tbeforeItemsHeight = this.getBeforeItemsHeight(\r\n\t\t\t\t\t// `firstShownItemIndex` (called `beforeItemsCount`) could be greater than\r\n\t\t\t\t\t// `beforeResizeItemsCount` when the user scrolls down.\r\n\t\t\t\t\t// `firstShownItemIndex` (called `beforeItemsCount`) could be less than\r\n\t\t\t\t\t// `beforeResizeItemsCount` when the user scrolls up.\r\n\t\t\t\t\tMath.min(beforeItemsCount, beforeResizeItemsCount),\r\n\t\t\t\t\t{ beforeResize: true }\r\n\t\t\t\t)\r\n\t\t\t\ti = beforeResizeItemsCount\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst columnsCount = beforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\tconst verticalSpacing = beforeResize ? this.getVerticalSpacingBeforeResize() : this.getVerticalSpacing()\r\n\r\n\t\twhile (i < beforeItemsCount) {\r\n\t\t\tconst currentRowFirstItemIndex = i\r\n\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\t// Not checking for `itemsCount` overflow here because `i = beforeItemsCount`\r\n\t\t\t// can only start at the start of a row, meaning that when calculating\r\n\t\t\t// \"before items height\" it's not supposed to add item heights from the\r\n\t\t\t// last row of items because in that case it would have to iterate from\r\n\t\t\t// `i === beforeItemsCount` and that condition is already checked above.\r\n\t\t\t// while (i < itemsCount) {\r\n\t\t\twhile (columnIndex < columnsCount) {\r\n\t\t\t\tlet itemHeight = beforeResize ? this.getItemHeightBeforeResize(i) : this.getItemHeight(i)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\t// `itemHeight` can only be `undefined` when not `beforeResize`.\r\n\t\t\t\t\t// Use the current \"average item height\" as a substitute.\r\n\t\t\t\t\titemHeight = this.getAverageItemHeight()\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\ti++\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\tbeforeItemsHeight += rowHeight\r\n\t\t\tbeforeItemsHeight += verticalSpacing\r\n\t\t}\r\n\r\n\t\treturn beforeItemsHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Measures \"after\" items height.\r\n\t * @param {number} lastShownItemIndex — Last shown item index.\r\n\t * @param {number} itemsCount — Items count.\r\n\t * @return {number}\r\n\t */\r\n\tgetAfterItemsHeight(\r\n\t\tlastShownItemIndex,\r\n\t\titemsCount\r\n\t) {\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\t\tconst lastShownRowIndex = Math.floor(lastShownItemIndex / columnsCount)\r\n\r\n\t\tlet afterItemsHeight = 0\r\n\r\n\t\tlet i = lastShownItemIndex + 1\r\n\t\twhile (i < itemsCount) {\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < columnsCount && i < itemsCount) {\r\n\t\t\t\tlet itemHeight = this.getItemHeight(i)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\titemHeight = this.getAverageItemHeight()\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\ti++\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\t// Add all \"after\" items height.\r\n\t\t\tafterItemsHeight += this.getVerticalSpacing()\r\n\t\t\tafterItemsHeight += rowHeight\r\n\t\t}\r\n\r\n\t\treturn afterItemsHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the items's top offset relative to the top edge of the first item.\r\n\t * @param {number} i — Item index\r\n\t * @return {[number]} Returns `undefined` if any of the previous items haven't been rendered yet.\r\n\t */\r\n\tgetItemTopOffset(i) {\r\n\t\tlet topOffsetInsideScrollableContainer = 0\r\n\r\n\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\t\tconst beforeResizeRowsCount = beforeResizeItemsCount === 0\r\n\t\t\t? 0\r\n\t\t\t: Math.ceil(beforeResizeItemsCount / this.getColumnsCountBeforeResize())\r\n\r\n\t\tconst maxBeforeResizeRowsCount = i < beforeResizeItemsCount\r\n\t\t\t? Math.floor(i / this.getColumnsCountBeforeResize())\r\n\t\t\t: beforeResizeRowsCount\r\n\r\n\t\tlet beforeResizeRowIndex = 0\r\n\t\twhile (beforeResizeRowIndex < maxBeforeResizeRowsCount) {\r\n\t\t\tconst rowHeight = this.getItemHeightBeforeResize(\r\n\t\t\t\tbeforeResizeRowIndex * this.getColumnsCountBeforeResize()\r\n\t\t\t)\r\n\r\n\t\t\ttopOffsetInsideScrollableContainer += rowHeight\r\n\t\t\ttopOffsetInsideScrollableContainer += this.getVerticalSpacingBeforeResize()\r\n\r\n\t\t\tbeforeResizeRowIndex++\r\n\t\t}\r\n\r\n\t\tconst itemRowIndex = Math.floor((i - beforeResizeItemsCount) / this.getColumnsCount())\r\n\r\n\t\tlet rowIndex = 0\r\n\t\twhile (rowIndex < itemRowIndex) {\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < this.getColumnsCount()) {\r\n\t\t\t\tconst itemHeight = this.getItemHeight(\r\n\t\t\t\t\tbeforeResizeItemsCount + rowIndex * this.getColumnsCount() + columnIndex\r\n\t\t\t\t)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\ttopOffsetInsideScrollableContainer += rowHeight\r\n\t\t\ttopOffsetInsideScrollableContainer += this.getVerticalSpacing()\r\n\r\n\t\t\trowIndex++\r\n\t\t}\r\n\r\n\t\treturn topOffsetInsideScrollableContainer\r\n\t}\r\n}\r\n\r\nexport const LAYOUT_REASON = {\r\n\tSCROLL: 'scroll',\r\n\tSTOPPED_SCROLLING: 'stopped scrolling',\r\n\tMANUAL: 'manual',\r\n\tSTARTED: 'started',\r\n\tNON_MEASURED_ITEMS_HAVE_BEEN_MEASURED: 'non-measured item heights have been measured',\r\n\tVIEWPORT_WIDTH_CHANGED: 'viewport width changed',\r\n\tVIEWPORT_HEIGHT_CHANGED: 'viewport height changed',\r\n\tVIEWPORT_SIZE_UNCHANGED: 'viewport size unchanged',\r\n\tITEM_HEIGHT_CHANGED: 'item height changed',\r\n\tITEMS_CHANGED: 'items changed',\r\n\tTOP_OFFSET_CHANGED: 'list top offset changed'\r\n}"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,GAAP,IAAcC,IAAd,QAA0B,oBAA1B;AACA,OAAOC,gCAAP,MAA6C,uCAA7C;;IAEqBC,M;EACpB,sBAgBG;IAAA,IAfFC,MAeE,QAfFA,MAeE;IAAA,IAdFC,6BAcE,QAdFA,6BAcE;IAAA,IAbFC,uCAaE,QAbFA,uCAaE;IAAA,IAZFC,qBAYE,QAZFA,qBAYE;IAAA,IAXFC,kBAWE,QAXFA,kBAWE;IAAA,IAVFC,kBAUE,QAVFA,kBAUE;IAAA,IATFC,8BASE,QATFA,8BASE;IAAA,IARFC,eAQE,QARFA,eAQE;IAAA,IAPFC,2BAOE,QAPFA,2BAOE;IAAA,IANFC,aAME,QANFA,aAME;IAAA,IALFC,yBAKE,QALFA,yBAKE;IAAA,IAJFC,yBAIE,QAJFA,yBAIE;IAAA,IAHFC,oBAGE,QAHFA,oBAGE;IAA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,YAAY,GAAG3D,IAAI,CAACsC,KAAL,CAAW,CAACpB,CAAC,GAAGiB,sBAAL,IAA+B,KAAK7D,eAAL,EAA1C,CAArB;MAEA,IAAIsF,QAAQ,GAAG,CAAf;;MACA,OAAOA,QAAQ,GAAGD,YAAlB,EAAgC;QAC/B,IAAIN,UAAS,GAAG,CAAhB;QACA,IAAIV,WAAW,GAAG,CAAlB;;QACA,OAAOA,WAAW,GAAG,KAAKrE,eAAL,EAArB,EAA6C;UAC5C,IAAMsE,UAAU,GAAG,KAAKpE,aAAL,CAClB2D,sBAAsB,GAAGyB,QAAQ,GAAG,KAAKtF,eAAL,EAApC,GAA6DqE,WAD3C,CAAnB;;UAGA,IAAIC,UAAU,KAAKrB,SAAnB,EAA8B;YAC7B;UACA;;UACD8B,UAAS,GAAGrD,IAAI,CAAC8C,GAAL,CAASO,UAAT,EAAoBT,UAApB,CAAZ;UACAD,WAAW;QACX;;QAEDY,kCAAkC,IAAIF,UAAtC;QACAE,kCAAkC,IAAI,KAAKnF,kBAAL,EAAtC;QAEAwF,QAAQ;MACR;;MAED,OAAOL,kCAAP;IACA;;;;;;SA/yBmBzF,M;AAkzBrB,OAAO,IAAM+F,aAAa,GAAG;EAC5BC,MAAM,EAAE,QADoB;EAE5BC,iBAAiB,EAAE,mBAFS;EAG5BC,MAAM,EAAE,QAHoB;EAI5BC,OAAO,EAAE,SAJmB;EAK5BC,qCAAqC,EAAE,8CALX;EAM5BC,sBAAsB,EAAE,wBANI;EAO5BC,uBAAuB,EAAE,yBAPG;EAQ5BC,uBAAuB,EAAE,yBARG;EAS5BC,mBAAmB,EAAE,qBATO;EAU5BC,aAAa,EAAE,eAVa;EAW5BC,kBAAkB,EAAE;AAXQ,CAAtB"}
|
|
1
|
+
{"version":3,"file":"Layout.js","names":["log","warn","ScrollableContainerNotReadyError","Layout","bypass","getInitialEstimatedItemHeight","getInitialEstimatedVisibleItemRowsCount","measureItemsBatchSize","getPrerenderMargin","getVerticalSpacing","getVerticalSpacingBeforeResize","getColumnsCount","getColumnsCountBeforeResize","getItemHeight","getItemHeightBeforeResize","getBeforeResizeItemsCount","getAverageItemHeight","getMaxVisibleAreaHeight","getPreviouslyCalculatedLayout","name","getValue","defaultValue","error","itemsCount","columnsCount","beforeStart","firstShownItemIndex","lastShownItemIndex","getLastShownItemIndex","getInitialLastShownItemIndex","getInitialLayoutValueWithFallback","beforeItemsHeight","afterItemsHeight","estimatedRowsCount","getEstimatedRowsCountForHeight","isNaN","Error","Math","min","height","estimatedItemHeight","getEstimatedItemHeight","verticalSpacing","ceil","averageItemHeight","prependedItemsCount","appendedItemsCount","shouldRestoreScrollPosition","onResetGridLayout","appendedRowsCount","addedHeightAfter","prependedRowsCount","addedHeightBefore","shownItemsCountBeforeItemsUpdate","afterItemsCount","i","nonMeasuredAreaHeight","indexOfTheFirstItemInTheRow","itemsCountToRenderForMeasurement","Infinity","undefined","firstNonMeasuredItemIndex","visibleAreaInsideTheList","indexes","_getShownItemIndex","fromIndex","findFirstShownItemIndex","getNonVisibleListShownItemIndexes","findLastShownItemIndex","parameters","beforeResize","beforeResizeItemsCount","notFound","beforeResizeItemsHeight","floor","currentRowFirstItemIndex","hasMoreRows","verticalSpacingAfterCurrentRow","currentRowHeight","columnIndex","itemHeight","getItemNotMeasuredIndexes","bottom","max","itemsHeightFromFirstRowToThisRow","rowStepsIntoVisibleAreaTop","top","rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder","layout","beforeItemsCount","getBeforeItemsHeight","rowHeight","lastShownRowIndex","topOffsetInsideScrollableContainer","beforeResizeRowsCount","maxBeforeResizeRowsCount","beforeResizeRowIndex","itemRowIndex","rowIndex","LAYOUT_REASON","SCROLL","STOPPED_SCROLLING","MANUAL","STARTED","NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED","VIEWPORT_WIDTH_CHANGED","VIEWPORT_HEIGHT_CHANGED","VIEWPORT_SIZE_UNCHANGED","ITEM_HEIGHT_CHANGED","ITEMS_CHANGED","TOP_OFFSET_CHANGED"],"sources":["../source/Layout.js"],"sourcesContent":["import log, { warn } from './utility/debug.js'\r\nimport ScrollableContainerNotReadyError from './ScrollableContainerNotReadyError.js'\r\n\r\nexport default class Layout {\r\n\tconstructor({\r\n\t\tbypass,\r\n\t\tgetInitialEstimatedItemHeight,\r\n\t\tgetInitialEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tgetPrerenderMargin,\r\n\t\tgetVerticalSpacing,\r\n\t\tgetVerticalSpacingBeforeResize,\r\n\t\tgetColumnsCount,\r\n\t\tgetColumnsCountBeforeResize,\r\n\t\tgetItemHeight,\r\n\t\tgetItemHeightBeforeResize,\r\n\t\tgetBeforeResizeItemsCount,\r\n\t\tgetAverageItemHeight,\r\n\t\tgetMaxVisibleAreaHeight,\r\n\t\tgetPreviouslyCalculatedLayout\r\n\t}) {\r\n\t\tthis.bypass = bypass\r\n\t\tthis.getInitialEstimatedItemHeight = getInitialEstimatedItemHeight\r\n\t\tthis.getInitialEstimatedVisibleItemRowsCount = getInitialEstimatedVisibleItemRowsCount\r\n\t\tthis.measureItemsBatchSize = measureItemsBatchSize\r\n\t\tthis.getPrerenderMargin = getPrerenderMargin\r\n\t\tthis.getVerticalSpacing = getVerticalSpacing\r\n\t\tthis.getVerticalSpacingBeforeResize = getVerticalSpacingBeforeResize\r\n\t\tthis.getColumnsCount = getColumnsCount\r\n\t\tthis.getColumnsCountBeforeResize = getColumnsCountBeforeResize\r\n\t\tthis.getItemHeight = getItemHeight\r\n\t\tthis.getItemHeightBeforeResize = getItemHeightBeforeResize\r\n\t\tthis.getBeforeResizeItemsCount = getBeforeResizeItemsCount\r\n\t\tthis.getAverageItemHeight = getAverageItemHeight\r\n\t\tthis.getMaxVisibleAreaHeight = getMaxVisibleAreaHeight\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\tthis.getPreviouslyCalculatedLayout = getPreviouslyCalculatedLayout\r\n\t}\r\n\r\n\t// React `<VirtualScroller/>` component attempts to create the initial state\r\n\t// before the component tree has mounted. This could result in an inability to\r\n\t// calculate some initial layout values like `columnsCount` or `lastShownItemIndex`.\r\n\t// Such errors aren't considered critical because layout will be re-calculated\r\n\t// after the component mounts. The workaround is to use some sane default values\r\n\t// until the scrollable container has mounted.\r\n\tgetInitialLayoutValueWithFallback(name, getValue, defaultValue) {\r\n\t\ttry {\r\n\t\t\treturn getValue()\r\n\t\t} catch (error) {\r\n\t\t\tif (error instanceof ScrollableContainerNotReadyError) {\r\n\t\t\t\tlog(`Scrollable container size is not known at this point, so \"${name}\" can't be calculated yet. Default to`, defaultValue);\r\n\t\t\t\treturn defaultValue\r\n\t\t\t} else {\r\n\t\t\t\tthrow error\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetInitialLayoutValues({\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tbeforeStart\r\n\t}) {\r\n\t\tlet firstShownItemIndex\r\n\t\tlet lastShownItemIndex\r\n\t\t// If there're no items then `firstShownItemIndex` stays `undefined`.\r\n\t\tif (itemsCount > 0) {\r\n\t\t\tconst getLastShownItemIndex = () => {\r\n\t\t\t\treturn this.getInitialLastShownItemIndex({\r\n\t\t\t\t\titemsCount,\r\n\t\t\t\t\tcolumnsCount,\r\n\t\t\t\t\tfirstShownItemIndex\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t\tfirstShownItemIndex = 0\r\n\t\t\tlastShownItemIndex = beforeStart\r\n\t\t\t\t? this.getInitialLayoutValueWithFallback(\r\n\t\t\t\t\t'lastShownItemIndex',\r\n\t\t\t\t\tgetLastShownItemIndex,\r\n\t\t\t\t\t0\r\n\t\t\t\t)\r\n\t\t\t\t: getLastShownItemIndex()\r\n\t\t}\r\n\t\treturn {\r\n\t\t\tbeforeItemsHeight: 0,\r\n\t\t\tafterItemsHeight: 0,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\tgetInitialLastShownItemIndex({\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tfirstShownItemIndex\r\n\t}) {\r\n\t\tif (this.bypass) {\r\n\t\t\treturn itemsCount - 1\r\n\t\t}\r\n\t\t// On server side, at initialization time,\r\n\t\t// `scrollableContainer` is `undefined`,\r\n\t\t// so default to `1` estimated rows count.\r\n\t\tlet estimatedRowsCount = 1\r\n\t\tif (this.getMaxVisibleAreaHeight()) {\r\n\t\t\testimatedRowsCount = this.getEstimatedRowsCountForHeight(this.getMaxVisibleAreaHeight() + this.getPrerenderMargin())\r\n\t\t} else if (this.getInitialEstimatedVisibleItemRowsCount) {\r\n\t\t\testimatedRowsCount = this.getInitialEstimatedVisibleItemRowsCount()\r\n\t\t\tif (isNaN(estimatedRowsCount)) {\r\n\t\t\t\tthrow new Error('[virtual-scroller] `getEstimatedVisibleItemRowsCount()` must return a number')\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn Math.min(\r\n\t\t\tfirstShownItemIndex + (estimatedRowsCount * columnsCount - 1),\r\n\t\t\titemsCount - 1\r\n\t\t)\r\n\t}\r\n\r\n\tgetEstimatedRowsCountForHeight(height) {\r\n\t\tconst estimatedItemHeight = this.getEstimatedItemHeight()\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\t\tif (estimatedItemHeight) {\r\n\t\t\treturn Math.ceil((height + verticalSpacing) / (estimatedItemHeight + verticalSpacing))\r\n\t\t} else {\r\n\t\t\t// If no items have been rendered yet, and no `estimatedItemHeight` option\r\n\t\t\t// has been passed, then default to `1` estimated rows count in any `height`.\r\n\t\t\treturn 1\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns estimated list item height.\r\n\t * (depends on which items have been previously rendered and measured).\r\n\t * @return {number}\r\n\t */\r\n\tgetEstimatedItemHeight() {\r\n\t\tconst averageItemHeight = this.getAverageItemHeight()\r\n\t\tif (averageItemHeight) {\r\n\t\t\treturn averageItemHeight\r\n\t\t}\r\n\t\tif (this.getInitialEstimatedItemHeight) {\r\n\t\t\tconst estimatedItemHeight = this.getInitialEstimatedItemHeight()\r\n\t\t\tif (isNaN(estimatedItemHeight)) {\r\n\t\t\t\tthrow new Error('[virtual-scroller] `getInitialEstimatedItemHeight()` must return a number')\r\n\t\t\t}\r\n\t\t\treturn estimatedItemHeight\r\n\t\t}\r\n\t\treturn 0\r\n\t}\r\n\r\n\tgetLayoutUpdateForItemsDiff({\r\n\t\tfirstShownItemIndex,\r\n\t\tlastShownItemIndex,\r\n\t\tbeforeItemsHeight,\r\n\t\tafterItemsHeight\r\n\t}, {\r\n\t\tprependedItemsCount,\r\n\t\tappendedItemsCount\r\n\t}, {\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tshouldRestoreScrollPosition,\r\n\t\tonResetGridLayout\r\n\t}) {\r\n\t\t// const layoutUpdate = {}\r\n\r\n\t\t// If the layout stays the same, then simply increase\r\n\t\t// the top and bottom margins proportionally to the amount\r\n\t\t// of the items added.\r\n\t\tconst averageItemHeight = this.getAverageItemHeight()\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\r\n\t\tif (appendedItemsCount > 0) {\r\n\t\t\tconst appendedRowsCount = Math.ceil(appendedItemsCount / columnsCount)\r\n\t\t\tconst addedHeightAfter = appendedRowsCount * (verticalSpacing + averageItemHeight)\r\n\r\n\t\t\tafterItemsHeight += addedHeightAfter\r\n\r\n\t\t\t// layoutUpdate = {\r\n\t\t\t// \t...layoutUpdate,\r\n\t\t\t// \tafterItemsHeight\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\tif (prependedItemsCount > 0) {\r\n\t\t\tconst prependedRowsCount = Math.ceil(prependedItemsCount / columnsCount)\r\n\t\t\tconst addedHeightBefore = prependedRowsCount * (averageItemHeight + verticalSpacing)\r\n\r\n\t\t\tfirstShownItemIndex += prependedItemsCount\r\n\t\t\tlastShownItemIndex += prependedItemsCount\r\n\t\t\tbeforeItemsHeight += addedHeightBefore\r\n\r\n\t\t\t// If the currently shown items position on screen should be preserved\r\n\t\t\t// when prepending new items, then it means that:\r\n\t\t\t// * The current scroll position should be snapshotted.\r\n\t\t\t// * The current list height should be snapshotted.\r\n\t\t\t// * All prepended items should be shown so that their height could be\r\n\t\t\t// measured after they're rendered. Based on the prepended items' height,\r\n\t\t\t// the scroll position will be restored so that there's no \"jump of content\".\r\n\t\t\tif (shouldRestoreScrollPosition) {\r\n\t\t\t\tfirstShownItemIndex = 0\r\n\t\t\t\tbeforeItemsHeight = 0\r\n\t\t\t}\r\n\r\n\t\t\tif (prependedItemsCount % columnsCount > 0) {\r\n\t\t\t\t// Rows will be rebalanced as a result of prepending new items,\r\n\t\t\t\t// and row heights can change as a result, so re-layout items\r\n\t\t\t\t// after they've been measured (after the upcoming re-render).\r\n\t\t\t\t//\r\n\t\t\t\t// For example, consider a web page where item rows are `display: flex`.\r\n\t\t\t\t// Suppose there're 3 columns and it shows items from 4 to 6.\r\n\t\t\t\t//\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Apples are | Bananas | Cranberries |\r\n\t\t\t\t// | green | | |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Dates | Elderberry | Figs are |\r\n\t\t\t\t// | | | tasty |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t//\r\n\t\t\t\t// Now, 1 item gets prepended. As a result, all existing rows will have\r\n\t\t\t\t// a different set of items, which means that the row heights will change.\r\n\t\t\t\t//\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Zucchini | Apples are | Bananas |\r\n\t\t\t\t// | | green | |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Cranberries | Dates | Elderberry |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Figs |\r\n\t\t\t\t// | are tasty |\r\n\t\t\t\t// ---------------\r\n\t\t\t\t//\r\n\t\t\t\t// As it can be seen above, the second row's height has changed from 2 to 1.\r\n\t\t\t\t// Not only that, but `itemHeights` have changed as well, so if you thought\r\n\t\t\t\t// that the library could easily recalculate row heights using `Math.max()` — \r\n\t\t\t\t// turns out it's not always the case.\r\n\t\t\t\t//\r\n\t\t\t\t// There could be an explicit opt-in option for automatically recalculating\r\n\t\t\t\t// row heights, but I don't want to write code for such an extremely rare\r\n\t\t\t\t// use case. Instead, use the `getColumnsCount()` parameter function when\r\n\t\t\t\t// fetching previous items.\r\n\r\n\t\t\t\tonResetGridLayout()\r\n\r\n\t\t\t\twarn('~ Prepended items count', prependedItemsCount, 'is not divisible by Columns Count', columnsCount, '~')\r\n\t\t\t\twarn('Layout reset required')\r\n\r\n\t\t\t\tconst shownItemsCountBeforeItemsUpdate = lastShownItemIndex - firstShownItemIndex + 1\r\n\r\n\t\t\t\tfirstShownItemIndex = 0\r\n\t\t\t\tbeforeItemsHeight = 0\r\n\r\n\t\t\t\tif (!shouldRestoreScrollPosition) {\r\n\t\t\t\t\t// Limit shown items count if too many items have been prepended.\r\n\t\t\t\t\tif (prependedItemsCount > shownItemsCountBeforeItemsUpdate) {\r\n\t\t\t\t\t\tlastShownItemIndex = this.getInitialLastShownItemIndex({\r\n\t\t\t\t\t\t\titemsCount,\r\n\t\t\t\t\t\t\tcolumnsCount,\r\n\t\t\t\t\t\t\tfirstShownItemIndex\r\n\t\t\t\t\t\t})\r\n\r\n\t\t\t\t\t\t// Approximate `afterItemsHeight` calculation.\r\n\t\t\t\t\t\tconst afterItemsCount = itemsCount - (lastShownItemIndex + 1)\r\n\t\t\t\t\t\tafterItemsHeight = Math.ceil(afterItemsCount / columnsCount) * (verticalSpacing + averageItemHeight)\r\n\r\n\t\t\t\t\t\t// layoutUpdate = {\r\n\t\t\t\t\t\t// \t...layoutUpdate,\r\n\t\t\t\t\t\t// \tafterItemsHeight\r\n\t\t\t\t\t\t// }\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// layoutUpdate = {\r\n\t\t\t// \t...layoutUpdate,\r\n\t\t\t// \tbeforeItemsHeight,\r\n\t\t\t// \tfirstShownItemIndex,\r\n\t\t\t// \tlastShownItemIndex\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\t// return layoutUpdate\r\n\r\n\t\t// Overwrite all four props in all scenarios.\r\n\t\t// The reason is that only this way subsequent `setItems()` calls\r\n\t\t// will be truly \"stateless\" when a chain of `setItems()` calls\r\n\t\t// could be replaced with just the last one in a scenario when\r\n\t\t// `updateState()` calls are \"asynchronous\" (delayed execution).\r\n\t\t//\r\n\t\t// So, for example, the user calls `setItems()` with one set of items.\r\n\t\t// A `updateState()` call has been dispatched but the `state` hasn't been updated yet.\r\n\t\t// Then the user calls `setItems()` with another set of items.\r\n\t\t// If this function only returned a minimal set of properties that actually change,\r\n\t\t// the other layout properties of the second `setItems()` call wouldn't overwrite the ones\r\n\t\t// scheduled for update during the first `setItems()` call, resulting in an inconsistent `state`.\r\n\t\t//\r\n\t\t// For example, the first `setItems()` call does a `updateState()` call where it updates\r\n\t\t// `afterItemsHeight`, and then the second `setItems()` call only updates `beforeItemsHeight`\r\n\t\t// and `firstShownItemIndex` and `lastShownItemIndex`. If the second `setItems()` call was to\r\n\t\t// overwrite any effects of the pending-but-not-yet-applied first `setItems()` call, it would\r\n\t\t// have to call `updateState()` with an `afterItemsHeight` property too, even though it hasn't change.\r\n\t\t// That would be just to revert the change to `afterItemsHeight` state property already scheduled\r\n\t\t// by the first `setItems()` call.\r\n\t\t//\r\n\t\treturn {\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t// If an item that hasn't been shown (and measured) yet is encountered\r\n\t// then show such item and then retry after it has been measured.\r\n\tgetItemNotMeasuredIndexes(i, {\r\n\t\titemsCount,\r\n\t\tfirstShownItemIndex,\r\n\t\tnonMeasuredAreaHeight,\r\n\t\tindexOfTheFirstItemInTheRow\r\n\t}) {\r\n\t\tlog('Item index', i, 'height is required for calculations but hasn\\'t been measured yet. Mark the item as \"shown\", rerender the list, measure the item\\'s height and redo the layout.')\r\n\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\r\n\t\tconst itemsCountToRenderForMeasurement = Math.min(\r\n\t\t\tthis.getEstimatedRowsCountForHeight(nonMeasuredAreaHeight) * columnsCount,\r\n\t\t\tthis.measureItemsBatchSize || Infinity,\r\n\t\t)\r\n\r\n\t\tif (firstShownItemIndex === undefined) {\r\n\t\t\tfirstShownItemIndex = indexOfTheFirstItemInTheRow\r\n\t\t}\r\n\r\n\t\tconst lastShownItemIndex = Math.min(\r\n\t\t\tindexOfTheFirstItemInTheRow + itemsCountToRenderForMeasurement - 1,\r\n\t\t\t// Guard against index overflow.\r\n\t\t\titemsCount - 1\r\n\t\t)\r\n\r\n\t\treturn {\r\n\t\t\tfirstNonMeasuredItemIndex: i,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Finds the indexes of the currently visible items.\r\n\t * @return {object} `{ firstShownItemIndex: number, lastShownItemIndex: number, firstNonMeasuredItemIndex: number? }`\r\n\t */\r\n\tgetShownItemIndexes({\r\n\t\titemsCount,\r\n\t\tvisibleAreaInsideTheList\r\n\t}) {\r\n\t\tlet indexes = this._getShownItemIndex({\r\n\t\t\titemsCount,\r\n\t\t\tfromIndex: 0,\r\n\t\t\tvisibleAreaInsideTheList,\r\n\t\t\tfindFirstShownItemIndex: true\r\n\t\t})\r\n\r\n\t\tif (indexes === null) {\r\n\t\t\treturn this.getNonVisibleListShownItemIndexes()\r\n\t\t}\r\n\r\n\t\tif (indexes.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\treturn indexes\r\n\t\t}\r\n\r\n\t\tconst { firstShownItemIndex, beforeItemsHeight } = indexes\r\n\r\n\t\tindexes = this._getShownItemIndex({\r\n\t\t\titemsCount,\r\n\t\t\tfromIndex: firstShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tvisibleAreaInsideTheList,\r\n\t\t\tfindLastShownItemIndex: true\r\n\t\t})\r\n\r\n\t\tif (indexes === null) {\r\n\t\t\treturn this.getNonVisibleListShownItemIndexes()\r\n\t\t}\r\n\r\n\t\tif (indexes.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\treturn indexes\r\n\t\t}\r\n\r\n\t\tconst { lastShownItemIndex } = indexes\r\n\r\n\t\treturn {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t_getShownItemIndex(parameters) {\r\n\t\tconst {\r\n\t\t\tbeforeResize,\r\n\t\t\titemsCount,\r\n\t\t\tvisibleAreaInsideTheList,\r\n\t\t\tfindFirstShownItemIndex,\r\n\t\t\tfindLastShownItemIndex,\r\n\t\t\t// backwards\r\n\t\t} = parameters\r\n\r\n\t\tlet {\r\n\t\t\tfromIndex,\r\n\t\t\tbeforeItemsHeight\r\n\t\t} = parameters\r\n\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\t\t//\r\n\t\t// If someone would attempt to use a \"previously calculated layout\" here\r\n\t\t// then `shownItemsHeight` would also have to be returned from this function:\r\n\t\t// the total height of all shown items including vertical spacing between them.\r\n\t\t//\r\n\t\t// If \"previously calculated layout\" would be used then it would first find\r\n\t\t// `firstShownItemIndex` and then find `lastShownItemIndex` as part of two\r\n\t\t// separate calls of this function, each with or without `backwards` flag,\r\n\t\t// depending on whether `visibleAreaInsideTheList.top` and `visibleAreaInsideTheList.top`\r\n\t\t// have shifted up or down.\r\n\r\n\t\tlet firstShownItemIndex\r\n\t\tlet lastShownItemIndex\r\n\r\n\t\t// It's not always required to pass `beforeItemsHeight` parameter:\r\n\t\t// when `fromIndex` is `0`, it's also assumed to be `0`.\r\n\t\tif (fromIndex === 0) {\r\n\t\t\tbeforeItemsHeight = 0\r\n\t\t}\r\n\r\n\t\tif (beforeItemsHeight === undefined) {\r\n\t\t\tthrow new Error('[virtual-scroller] `beforeItemsHeight` not passed to `Layout.getShownItemIndexes()` when starting from index ' + fromIndex);\r\n\t\t}\r\n\r\n\t\t// const backwards = false\r\n\t\t// while (backwards ? i >= 0 : i < itemsCount) {}\r\n\r\n\t\tif (!beforeResize) {\r\n\t\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\t\t\tif (beforeResizeItemsCount > fromIndex) {\r\n\t\t\t\t// First search for the item in \"before resize\" items.\r\n\t\t\t\tconst {\r\n\t\t\t\t\tnotFound,\r\n\t\t\t\t\tbeforeItemsHeight: beforeResizeItemsHeight,\r\n\t\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\t\tlastShownItemIndex\r\n\t\t\t\t} = this._getShownItemIndex({\r\n\t\t\t\t\t...parameters,\r\n\t\t\t\t\tbeforeResize: true,\r\n\t\t\t\t\titemsCount: beforeResizeItemsCount\r\n\t\t\t\t})\r\n\r\n\t\t\t\t// If the item was not found in \"before resize\" items\r\n\t\t\t\t// then search in regular items skipping \"before resize\" ones.\r\n\t\t\t\tif (notFound) {\r\n\t\t\t\t\tbeforeItemsHeight = beforeResizeItemsHeight\r\n\t\t\t\t\tfromIndex += beforeResizeItemsCount\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// If the item was found in \"before resize\" items\r\n\t\t\t\t\t// then return the result.\r\n\t\t\t\t\t// Rebalance first / last shown item indexes based on\r\n\t\t\t\t\t// the current columns count, if required.\r\n\t\t\t\t\tconst columnsCount = this.getColumnsCount()\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tfirstShownItemIndex: firstShownItemIndex === undefined\r\n\t\t\t\t\t\t\t? undefined\r\n\t\t\t\t\t\t\t: Math.floor(firstShownItemIndex / columnsCount) * columnsCount,\r\n\t\t\t\t\t\tlastShownItemIndex: lastShownItemIndex === undefined\r\n\t\t\t\t\t\t\t? undefined\r\n\t\t\t\t\t\t\t: Math.floor(lastShownItemIndex / columnsCount) * columnsCount,\r\n\t\t\t\t\t\tbeforeItemsHeight: beforeResizeItemsHeight\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst columnsCount = beforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\tconst verticalSpacing = beforeResize ? this.getVerticalSpacingBeforeResize() : this.getVerticalSpacing()\r\n\r\n\t\tlet i = fromIndex\r\n\t\twhile (i < itemsCount) {\r\n\t\t\tconst currentRowFirstItemIndex = i\r\n\r\n\t\t\tconst hasMoreRows = itemsCount > currentRowFirstItemIndex + columnsCount\r\n\t\t\tconst verticalSpacingAfterCurrentRow = hasMoreRows ? verticalSpacing : 0\r\n\r\n\t\t\tlet currentRowHeight = 0\r\n\r\n\t\t\t// Calculate current row height.\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < columnsCount && i < itemsCount) {\r\n\t\t\t\tconst itemHeight = beforeResize ? this.getItemHeightBeforeResize(i) : this.getItemHeight(i)\r\n\r\n\t\t\t\t// If this item hasn't been measured yet (or re-measured after a resize)\r\n\t\t\t\t// then mark it as the first non-measured one.\r\n\t\t\t\t//\r\n\t\t\t\t// Can't happen by definition when `beforeResize` parameter is `true`.\r\n\t\t\t\t//\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\treturn this.getItemNotMeasuredIndexes(i, {\r\n\t\t\t\t\t\titemsCount,\r\n\t\t\t\t\t\tfirstShownItemIndex: findLastShownItemIndex ? fromIndex : undefined,\r\n\t\t\t\t\t\tindexOfTheFirstItemInTheRow: currentRowFirstItemIndex,\r\n\t\t\t\t\t\tnonMeasuredAreaHeight: (visibleAreaInsideTheList.bottom + this.getPrerenderMargin()) - beforeItemsHeight\r\n\t\t\t\t\t})\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcurrentRowHeight = Math.max(currentRowHeight, itemHeight)\r\n\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t\ti++\r\n\t\t\t}\r\n\r\n\t\t\tconst itemsHeightFromFirstRowToThisRow = beforeItemsHeight + currentRowHeight\r\n\r\n\t\t\tconst rowStepsIntoVisibleAreaTop = itemsHeightFromFirstRowToThisRow > visibleAreaInsideTheList.top - this.getPrerenderMargin()\r\n\t\t\tconst rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder = itemsHeightFromFirstRowToThisRow + verticalSpacingAfterCurrentRow >= visibleAreaInsideTheList.bottom + this.getPrerenderMargin()\r\n\r\n\t\t\t// if (backwards) {\r\n\t\t\t// \tif (findFirstShownItemIndex) {\r\n\t\t\t// \t\tif (rowStepsOutOfVisibleAreaTop) {\r\n\t\t\t// \t\t\treturn {\r\n\t\t\t// \t\t\t\tfirstShownItemIndex: currentRowFirstItemIndex + columnsCount\r\n\t\t\t// \t\t\t}\r\n\t\t\t// \t\t}\r\n\t\t\t// \t} else if (findLastShownItemIndex) {\r\n\t\t\t// \t\tif (rowStepsIntoVisibleAreaBottom) {\r\n\t\t\t// \t\t\treturn {\r\n\t\t\t// \t\t\t\tlastShownItemIndex: currentRowFirstItemIndex + columnsCount - 1\r\n\t\t\t// \t\t\t}\r\n\t\t\t// \t\t}\r\n\t\t\t// \t}\r\n\t\t\t// }\r\n\r\n\t\t\tif (findFirstShownItemIndex) {\r\n\t\t\t\tif (rowStepsIntoVisibleAreaTop) {\r\n\t\t\t\t\t// If item is the first one visible in the viewport\r\n\t\t\t\t\t// then start showing items from this row.\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tfirstShownItemIndex: currentRowFirstItemIndex,\r\n\t\t\t\t\t\tbeforeItemsHeight\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else if (findLastShownItemIndex) {\r\n\t\t\t\tif (rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder) {\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tlastShownItemIndex: Math.min(\r\n\t\t\t\t\t\t\t// The index of the last item in the current row.\r\n\t\t\t\t\t\t\tcurrentRowFirstItemIndex + columnsCount - 1,\r\n\t\t\t\t\t\t\t// Guards against index overflow.\r\n\t\t\t\t\t\t\titemsCount - 1\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbeforeItemsHeight += currentRowHeight + verticalSpacingAfterCurrentRow\r\n\r\n\t\t\t// if (backwards) {\r\n\t\t\t// \t// Set `i` to be the first item of the current row.\r\n\t\t\t// \ti -= columnsCount\r\n\t\t\t// \tconst prevoiusRowIsBeforeResize = i - 1 < this.getBeforeResizeItemsCount()\r\n\t\t\t// \tconst previousRowColumnsCount = prevoiusRowIsBeforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\t\t// \t// Set `i` to be the first item of the previous row.\r\n\t\t\t// \ti -= previousRowColumnsCount\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\t// if (backwards) {\r\n\t\t// \tif (findFirstShownItemIndex) {\r\n\t\t// \t\twarn('The list is supposed to be visible but no visible item has been found (while traversing backwards)')\r\n\t\t// \t\treturn null\r\n\t\t// \t} else if (findLastShownItemIndex) {\r\n\t\t// \t\treturn {\r\n\t\t// \t\t\tfirstShownItemIndex: 0\r\n\t\t// \t\t}\r\n\t\t// \t}\r\n\t\t// }\r\n\r\n\t\tif (beforeResize) {\r\n\t\t\treturn {\r\n\t\t\t\tnotFound: true,\r\n\t\t\t\tbeforeItemsHeight\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// This case isn't supposed to happen but it could hypothetically happen\r\n\t\t// because the list height is measured from the user's screen and\r\n\t\t// not necessarily can be trusted.\r\n\t\tif (findFirstShownItemIndex) {\r\n\t\t\twarn('The list is supposed to be visible but no visible item has been found')\r\n\t\t\treturn null\r\n\t\t} else if (findLastShownItemIndex) {\r\n\t\t\treturn {\r\n\t\t\t\tlastShownItemIndex: itemsCount - 1\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetNonVisibleListShownItemIndexes() {\r\n\t\tconst layout = {\r\n\t\t\tfirstShownItemIndex: 0,\r\n\t\t\tlastShownItemIndex: 0\r\n\t\t}\r\n\t\tif (this.getItemHeight(0) === undefined) {\r\n\t\t\tlayout.firstNonMeasuredItemIndex = 0\r\n\t\t}\r\n\t\treturn layout\r\n\t}\r\n\r\n\t/**\r\n\t * Measures \"before\" items height.\r\n\t * @param {number} beforeItemsCount — Basically, first shown item index.\r\n\t * @return {number}\r\n\t */\r\n\tgetBeforeItemsHeight(\r\n\t\tbeforeItemsCount,\r\n\t\t{ beforeResize } = {}\r\n\t) {\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\r\n\t\tlet beforeItemsHeight = 0\r\n\t\tlet i = 0\r\n\r\n\t\tif (!beforeResize) {\r\n\t\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\r\n\t\t\tif (beforeResizeItemsCount > 0) {\r\n\t\t\t\t// First add all \"before resize\" item heights.\r\n\t\t\t\tbeforeItemsHeight = this.getBeforeItemsHeight(\r\n\t\t\t\t\t// `firstShownItemIndex` (called `beforeItemsCount`) could be greater than\r\n\t\t\t\t\t// `beforeResizeItemsCount` when the user scrolls down.\r\n\t\t\t\t\t// `firstShownItemIndex` (called `beforeItemsCount`) could be less than\r\n\t\t\t\t\t// `beforeResizeItemsCount` when the user scrolls up.\r\n\t\t\t\t\tMath.min(beforeItemsCount, beforeResizeItemsCount),\r\n\t\t\t\t\t{ beforeResize: true }\r\n\t\t\t\t)\r\n\t\t\t\ti = beforeResizeItemsCount\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst columnsCount = beforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\tconst verticalSpacing = beforeResize ? this.getVerticalSpacingBeforeResize() : this.getVerticalSpacing()\r\n\r\n\t\twhile (i < beforeItemsCount) {\r\n\t\t\tconst currentRowFirstItemIndex = i\r\n\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\t// Not checking for `itemsCount` overflow here because `i = beforeItemsCount`\r\n\t\t\t// can only start at the start of a row, meaning that when calculating\r\n\t\t\t// \"before items height\" it's not supposed to add item heights from the\r\n\t\t\t// last row of items because in that case it would have to iterate from\r\n\t\t\t// `i === beforeItemsCount` and that condition is already checked above.\r\n\t\t\t// while (i < itemsCount) {\r\n\t\t\twhile (columnIndex < columnsCount) {\r\n\t\t\t\tlet itemHeight = beforeResize ? this.getItemHeightBeforeResize(i) : this.getItemHeight(i)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\t// `itemHeight` can only be `undefined` when not `beforeResize`.\r\n\t\t\t\t\t// Use the current \"average item height\" as a substitute.\r\n\t\t\t\t\titemHeight = this.getAverageItemHeight()\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\ti++\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\tbeforeItemsHeight += rowHeight\r\n\t\t\tbeforeItemsHeight += verticalSpacing\r\n\t\t}\r\n\r\n\t\treturn beforeItemsHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Measures \"after\" items height.\r\n\t * @param {number} lastShownItemIndex — Last shown item index.\r\n\t * @param {number} itemsCount — Items count.\r\n\t * @return {number}\r\n\t */\r\n\tgetAfterItemsHeight(\r\n\t\tlastShownItemIndex,\r\n\t\titemsCount\r\n\t) {\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\t\tconst lastShownRowIndex = Math.floor(lastShownItemIndex / columnsCount)\r\n\r\n\t\tlet afterItemsHeight = 0\r\n\r\n\t\tlet i = lastShownItemIndex + 1\r\n\t\twhile (i < itemsCount) {\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < columnsCount && i < itemsCount) {\r\n\t\t\t\tlet itemHeight = this.getItemHeight(i)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\titemHeight = this.getAverageItemHeight()\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\ti++\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\t// Add all \"after\" items height.\r\n\t\t\tafterItemsHeight += this.getVerticalSpacing()\r\n\t\t\tafterItemsHeight += rowHeight\r\n\t\t}\r\n\r\n\t\treturn afterItemsHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the items's top offset relative to the top edge of the first item.\r\n\t * @param {number} i — Item index\r\n\t * @return {[number]} Returns `undefined` if any of the previous items haven't been rendered yet.\r\n\t */\r\n\tgetItemTopOffset(i) {\r\n\t\tlet topOffsetInsideScrollableContainer = 0\r\n\r\n\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\t\tconst beforeResizeRowsCount = beforeResizeItemsCount === 0\r\n\t\t\t? 0\r\n\t\t\t: Math.ceil(beforeResizeItemsCount / this.getColumnsCountBeforeResize())\r\n\r\n\t\tconst maxBeforeResizeRowsCount = i < beforeResizeItemsCount\r\n\t\t\t? Math.floor(i / this.getColumnsCountBeforeResize())\r\n\t\t\t: beforeResizeRowsCount\r\n\r\n\t\tlet beforeResizeRowIndex = 0\r\n\t\twhile (beforeResizeRowIndex < maxBeforeResizeRowsCount) {\r\n\t\t\tconst rowHeight = this.getItemHeightBeforeResize(\r\n\t\t\t\tbeforeResizeRowIndex * this.getColumnsCountBeforeResize()\r\n\t\t\t)\r\n\r\n\t\t\ttopOffsetInsideScrollableContainer += rowHeight\r\n\t\t\ttopOffsetInsideScrollableContainer += this.getVerticalSpacingBeforeResize()\r\n\r\n\t\t\tbeforeResizeRowIndex++\r\n\t\t}\r\n\r\n\t\tconst itemRowIndex = Math.floor((i - beforeResizeItemsCount) / this.getColumnsCount())\r\n\r\n\t\tlet rowIndex = 0\r\n\t\twhile (rowIndex < itemRowIndex) {\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < this.getColumnsCount()) {\r\n\t\t\t\tconst itemHeight = this.getItemHeight(\r\n\t\t\t\t\tbeforeResizeItemsCount + rowIndex * this.getColumnsCount() + columnIndex\r\n\t\t\t\t)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\ttopOffsetInsideScrollableContainer += rowHeight\r\n\t\t\ttopOffsetInsideScrollableContainer += this.getVerticalSpacing()\r\n\r\n\t\t\trowIndex++\r\n\t\t}\r\n\r\n\t\treturn topOffsetInsideScrollableContainer\r\n\t}\r\n}\r\n\r\nexport const LAYOUT_REASON = {\r\n\tSCROLL: 'scroll',\r\n\tSTOPPED_SCROLLING: 'stopped scrolling',\r\n\tMANUAL: 'manual',\r\n\tSTARTED: 'started',\r\n\tNON_MEASURED_ITEMS_HAVE_BEEN_MEASURED: 'non-measured item heights have been measured',\r\n\tVIEWPORT_WIDTH_CHANGED: 'viewport width changed',\r\n\tVIEWPORT_HEIGHT_CHANGED: 'viewport height changed',\r\n\tVIEWPORT_SIZE_UNCHANGED: 'viewport size unchanged',\r\n\tITEM_HEIGHT_CHANGED: 'item height changed',\r\n\tITEMS_CHANGED: 'items changed',\r\n\tTOP_OFFSET_CHANGED: 'list top offset changed'\r\n}"],"mappings":";;;;;;;;;;;;AAAA,OAAOA,GAAP,IAAcC,IAAd,QAA0B,oBAA1B;AACA,OAAOC,gCAAP,MAA6C,uCAA7C;;IAEqBC,M;EACpB,sBAgBG;IAAA,IAfFC,MAeE,QAfFA,MAeE;IAAA,IAdFC,6BAcE,QAdFA,6BAcE;IAAA,IAbFC,uCAaE,QAbFA,uCAaE;IAAA,IAZFC,qBAYE,QAZFA,qBAYE;IAAA,IAXFC,kBAWE,QAXFA,kBAWE;IAAA,IAVFC,kBAUE,QAVFA,kBAUE;IAAA,IATFC,8BASE,QATFA,8BASE;IAAA,IARFC,eAQE,QARFA,eAQE;IAAA,IAPFC,2BAOE,QAPFA,2BAOE;IAAA,IANFC,aAME,QAN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