virtual-scroller 1.12.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,7 +99,7 @@ function _default() {
99
99
 
100
100
  var layoutUpdateReason;
101
101
 
102
- if (_this.updateLayoutAfterRenderBecauseItemHeightChanged) {
102
+ if (itemHeightHasChanged) {
103
103
  layoutUpdateReason = _Layout.LAYOUT_REASON.ITEM_HEIGHT_CHANGED;
104
104
  }
105
105
 
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualScroller.onRender.js","names":["_onRender","newState","prevState","waitingForRender","log","isDebug","getStateSnapshot","onStateChange","shallowEqual","tbody","setTbodyPadding","getItemsContainerElement","beforeItemsHeight","afterItemsHeight","mostRecentSetStateValue","warn","reportError","resetStateUpdateFlags","call","nonMeasuredItemsHaveBeenRendered","itemHeightHasChanged","widthHasChanged","layoutUpdateReason","updateLayoutAfterRenderBecauseItemHeightChanged","LAYOUT_REASON","ITEM_HEIGHT_CHANGED","NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED","VIEWPORT_WIDTH_CHANGED","itemHeights","reset","verticalSpacing","undefined","previousItems","items","newItems","itemsDiff","getItemsDiff","prependedItemsCount","onPrepend","onNewItemsRendered","ITEMS_CHANGED","stateUpdate","firstShownItemIndex","lastShownItemIndex","verticalSpacingStateUpdate","measureItemHeightsAndSpacing","cleanedUpBeforeResize","beforeResize","cleanUpBeforeResizeItemHeights","scrollBy","scroll","scrollByY","_isActive","_stoppedStateUpdate","updateStateRightAfterRender","reason","updateState","newLayout","appendedItemsCount","getState","itemStates","itemHeightsThatChangedWhileNewItemsWereBeingRendered","Object","keys","i","Number","itemStatesThatChangedWhileNewItemsWereBeingRendered","previouslyCalculatedLayout","listHeightMeasurement","hasSnapshot","listBottomOffsetChange","getListBottomOffsetChange","shownItemsHeight","_useTimeoutInRenderLoop","cancelLayoutTimer","scheduleLayoutTimer","onUpdateShownItemIndexes","Boolean","firstNonMeasuredItemIndex","newItemsWillBeRendered"],"sources":["../source/VirtualScroller.onRender.js"],"sourcesContent":["import log, { warn, reportError, isDebug } from './utility/debug.js'\r\nimport getStateSnapshot from './utility/getStateSnapshot.js'\r\nimport shallowEqual from './utility/shallowEqual.js'\r\nimport { LAYOUT_REASON } from './Layout.js'\r\nimport { setTbodyPadding } from './DOM/tbody.js'\r\n\r\nexport default function() {\r\n\t/**\r\n\t * Should be called right after updates to `state` have been rendered.\r\n\t * @param {object} newState\r\n\t * @param {object} [prevState]\r\n\t */\r\n\tthis._onRender = (newState, prevState) => {\r\n\t\tthis.waitingForRender = false\r\n\r\n\t\tlog('~ Rendered ~')\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('State', getStateSnapshot(newState))\r\n\t\t}\r\n\r\n\t\tif (this.onStateChange) {\r\n\t\t\tif (!shallowEqual(newState, prevState)) {\r\n\t\t\t\tthis.onStateChange(newState)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Update `<tbody/>` `padding`.\r\n\t\t// (`<tbody/>` is different in a way that it can't have `margin`, only `padding`).\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1\r\n\t\tif (this.tbody) {\r\n\t\t\tsetTbodyPadding(\r\n\t\t\t\tthis.getItemsContainerElement(),\r\n\t\t\t\tnewState.beforeItemsHeight,\r\n\t\t\t\tnewState.afterItemsHeight\r\n\t\t\t)\r\n\t\t}\r\n\r\n\t\t// `this.mostRecentlySetState` checks that state management behavior is correct:\r\n\t\t// that in situations when there're multiple new states waiting to be set,\r\n\t\t// only the latest one gets applied.\r\n\t\t// It keeps the code simpler and prevents possible race condition bugs.\r\n\t\t// For example, `VirtualScroller` keeps track of its latest requested\r\n\t\t// state update in different instance variable flags which assume that\r\n\t\t// only that latest requested state update gets actually applied.\r\n\t\t//\r\n\t\t// This check should also be performed for the initial render in order to\r\n\t\t// guarantee that no potentially incorrect state update goes unnoticed.\r\n\t\t// Incorrect state updates could happen when `VirtualScroller` state\r\n\t\t// is managed externally by passing `getState()`/`updateState()` options.\r\n\t\t//\r\n\t\t// Perform the check only when `this.mostRecentSetStateValue` is defined.\r\n\t\t// `this.mostRecentSetStateValue` is normally gonna be `undefined` at the initial render\r\n\t\t// because the initial state is not set by calling `this.updateState()`.\r\n\t\t// At the same time, it is possible that the initial render is delayed\r\n\t\t// for whatever reason, and `this.updateState()` gets called before the initial render,\r\n\t\t// so `this.mostRecentSetStateValue` could also be defined at the initial render,\r\n\t\t// in which case the check should be performed.\r\n\t\t//\r\n\t\tif (this.mostRecentSetStateValue) {\r\n\t\t\t// \"Shallow equality\" is used here instead of \"strict equality\"\r\n\t\t\t// because a developer might choose to supply an `updateState()` function\r\n\t\t\t// rather than a `setState()` function, in which case the `updateState()` function\r\n\t\t\t// would construct its own state object.\r\n\t\t\tif (!shallowEqual(newState, this.mostRecentSetStateValue)) {\r\n\t\t\t\twarn('The most recent state that was set', getStateSnapshot(this.mostRecentSetStateValue))\r\n\t\t\t\treportError('The state that has been rendered is not the most recent one that was set')\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `this.resetStateUpdateFlags()` must be called before calling\r\n\t\t// `this.measureItemHeightsAndSpacing()`.\r\n\t\tconst {\r\n\t\t\tnonMeasuredItemsHaveBeenRendered,\r\n\t\t\titemHeightHasChanged,\r\n\t\t\twidthHasChanged\r\n\t\t} = resetStateUpdateFlags.call(this)\r\n\r\n\t\tlet layoutUpdateReason\r\n\r\n\t\tif (this.updateLayoutAfterRenderBecauseItemHeightChanged) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.ITEM_HEIGHT_CHANGED\r\n\t\t}\r\n\r\n\t\tif (!prevState) {\r\n\t\t\tif (!layoutUpdateReason) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If the `VirtualScroller`, while calculating layout parameters, encounters\r\n\t\t// a not-shown item with a non-measured height, it calls `updateState()` just to\r\n\t\t// render that item first, and then, after the list has been re-rendered, it measures\r\n\t\t// the item's height and then proceeds with calculating the correct layout parameters.\r\n\t\tif (nonMeasuredItemsHaveBeenRendered) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED\r\n\t\t}\r\n\r\n\t\t// If scrollable container width has changed, and it has been re-rendered,\r\n\t\t// then it's time to measure the new item heights and then perform a re-layout\r\n\t\t// with the correctly calculated layout parameters.\r\n\t\t//\r\n\t\t// A re-layout is required because the layout parameters calculated on resize\r\n\t\t// are approximate ones, and the exact item heights aren't known at that point.\r\n\t\t// So on resize, it calls `updateState()` 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\tif (widthHasChanged) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.VIEWPORT_WIDTH_CHANGED\r\n\r\n\t\t\t// Reset measured item heights on viewport width change.\r\n\t\t\tthis.itemHeights.reset()\r\n\r\n\t\t\t// Reset `verticalSpacing` (will be re-measured).\r\n\t\t\tthis.verticalSpacing = undefined\r\n\t\t}\r\n\r\n\t\tif (prevState) {\r\n\t\t\tconst { items: previousItems } = prevState\r\n\t\t\tconst { items: newItems } = newState\r\n\t\t\t// Even if `this.newItemsWillBeRendered` flag is `true`,\r\n\t\t\t// `newItems` could still be equal to `previousItems`.\r\n\t\t\t// For example, when `updateState()` calls don't update `state` immediately\r\n\t\t\t// and a developer first calls `setItems(newItems)` and then calls `setItems(oldItems)`:\r\n\t\t\t// in that case, `this.newItemsWillBeRendered` flag will be `true` but the actual `items`\r\n\t\t\t// in state wouldn't have changed due to the first `updateState()` call being overwritten\r\n\t\t\t// by the second `updateState()` call (that's called \"batching state updates\" in React).\r\n\t\t\tif (newItems !== previousItems) {\r\n\t\t\t\tconst itemsDiff = this.getItemsDiff(previousItems, newItems)\r\n\t\t\t\tif (itemsDiff) {\r\n\t\t\t\t\t// The call to `.onPrepend()` must precede the call to `.measureItemHeights()`\r\n\t\t\t\t\t// which is called in `.onRender()`.\r\n\t\t\t\t\t// `this.itemHeights.onPrepend()` updates `firstMeasuredItemIndex`\r\n\t\t\t\t\t// and `lastMeasuredItemIndex` of `this.itemHeights`.\r\n\t\t\t\t\tconst { prependedItemsCount } = itemsDiff\r\n\t\t\t\t\tthis.itemHeights.onPrepend(prependedItemsCount)\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.itemHeights.reset()\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (!widthHasChanged) {\r\n\t\t\t\t\t// The call to `this.onNewItemsRendered()` must precede the call to\r\n\t\t\t\t\t// `.measureItemHeights()` which is called in `.onRender()` because\r\n\t\t\t\t\t// `this.onNewItemsRendered()` updates `firstMeasuredItemIndex` and\r\n\t\t\t\t\t// `lastMeasuredItemIndex` of `this.itemHeights` in case of a prepend.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// If after prepending items the scroll position\r\n\t\t\t\t\t// should be \"restored\" so that there's no \"jump\" of content\r\n\t\t\t\t\t// then it means that all previous items have just been rendered\r\n\t\t\t\t\t// in a single pass, and there's no need to update layout again.\r\n\t\t\t\t\t//\r\n\t\t\t\t\tif (onNewItemsRendered.call(this, itemsDiff, newState) !== 'SEAMLESS_PREPEND') {\r\n\t\t\t\t\t\tlayoutUpdateReason = LAYOUT_REASON.ITEMS_CHANGED\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\tlet stateUpdate\r\n\r\n\t\t// Re-measure item heights.\r\n\t\t// Also, measure vertical spacing (if not measured) and fix `<table/>` padding.\r\n\t\t//\r\n\t\t// This block should go after `if (newItems !== previousItems) {}`\r\n\t\t// because `this.itemHeights` can get `.reset()` there, which would\r\n\t\t// discard all the measurements done here, and having currently shown\r\n\t\t// item height measurements is required.\r\n\t\t//\r\n\t\tif (\r\n\t\t\t(prevState && (\r\n\t\t\t\tnewState.firstShownItemIndex !== prevState.firstShownItemIndex ||\r\n\t\t\t\tnewState.lastShownItemIndex !== prevState.lastShownItemIndex ||\r\n\t\t\t\tnewState.items !== prevState.items\r\n\t\t\t)) ||\r\n\t\t\twidthHasChanged\r\n\t\t) {\r\n\t\t\tconst verticalSpacingStateUpdate = this.measureItemHeightsAndSpacing()\r\n\t\t\tif (verticalSpacingStateUpdate) {\r\n\t\t\t\tstateUpdate = {\r\n\t\t\t\t\t...stateUpdate,\r\n\t\t\t\t\t...verticalSpacingStateUpdate\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Clean up \"before resize\" item heights and adjust the scroll position accordingly.\r\n\t\t// Calling `this.beforeResize.cleanUpBeforeResizeItemHeights()` might trigger\r\n\t\t// a `this.updateState()` call but that wouldn't matter because `beforeResize`\r\n\t\t// properties have already been modified directly in `state` (a hacky technique)\r\n\t\tconst cleanedUpBeforeResize = this.beforeResize.cleanUpBeforeResizeItemHeights()\r\n\t\tif (cleanedUpBeforeResize !== undefined) {\r\n\t\t\tconst { scrollBy, beforeResize } = cleanedUpBeforeResize\r\n\t\t\tlog('Correct scroll position by', scrollBy)\r\n\t\t\tthis.scroll.scrollByY(scrollBy)\r\n\t\t\tstateUpdate = {\r\n\t\t\t\t...stateUpdate,\r\n\t\t\t\tbeforeResize\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!this._isActive) {\r\n\t\t\tthis._stoppedStateUpdate = stateUpdate\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (layoutUpdateReason) {\r\n\t\t\tupdateStateRightAfterRender.call(this, {\r\n\t\t\t\tstateUpdate,\r\n\t\t\t\treason: layoutUpdateReason\r\n\t\t\t})\r\n\t\t} else if (stateUpdate) {\r\n\t\t\tthis.updateState(stateUpdate)\r\n\t\t} else {\r\n\t\t\tlog('~ Finished Layout ~')\r\n\t\t}\r\n\t}\r\n\r\n\t// After a new set of items has been rendered:\r\n\t//\r\n\t// * Restores scroll position when using `preserveScrollPositionOnPrependItems`\r\n\t// and items have been prepended.\r\n\t//\r\n\t// * Applies any \"pending\" `itemHeights` updates — those ones that happened\r\n\t// while an asynchronous `updateState()` call in `setItems()` was pending.\r\n\t//\r\n\t// * Either creates or resets the snapshot of the current layout.\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\t// The \"previously calculated layout\" feature is not currently used.\r\n\t//\r\n\tfunction onNewItemsRendered(itemsDiff, newLayout) {\r\n\t\t// If it's an \"incremental\" update.\r\n\t\tif (itemsDiff) {\r\n\t\t\tconst {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t} = itemsDiff\r\n\r\n\t\t\tconst {\r\n\t\t\t\titemHeights,\r\n\t\t\t\titemStates\r\n\t\t\t} = this.getState()\r\n\r\n\t\t\t// See if any items' heights changed while new items were being rendered.\r\n\t\t\tif (this.itemHeightsThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tfor (const i of Object.keys(this.itemHeightsThatChangedWhileNewItemsWereBeingRendered)) {\r\n\t\t\t\t\titemHeights[prependedItemsCount + Number(i)] = this.itemHeightsThatChangedWhileNewItemsWereBeingRendered[i]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// See if any items' states changed while new items were being rendered.\r\n\t\t\tif (this.itemStatesThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tfor (const i of Object.keys(this.itemStatesThatChangedWhileNewItemsWereBeingRendered)) {\r\n\t\t\t\t\titemStates[prependedItemsCount + Number(i)] = this.itemStatesThatChangedWhileNewItemsWereBeingRendered[i]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (prependedItemsCount === 0) {\r\n\t\t\t\t// Adjust `this.previouslyCalculatedLayout`.\r\n\t\t\t\tif (this.previouslyCalculatedLayout) {\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout.firstShownItemIndex === newLayout.firstShownItemIndex &&\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout.lastShownItemIndex === newLayout.lastShownItemIndex\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\t// `this.previouslyCalculatedLayout` stays the same.\r\n\t\t\t\t\t\t// `firstShownItemIndex` / `lastShownItemIndex` didn't get changed in `setItems()`,\r\n\t\t\t\t\t\t// so `beforeItemsHeight` and `shownItemsHeight` also stayed the same.\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\twarn('Unexpected (non-matching) \"firstShownItemIndex\" or \"lastShownItemIndex\" encountered in \"onRender()\" after appending items')\r\n\t\t\t\t\t\twarn('Previously calculated layout', this.previouslyCalculatedLayout)\r\n\t\t\t\t\t\twarn('New layout', newLayout)\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout = undefined\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn 'SEAMLESS_APPEND'\r\n\t\t\t} else {\r\n\t\t\t\tif (this.listHeightMeasurement.hasSnapshot()) {\r\n\t\t\t\t\tif (newLayout.firstShownItemIndex === 0) {\r\n\t\t\t\t\t\t// Restore (adjust) scroll position.\r\n\t\t\t\t\t\tlog('~ Restore Scroll Position ~')\r\n\t\t\t\t\t\tconst listBottomOffsetChange = this.listHeightMeasurement.getListBottomOffsetChange({\r\n\t\t\t\t\t\t\tbeforeItemsHeight: newLayout.beforeItemsHeight\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t\tthis.listHeightMeasurement.reset()\r\n\t\t\t\t\t\tif (listBottomOffsetChange) {\r\n\t\t\t\t\t\t\tlog('Scroll down by', listBottomOffsetChange)\r\n\t\t\t\t\t\t\tthis.scroll.scrollByY(listBottomOffsetChange)\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tlog('Scroll position hasn\\'t changed')\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t// Create new `this.previouslyCalculatedLayout`.\r\n\t\t\t\t\t\tif (this.previouslyCalculatedLayout) {\r\n\t\t\t\t\t\t\tif (\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout.firstShownItemIndex === 0 &&\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout.lastShownItemIndex === newLayout.lastShownItemIndex - prependedItemsCount\r\n\t\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout = {\r\n\t\t\t\t\t\t\t\t\tbeforeItemsHeight: 0,\r\n\t\t\t\t\t\t\t\t\tshownItemsHeight: this.previouslyCalculatedLayout.shownItemsHeight + listBottomOffsetChange,\r\n\t\t\t\t\t\t\t\t\tfirstShownItemIndex: 0,\r\n\t\t\t\t\t\t\t\t\tlastShownItemIndex: newLayout.lastShownItemIndex\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\twarn('Unexpected (non-matching) \"firstShownItemIndex\" or \"lastShownItemIndex\" encountered in \"onRender()\" after prepending items')\r\n\t\t\t\t\t\t\t\twarn('Previously calculated layout', this.previouslyCalculatedLayout)\r\n\t\t\t\t\t\t\t\twarn('New layout', newLayout)\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout = undefined\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn 'SEAMLESS_PREPEND'\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\twarn(`Unexpected \"firstShownItemIndex\" ${newLayout.firstShownItemIndex} encountered in \"onRender()\" after prepending items. Expected 0.`)\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\t// Reset `this.previouslyCalculatedLayout` in any case other than\r\n\t\t// SEAMLESS_PREPEND or SEAMLESS_APPEND.\r\n\t\tthis.previouslyCalculatedLayout = undefined\r\n\t}\r\n\r\n\tfunction updateStateRightAfterRender({\r\n\t\treason,\r\n\t\tstateUpdate\r\n\t}) {\r\n\t\t// In React, `setTimeout()` is used to prevent a React error:\r\n\t\t// \"Maximum update depth exceeded.\r\n\t\t// This can happen when a component repeatedly calls\r\n\t\t// `.updateState()` inside `componentWillUpdate()` or `componentDidUpdate()`.\r\n\t\t// React limits the number of nested updates to prevent infinite loops.\"\r\n\t\tif (this._useTimeoutInRenderLoop) {\r\n\t\t\t// Cancel a previously scheduled re-layout.\r\n\t\t\tstateUpdate = this.cancelLayoutTimer({ stateUpdate })\r\n\t\t\t// Schedule a new re-layout.\r\n\t\t\tthis.scheduleLayoutTimer({\r\n\t\t\t\treason,\r\n\t\t\t\tstateUpdate\r\n\t\t\t})\r\n\t\t} else {\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}\r\n\t}\r\n\r\n\tfunction resetStateUpdateFlags() {\r\n\t\t// Read and reset `this.widthHasChanged` flag.\r\n\t\t//\r\n\t\t// If `this.widthHasChanged` flag was reset after calling\r\n\t\t// `this.measureWidthHeightsAndSpacingAndUpdateTablePadding()`\r\n\t\t// then there would be a bug because\r\n\t\t// `this.measureWidthHeightsAndSpacingAndUpdateTablePadding()`\r\n\t\t// calls `this.updateState({ verticalSpacing })` which calls\r\n\t\t// `this.onRender()` immediately, so `this.widthHasChanged`\r\n\t\t// flag wouldn't be reset by that time and would trigger things\r\n\t\t// like `this.itemHeights.reset()` a second time.\r\n\t\t//\r\n\t\t// So, instead read the value of `this.widthHasChanged` flag\r\n\t\t// and reset it right away to prevent any such potential bugs.\r\n\t\t//\r\n\t\tconst widthHasChanged = Boolean(this.widthHasChanged)\r\n\t\t//\r\n\t\t// Reset `this.widthHasChanged` flag.\r\n\t\tthis.widthHasChanged = undefined\r\n\r\n\t\t// Read `this.firstNonMeasuredItemIndex` flag.\r\n\t\tconst nonMeasuredItemsHaveBeenRendered = this.firstNonMeasuredItemIndex !== undefined\r\n\t\tif (nonMeasuredItemsHaveBeenRendered) {\r\n\t\t\tlog('Non-measured item index', this.firstNonMeasuredItemIndex)\r\n\t\t}\r\n\t\t// Reset `this.firstNonMeasuredItemIndex` flag.\r\n\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\r\n\t\t// Reset `this.newItemsWillBeRendered` flag.\r\n\t\tthis.newItemsWillBeRendered = undefined\r\n\r\n\t\t// Reset `this.itemHeightsThatChangedWhileNewItemsWereBeingRendered`.\r\n\t\tthis.itemHeightsThatChangedWhileNewItemsWereBeingRendered = undefined\r\n\r\n\t\t// Reset `this.itemStatesThatChangedWhileNewItemsWereBeingRendered`.\r\n\t\tthis.itemStatesThatChangedWhileNewItemsWereBeingRendered = undefined\r\n\r\n\t\t// Reset `this.updateLayoutAfterRenderBecauseItemHeightChanged`.\r\n\t\tconst itemHeightHasChanged = this.updateLayoutAfterRenderBecauseItemHeightChanged\r\n\t\tthis.updateLayoutAfterRenderBecauseItemHeightChanged = undefined\r\n\r\n\t\treturn {\r\n\t\t\tnonMeasuredItemsHaveBeenRendered,\r\n\t\t\titemHeightHasChanged,\r\n\t\t\twidthHasChanged\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEe,oBAAW;EAAA;;EACzB;AACD;AACA;AACA;AACA;EACC,KAAKA,SAAL,GAAiB,UAACC,QAAD,EAAWC,SAAX,EAAyB;IACzC,KAAI,CAACC,gBAAL,GAAwB,KAAxB;IAEA,IAAAC,iBAAA,EAAI,cAAJ;;IACA,IAAI,IAAAC,cAAA,GAAJ,EAAe;MACd,IAAAD,iBAAA,EAAI,OAAJ,EAAa,IAAAE,4BAAA,EAAiBL,QAAjB,CAAb;IACA;;IAED,IAAI,KAAI,CAACM,aAAT,EAAwB;MACvB,IAAI,CAAC,IAAAC,wBAAA,EAAaP,QAAb,EAAuBC,SAAvB,CAAL,EAAwC;QACvC,KAAI,CAACK,aAAL,CAAmBN,QAAnB;MACA;IACD,CAZwC,CAczC;IACA;IACA;;;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QAAEjC,WAAW,EAAXA;MAAF,CAAvB,CAAd,CAFiC,CAGjC;;MACA,KAAKkC,mBAAL,CAAyB;QACxBpB,MAAM,EAANA,MADwB;QAExBd,WAAW,EAAXA;MAFwB,CAAzB;IAIA,CARD,MAQO;MACN,KAAKmC,wBAAL,CAA8B;QAC7BrB,MAAM,EAANA,MAD6B;QAE7Bd,WAAW,EAAXA;MAF6B,CAA9B;IAIA;EACD;;EAED,SAASxB,qBAAT,GAAiC;IAChC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAMI,eAAe,GAAGwD,OAAO,CAAC,KAAKxD,eAAN,CAA/B,CAfgC,CAgBhC;IACA;;IACA,KAAKA,eAAL,GAAuBU,SAAvB,CAlBgC,CAoBhC;;IACA,IAAMZ,gCAAgC,GAAG,KAAK2D,yBAAL,KAAmC/C,SAA5E;;IACA,IAAIZ,gCAAJ,EAAsC;MACrC,IAAAf,iBAAA,EAAI,yBAAJ,EAA+B,KAAK0E,yBAApC;IACA,CAxB+B,CAyBhC;;;IACA,KAAKA,yBAAL,GAAiC/C,SAAjC,CA1BgC,CA4BhC;;IACA,KAAKgD,sBAAL,GAA8BhD,SAA9B,CA7BgC,CA+BhC;;IACA,KAAK8B,oDAAL,GAA4D9B,SAA5D,CAhCgC,CAkChC;;IACA,KAAKmC,mDAAL,GAA2DnC,SAA3D,CAnCgC,CAqChC;;IACA,IAAMX,oBAAoB,GAAG,KAAKG,+CAAlC;IACA,KAAKA,+CAAL,GAAuDQ,SAAvD;IAEA,OAAO;MACNZ,gCAAgC,EAAhCA,gCADM;MAENC,oBAAoB,EAApBA,oBAFM;MAGNC,eAAe,EAAfA;IAHM,CAAP;EAKA;AACD"}
1
+ {"version":3,"file":"VirtualScroller.onRender.js","names":["_onRender","newState","prevState","waitingForRender","log","isDebug","getStateSnapshot","onStateChange","shallowEqual","tbody","setTbodyPadding","getItemsContainerElement","beforeItemsHeight","afterItemsHeight","mostRecentSetStateValue","warn","reportError","resetStateUpdateFlags","call","nonMeasuredItemsHaveBeenRendered","itemHeightHasChanged","widthHasChanged","layoutUpdateReason","LAYOUT_REASON","ITEM_HEIGHT_CHANGED","NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED","VIEWPORT_WIDTH_CHANGED","itemHeights","reset","verticalSpacing","undefined","previousItems","items","newItems","itemsDiff","getItemsDiff","prependedItemsCount","onPrepend","onNewItemsRendered","ITEMS_CHANGED","stateUpdate","firstShownItemIndex","lastShownItemIndex","verticalSpacingStateUpdate","measureItemHeightsAndSpacing","cleanedUpBeforeResize","beforeResize","cleanUpBeforeResizeItemHeights","scrollBy","scroll","scrollByY","_isActive","_stoppedStateUpdate","updateStateRightAfterRender","reason","updateState","newLayout","appendedItemsCount","getState","itemStates","itemHeightsThatChangedWhileNewItemsWereBeingRendered","Object","keys","i","Number","itemStatesThatChangedWhileNewItemsWereBeingRendered","previouslyCalculatedLayout","listHeightMeasurement","hasSnapshot","listBottomOffsetChange","getListBottomOffsetChange","shownItemsHeight","_useTimeoutInRenderLoop","cancelLayoutTimer","scheduleLayoutTimer","onUpdateShownItemIndexes","Boolean","firstNonMeasuredItemIndex","newItemsWillBeRendered","updateLayoutAfterRenderBecauseItemHeightChanged"],"sources":["../source/VirtualScroller.onRender.js"],"sourcesContent":["import log, { warn, reportError, isDebug } from './utility/debug.js'\r\nimport getStateSnapshot from './utility/getStateSnapshot.js'\r\nimport shallowEqual from './utility/shallowEqual.js'\r\nimport { LAYOUT_REASON } from './Layout.js'\r\nimport { setTbodyPadding } from './DOM/tbody.js'\r\n\r\nexport default function() {\r\n\t/**\r\n\t * Should be called right after updates to `state` have been rendered.\r\n\t * @param {object} newState\r\n\t * @param {object} [prevState]\r\n\t */\r\n\tthis._onRender = (newState, prevState) => {\r\n\t\tthis.waitingForRender = false\r\n\r\n\t\tlog('~ Rendered ~')\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('State', getStateSnapshot(newState))\r\n\t\t}\r\n\r\n\t\tif (this.onStateChange) {\r\n\t\t\tif (!shallowEqual(newState, prevState)) {\r\n\t\t\t\tthis.onStateChange(newState)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Update `<tbody/>` `padding`.\r\n\t\t// (`<tbody/>` is different in a way that it can't have `margin`, only `padding`).\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1\r\n\t\tif (this.tbody) {\r\n\t\t\tsetTbodyPadding(\r\n\t\t\t\tthis.getItemsContainerElement(),\r\n\t\t\t\tnewState.beforeItemsHeight,\r\n\t\t\t\tnewState.afterItemsHeight\r\n\t\t\t)\r\n\t\t}\r\n\r\n\t\t// `this.mostRecentlySetState` checks that state management behavior is correct:\r\n\t\t// that in situations when there're multiple new states waiting to be set,\r\n\t\t// only the latest one gets applied.\r\n\t\t// It keeps the code simpler and prevents possible race condition bugs.\r\n\t\t// For example, `VirtualScroller` keeps track of its latest requested\r\n\t\t// state update in different instance variable flags which assume that\r\n\t\t// only that latest requested state update gets actually applied.\r\n\t\t//\r\n\t\t// This check should also be performed for the initial render in order to\r\n\t\t// guarantee that no potentially incorrect state update goes unnoticed.\r\n\t\t// Incorrect state updates could happen when `VirtualScroller` state\r\n\t\t// is managed externally by passing `getState()`/`updateState()` options.\r\n\t\t//\r\n\t\t// Perform the check only when `this.mostRecentSetStateValue` is defined.\r\n\t\t// `this.mostRecentSetStateValue` is normally gonna be `undefined` at the initial render\r\n\t\t// because the initial state is not set by calling `this.updateState()`.\r\n\t\t// At the same time, it is possible that the initial render is delayed\r\n\t\t// for whatever reason, and `this.updateState()` gets called before the initial render,\r\n\t\t// so `this.mostRecentSetStateValue` could also be defined at the initial render,\r\n\t\t// in which case the check should be performed.\r\n\t\t//\r\n\t\tif (this.mostRecentSetStateValue) {\r\n\t\t\t// \"Shallow equality\" is used here instead of \"strict equality\"\r\n\t\t\t// because a developer might choose to supply an `updateState()` function\r\n\t\t\t// rather than a `setState()` function, in which case the `updateState()` function\r\n\t\t\t// would construct its own state object.\r\n\t\t\tif (!shallowEqual(newState, this.mostRecentSetStateValue)) {\r\n\t\t\t\twarn('The most recent state that was set', getStateSnapshot(this.mostRecentSetStateValue))\r\n\t\t\t\treportError('The state that has been rendered is not the most recent one that was set')\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `this.resetStateUpdateFlags()` must be called before calling\r\n\t\t// `this.measureItemHeightsAndSpacing()`.\r\n\t\tconst {\r\n\t\t\tnonMeasuredItemsHaveBeenRendered,\r\n\t\t\titemHeightHasChanged,\r\n\t\t\twidthHasChanged\r\n\t\t} = resetStateUpdateFlags.call(this)\r\n\r\n\t\tlet layoutUpdateReason\r\n\r\n\t\tif (itemHeightHasChanged) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.ITEM_HEIGHT_CHANGED\r\n\t\t}\r\n\r\n\t\tif (!prevState) {\r\n\t\t\tif (!layoutUpdateReason) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If the `VirtualScroller`, while calculating layout parameters, encounters\r\n\t\t// a not-shown item with a non-measured height, it calls `updateState()` just to\r\n\t\t// render that item first, and then, after the list has been re-rendered, it measures\r\n\t\t// the item's height and then proceeds with calculating the correct layout parameters.\r\n\t\tif (nonMeasuredItemsHaveBeenRendered) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED\r\n\t\t}\r\n\r\n\t\t// If scrollable container width has changed, and it has been re-rendered,\r\n\t\t// then it's time to measure the new item heights and then perform a re-layout\r\n\t\t// with the correctly calculated layout parameters.\r\n\t\t//\r\n\t\t// A re-layout is required because the layout parameters calculated on resize\r\n\t\t// are approximate ones, and the exact item heights aren't known at that point.\r\n\t\t// So on resize, it calls `updateState()` 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\tif (widthHasChanged) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.VIEWPORT_WIDTH_CHANGED\r\n\r\n\t\t\t// Reset measured item heights on viewport width change.\r\n\t\t\tthis.itemHeights.reset()\r\n\r\n\t\t\t// Reset `verticalSpacing` (will be re-measured).\r\n\t\t\tthis.verticalSpacing = undefined\r\n\t\t}\r\n\r\n\t\tif (prevState) {\r\n\t\t\tconst { items: previousItems } = prevState\r\n\t\t\tconst { items: newItems } = newState\r\n\t\t\t// Even if `this.newItemsWillBeRendered` flag is `true`,\r\n\t\t\t// `newItems` could still be equal to `previousItems`.\r\n\t\t\t// For example, when `updateState()` calls don't update `state` immediately\r\n\t\t\t// and a developer first calls `setItems(newItems)` and then calls `setItems(oldItems)`:\r\n\t\t\t// in that case, `this.newItemsWillBeRendered` flag will be `true` but the actual `items`\r\n\t\t\t// in state wouldn't have changed due to the first `updateState()` call being overwritten\r\n\t\t\t// by the second `updateState()` call (that's called \"batching state updates\" in React).\r\n\t\t\tif (newItems !== previousItems) {\r\n\t\t\t\tconst itemsDiff = this.getItemsDiff(previousItems, newItems)\r\n\t\t\t\tif (itemsDiff) {\r\n\t\t\t\t\t// The call to `.onPrepend()` must precede the call to `.measureItemHeights()`\r\n\t\t\t\t\t// which is called in `.onRender()`.\r\n\t\t\t\t\t// `this.itemHeights.onPrepend()` updates `firstMeasuredItemIndex`\r\n\t\t\t\t\t// and `lastMeasuredItemIndex` of `this.itemHeights`.\r\n\t\t\t\t\tconst { prependedItemsCount } = itemsDiff\r\n\t\t\t\t\tthis.itemHeights.onPrepend(prependedItemsCount)\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.itemHeights.reset()\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (!widthHasChanged) {\r\n\t\t\t\t\t// The call to `this.onNewItemsRendered()` must precede the call to\r\n\t\t\t\t\t// `.measureItemHeights()` which is called in `.onRender()` because\r\n\t\t\t\t\t// `this.onNewItemsRendered()` updates `firstMeasuredItemIndex` and\r\n\t\t\t\t\t// `lastMeasuredItemIndex` of `this.itemHeights` in case of a prepend.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// If after prepending items the scroll position\r\n\t\t\t\t\t// should be \"restored\" so that there's no \"jump\" of content\r\n\t\t\t\t\t// then it means that all previous items have just been rendered\r\n\t\t\t\t\t// in a single pass, and there's no need to update layout again.\r\n\t\t\t\t\t//\r\n\t\t\t\t\tif (onNewItemsRendered.call(this, itemsDiff, newState) !== 'SEAMLESS_PREPEND') {\r\n\t\t\t\t\t\tlayoutUpdateReason = LAYOUT_REASON.ITEMS_CHANGED\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\tlet stateUpdate\r\n\r\n\t\t// Re-measure item heights.\r\n\t\t// Also, measure vertical spacing (if not measured) and fix `<table/>` padding.\r\n\t\t//\r\n\t\t// This block should go after `if (newItems !== previousItems) {}`\r\n\t\t// because `this.itemHeights` can get `.reset()` there, which would\r\n\t\t// discard all the measurements done here, and having currently shown\r\n\t\t// item height measurements is required.\r\n\t\t//\r\n\t\tif (\r\n\t\t\t(prevState && (\r\n\t\t\t\tnewState.firstShownItemIndex !== prevState.firstShownItemIndex ||\r\n\t\t\t\tnewState.lastShownItemIndex !== prevState.lastShownItemIndex ||\r\n\t\t\t\tnewState.items !== prevState.items\r\n\t\t\t)) ||\r\n\t\t\twidthHasChanged\r\n\t\t) {\r\n\t\t\tconst verticalSpacingStateUpdate = this.measureItemHeightsAndSpacing()\r\n\t\t\tif (verticalSpacingStateUpdate) {\r\n\t\t\t\tstateUpdate = {\r\n\t\t\t\t\t...stateUpdate,\r\n\t\t\t\t\t...verticalSpacingStateUpdate\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Clean up \"before resize\" item heights and adjust the scroll position accordingly.\r\n\t\t// Calling `this.beforeResize.cleanUpBeforeResizeItemHeights()` might trigger\r\n\t\t// a `this.updateState()` call but that wouldn't matter because `beforeResize`\r\n\t\t// properties have already been modified directly in `state` (a hacky technique)\r\n\t\tconst cleanedUpBeforeResize = this.beforeResize.cleanUpBeforeResizeItemHeights()\r\n\t\tif (cleanedUpBeforeResize !== undefined) {\r\n\t\t\tconst { scrollBy, beforeResize } = cleanedUpBeforeResize\r\n\t\t\tlog('Correct scroll position by', scrollBy)\r\n\t\t\tthis.scroll.scrollByY(scrollBy)\r\n\t\t\tstateUpdate = {\r\n\t\t\t\t...stateUpdate,\r\n\t\t\t\tbeforeResize\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!this._isActive) {\r\n\t\t\tthis._stoppedStateUpdate = stateUpdate\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (layoutUpdateReason) {\r\n\t\t\tupdateStateRightAfterRender.call(this, {\r\n\t\t\t\tstateUpdate,\r\n\t\t\t\treason: layoutUpdateReason\r\n\t\t\t})\r\n\t\t} else if (stateUpdate) {\r\n\t\t\tthis.updateState(stateUpdate)\r\n\t\t} else {\r\n\t\t\tlog('~ Finished Layout ~')\r\n\t\t}\r\n\t}\r\n\r\n\t// After a new set of items has been rendered:\r\n\t//\r\n\t// * Restores scroll position when using `preserveScrollPositionOnPrependItems`\r\n\t// and items have been prepended.\r\n\t//\r\n\t// * Applies any \"pending\" `itemHeights` updates — those ones that happened\r\n\t// while an asynchronous `updateState()` call in `setItems()` was pending.\r\n\t//\r\n\t// * Either creates or resets the snapshot of the current layout.\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\t// The \"previously calculated layout\" feature is not currently used.\r\n\t//\r\n\tfunction onNewItemsRendered(itemsDiff, newLayout) {\r\n\t\t// If it's an \"incremental\" update.\r\n\t\tif (itemsDiff) {\r\n\t\t\tconst {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t} = itemsDiff\r\n\r\n\t\t\tconst {\r\n\t\t\t\titemHeights,\r\n\t\t\t\titemStates\r\n\t\t\t} = this.getState()\r\n\r\n\t\t\t// See if any items' heights changed while new items were being rendered.\r\n\t\t\tif (this.itemHeightsThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tfor (const i of Object.keys(this.itemHeightsThatChangedWhileNewItemsWereBeingRendered)) {\r\n\t\t\t\t\titemHeights[prependedItemsCount + Number(i)] = this.itemHeightsThatChangedWhileNewItemsWereBeingRendered[i]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// See if any items' states changed while new items were being rendered.\r\n\t\t\tif (this.itemStatesThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tfor (const i of Object.keys(this.itemStatesThatChangedWhileNewItemsWereBeingRendered)) {\r\n\t\t\t\t\titemStates[prependedItemsCount + Number(i)] = this.itemStatesThatChangedWhileNewItemsWereBeingRendered[i]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (prependedItemsCount === 0) {\r\n\t\t\t\t// Adjust `this.previouslyCalculatedLayout`.\r\n\t\t\t\tif (this.previouslyCalculatedLayout) {\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout.firstShownItemIndex === newLayout.firstShownItemIndex &&\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout.lastShownItemIndex === newLayout.lastShownItemIndex\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\t// `this.previouslyCalculatedLayout` stays the same.\r\n\t\t\t\t\t\t// `firstShownItemIndex` / `lastShownItemIndex` didn't get changed in `setItems()`,\r\n\t\t\t\t\t\t// so `beforeItemsHeight` and `shownItemsHeight` also stayed the same.\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\twarn('Unexpected (non-matching) \"firstShownItemIndex\" or \"lastShownItemIndex\" encountered in \"onRender()\" after appending items')\r\n\t\t\t\t\t\twarn('Previously calculated layout', this.previouslyCalculatedLayout)\r\n\t\t\t\t\t\twarn('New layout', newLayout)\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout = undefined\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn 'SEAMLESS_APPEND'\r\n\t\t\t} else {\r\n\t\t\t\tif (this.listHeightMeasurement.hasSnapshot()) {\r\n\t\t\t\t\tif (newLayout.firstShownItemIndex === 0) {\r\n\t\t\t\t\t\t// Restore (adjust) scroll position.\r\n\t\t\t\t\t\tlog('~ Restore Scroll Position ~')\r\n\t\t\t\t\t\tconst listBottomOffsetChange = this.listHeightMeasurement.getListBottomOffsetChange({\r\n\t\t\t\t\t\t\tbeforeItemsHeight: newLayout.beforeItemsHeight\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t\tthis.listHeightMeasurement.reset()\r\n\t\t\t\t\t\tif (listBottomOffsetChange) {\r\n\t\t\t\t\t\t\tlog('Scroll down by', listBottomOffsetChange)\r\n\t\t\t\t\t\t\tthis.scroll.scrollByY(listBottomOffsetChange)\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tlog('Scroll position hasn\\'t changed')\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t// Create new `this.previouslyCalculatedLayout`.\r\n\t\t\t\t\t\tif (this.previouslyCalculatedLayout) {\r\n\t\t\t\t\t\t\tif (\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout.firstShownItemIndex === 0 &&\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout.lastShownItemIndex === newLayout.lastShownItemIndex - prependedItemsCount\r\n\t\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout = {\r\n\t\t\t\t\t\t\t\t\tbeforeItemsHeight: 0,\r\n\t\t\t\t\t\t\t\t\tshownItemsHeight: this.previouslyCalculatedLayout.shownItemsHeight + listBottomOffsetChange,\r\n\t\t\t\t\t\t\t\t\tfirstShownItemIndex: 0,\r\n\t\t\t\t\t\t\t\t\tlastShownItemIndex: newLayout.lastShownItemIndex\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\twarn('Unexpected (non-matching) \"firstShownItemIndex\" or \"lastShownItemIndex\" encountered in \"onRender()\" after prepending items')\r\n\t\t\t\t\t\t\t\twarn('Previously calculated layout', this.previouslyCalculatedLayout)\r\n\t\t\t\t\t\t\t\twarn('New layout', newLayout)\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout = undefined\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn 'SEAMLESS_PREPEND'\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\twarn(`Unexpected \"firstShownItemIndex\" ${newLayout.firstShownItemIndex} encountered in \"onRender()\" after prepending items. Expected 0.`)\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\t// Reset `this.previouslyCalculatedLayout` in any case other than\r\n\t\t// SEAMLESS_PREPEND or SEAMLESS_APPEND.\r\n\t\tthis.previouslyCalculatedLayout = undefined\r\n\t}\r\n\r\n\tfunction updateStateRightAfterRender({\r\n\t\treason,\r\n\t\tstateUpdate\r\n\t}) {\r\n\t\t// In React, `setTimeout()` is used to prevent a React error:\r\n\t\t// \"Maximum update depth exceeded.\r\n\t\t// This can happen when a component repeatedly calls\r\n\t\t// `.updateState()` inside `componentWillUpdate()` or `componentDidUpdate()`.\r\n\t\t// React limits the number of nested updates to prevent infinite loops.\"\r\n\t\tif (this._useTimeoutInRenderLoop) {\r\n\t\t\t// Cancel a previously scheduled re-layout.\r\n\t\t\tstateUpdate = this.cancelLayoutTimer({ stateUpdate })\r\n\t\t\t// Schedule a new re-layout.\r\n\t\t\tthis.scheduleLayoutTimer({\r\n\t\t\t\treason,\r\n\t\t\t\tstateUpdate\r\n\t\t\t})\r\n\t\t} else {\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}\r\n\t}\r\n\r\n\tfunction resetStateUpdateFlags() {\r\n\t\t// Read and reset `this.widthHasChanged` flag.\r\n\t\t//\r\n\t\t// If `this.widthHasChanged` flag was reset after calling\r\n\t\t// `this.measureWidthHeightsAndSpacingAndUpdateTablePadding()`\r\n\t\t// then there would be a bug because\r\n\t\t// `this.measureWidthHeightsAndSpacingAndUpdateTablePadding()`\r\n\t\t// calls `this.updateState({ verticalSpacing })` which calls\r\n\t\t// `this.onRender()` immediately, so `this.widthHasChanged`\r\n\t\t// flag wouldn't be reset by that time and would trigger things\r\n\t\t// like `this.itemHeights.reset()` a second time.\r\n\t\t//\r\n\t\t// So, instead read the value of `this.widthHasChanged` flag\r\n\t\t// and reset it right away to prevent any such potential bugs.\r\n\t\t//\r\n\t\tconst widthHasChanged = Boolean(this.widthHasChanged)\r\n\t\t//\r\n\t\t// Reset `this.widthHasChanged` flag.\r\n\t\tthis.widthHasChanged = undefined\r\n\r\n\t\t// Read `this.firstNonMeasuredItemIndex` flag.\r\n\t\tconst nonMeasuredItemsHaveBeenRendered = this.firstNonMeasuredItemIndex !== undefined\r\n\t\tif (nonMeasuredItemsHaveBeenRendered) {\r\n\t\t\tlog('Non-measured item index', this.firstNonMeasuredItemIndex)\r\n\t\t}\r\n\t\t// Reset `this.firstNonMeasuredItemIndex` flag.\r\n\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\r\n\t\t// Reset `this.newItemsWillBeRendered` flag.\r\n\t\tthis.newItemsWillBeRendered = undefined\r\n\r\n\t\t// Reset `this.itemHeightsThatChangedWhileNewItemsWereBeingRendered`.\r\n\t\tthis.itemHeightsThatChangedWhileNewItemsWereBeingRendered = undefined\r\n\r\n\t\t// Reset `this.itemStatesThatChangedWhileNewItemsWereBeingRendered`.\r\n\t\tthis.itemStatesThatChangedWhileNewItemsWereBeingRendered = undefined\r\n\r\n\t\t// Reset `this.updateLayoutAfterRenderBecauseItemHeightChanged`.\r\n\t\tconst itemHeightHasChanged = this.updateLayoutAfterRenderBecauseItemHeightChanged\r\n\t\tthis.updateLayoutAfterRenderBecauseItemHeightChanged = undefined\r\n\r\n\t\treturn {\r\n\t\t\tnonMeasuredItemsHaveBeenRendered,\r\n\t\t\titemHeightHasChanged,\r\n\t\t\twidthHasChanged\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEe,oBAAW;EAAA;;EACzB;AACD;AACA;AACA;AACA;EACC,KAAKA,SAAL,GAAiB,UAACC,QAAD,EAAWC,SAAX,EAAyB;IACzC,KAAI,CAACC,gBAAL,GAAwB,KAAxB;IAEA,IAAAC,iBAAA,EAAI,cAAJ;;IACA,IAAI,IAAAC,cAAA,GAAJ,EAAe;MACd,IAAAD,iBAAA,EAAI,OAAJ,EAAa,IAAAE,4BAAA,EAAiBL,QAAjB,CAAb;IACA;;IAED,IAAI,KAAI,CAACM,aAAT,EAAwB;MACvB,IAAI,CAAC,IAAAC,wBAAA,EAAaP,QAAb,EAAuBC,SAAvB,CAAL,EAAwC;QACvC,KAAI,CAACK,aAAL,CAAmBN,QAAnB;MACA;IACD,CAZwC,CAczC;IACA;IACA;;;IACA,IAAI,KAAI,CAACQ,KAAT,EAAgB;MACf,IAAAC,sBAAA,EACC,KAAI,CAACC,wBAAL,EADD,EAECV,QAAQ,CAACW,iBAFV,EAGCX,QAAQ,CAACY,gBAHV;IAKA,CAvBwC,CAyBzC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;IACA,IAAI,KAAI,CAACC,uBAAT,EAAkC;MACjC;MACA;MACA;MACA;MACA,IAAI,CAAC,IAAAN,wBAAA,EAAaP,QAAb,EAAuB,KAAI,CAACa,uBAA5B,CAAL,EAA2D;QAC1D,IAAAC,WAAA,EAAK,oCAAL,EAA2C,IAAAT,4BAAA,EAAiB,KAAI,CAACQ,uBAAtB,CAA3C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IAAMX,gCAAgC,GAAG,KAAK0D,yBAAL,KAAmC/C,SAA5E;;IACA,IAAIX,gCAAJ,EAAsC;MACrC,IAAAf,iBAAA,EAAI,yBAAJ,EAA+B,KAAKyE,yBAApC;IACA,CAxB+B,CAyBhC;;;IACA,KAAKA,yBAAL,GAAiC/C,SAAjC,CA1BgC,CA4BhC;;IACA,KAAKgD,sBAAL,GAA8BhD,SAA9B,CA7BgC,CA+BhC;;IACA,KAAK8B,oDAAL,GAA4D9B,SAA5D,CAhCgC,CAkChC;;IACA,KAAKmC,mDAAL,GAA2DnC,SAA3D,CAnCgC,CAqChC;;IACA,IAAMV,oBAAoB,GAAG,KAAK2D,+CAAlC;IACA,KAAKA,+CAAL,GAAuDjD,SAAvD;IAEA,OAAO;MACNX,gCAAgC,EAAhCA,gCADM;MAENC,oBAAoB,EAApBA,oBAFM;MAGNC,eAAe,EAAfA;IAHM,CAAP;EAKA;AACD"}
@@ -79,7 +79,7 @@ export default function () {
79
79
 
80
80
  var layoutUpdateReason;
81
81
 
82
- if (_this.updateLayoutAfterRenderBecauseItemHeightChanged) {
82
+ if (itemHeightHasChanged) {
83
83
  layoutUpdateReason = LAYOUT_REASON.ITEM_HEIGHT_CHANGED;
84
84
  }
85
85
 
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualScroller.onRender.js","names":["log","warn","reportError","isDebug","getStateSnapshot","shallowEqual","LAYOUT_REASON","setTbodyPadding","_onRender","newState","prevState","waitingForRender","onStateChange","tbody","getItemsContainerElement","beforeItemsHeight","afterItemsHeight","mostRecentSetStateValue","resetStateUpdateFlags","call","nonMeasuredItemsHaveBeenRendered","itemHeightHasChanged","widthHasChanged","layoutUpdateReason","updateLayoutAfterRenderBecauseItemHeightChanged","ITEM_HEIGHT_CHANGED","NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED","VIEWPORT_WIDTH_CHANGED","itemHeights","reset","verticalSpacing","undefined","previousItems","items","newItems","itemsDiff","getItemsDiff","prependedItemsCount","onPrepend","onNewItemsRendered","ITEMS_CHANGED","stateUpdate","firstShownItemIndex","lastShownItemIndex","verticalSpacingStateUpdate","measureItemHeightsAndSpacing","cleanedUpBeforeResize","beforeResize","cleanUpBeforeResizeItemHeights","scrollBy","scroll","scrollByY","_isActive","_stoppedStateUpdate","updateStateRightAfterRender","reason","updateState","newLayout","appendedItemsCount","getState","itemStates","itemHeightsThatChangedWhileNewItemsWereBeingRendered","Object","keys","i","Number","itemStatesThatChangedWhileNewItemsWereBeingRendered","previouslyCalculatedLayout","listHeightMeasurement","hasSnapshot","listBottomOffsetChange","getListBottomOffsetChange","shownItemsHeight","_useTimeoutInRenderLoop","cancelLayoutTimer","scheduleLayoutTimer","onUpdateShownItemIndexes","Boolean","firstNonMeasuredItemIndex","newItemsWillBeRendered"],"sources":["../source/VirtualScroller.onRender.js"],"sourcesContent":["import log, { warn, reportError, isDebug } from './utility/debug.js'\r\nimport getStateSnapshot from './utility/getStateSnapshot.js'\r\nimport shallowEqual from './utility/shallowEqual.js'\r\nimport { LAYOUT_REASON } from './Layout.js'\r\nimport { setTbodyPadding } from './DOM/tbody.js'\r\n\r\nexport default function() {\r\n\t/**\r\n\t * Should be called right after updates to `state` have been rendered.\r\n\t * @param {object} newState\r\n\t * @param {object} [prevState]\r\n\t */\r\n\tthis._onRender = (newState, prevState) => {\r\n\t\tthis.waitingForRender = false\r\n\r\n\t\tlog('~ Rendered ~')\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('State', getStateSnapshot(newState))\r\n\t\t}\r\n\r\n\t\tif (this.onStateChange) {\r\n\t\t\tif (!shallowEqual(newState, prevState)) {\r\n\t\t\t\tthis.onStateChange(newState)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Update `<tbody/>` `padding`.\r\n\t\t// (`<tbody/>` is different in a way that it can't have `margin`, only `padding`).\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1\r\n\t\tif (this.tbody) {\r\n\t\t\tsetTbodyPadding(\r\n\t\t\t\tthis.getItemsContainerElement(),\r\n\t\t\t\tnewState.beforeItemsHeight,\r\n\t\t\t\tnewState.afterItemsHeight\r\n\t\t\t)\r\n\t\t}\r\n\r\n\t\t// `this.mostRecentlySetState` checks that state management behavior is correct:\r\n\t\t// that in situations when there're multiple new states waiting to be set,\r\n\t\t// only the latest one gets applied.\r\n\t\t// It keeps the code simpler and prevents possible race condition bugs.\r\n\t\t// For example, `VirtualScroller` keeps track of its latest requested\r\n\t\t// state update in different instance variable flags which assume that\r\n\t\t// only that latest requested state update gets actually applied.\r\n\t\t//\r\n\t\t// This check should also be performed for the initial render in order to\r\n\t\t// guarantee that no potentially incorrect state update goes unnoticed.\r\n\t\t// Incorrect state updates could happen when `VirtualScroller` state\r\n\t\t// is managed externally by passing `getState()`/`updateState()` options.\r\n\t\t//\r\n\t\t// Perform the check only when `this.mostRecentSetStateValue` is defined.\r\n\t\t// `this.mostRecentSetStateValue` is normally gonna be `undefined` at the initial render\r\n\t\t// because the initial state is not set by calling `this.updateState()`.\r\n\t\t// At the same time, it is possible that the initial render is delayed\r\n\t\t// for whatever reason, and `this.updateState()` gets called before the initial render,\r\n\t\t// so `this.mostRecentSetStateValue` could also be defined at the initial render,\r\n\t\t// in which case the check should be performed.\r\n\t\t//\r\n\t\tif (this.mostRecentSetStateValue) {\r\n\t\t\t// \"Shallow equality\" is used here instead of \"strict equality\"\r\n\t\t\t// because a developer might choose to supply an `updateState()` function\r\n\t\t\t// rather than a `setState()` function, in which case the `updateState()` function\r\n\t\t\t// would construct its own state object.\r\n\t\t\tif (!shallowEqual(newState, this.mostRecentSetStateValue)) {\r\n\t\t\t\twarn('The most recent state that was set', getStateSnapshot(this.mostRecentSetStateValue))\r\n\t\t\t\treportError('The state that has been rendered is not the most recent one that was set')\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `this.resetStateUpdateFlags()` must be called before calling\r\n\t\t// `this.measureItemHeightsAndSpacing()`.\r\n\t\tconst {\r\n\t\t\tnonMeasuredItemsHaveBeenRendered,\r\n\t\t\titemHeightHasChanged,\r\n\t\t\twidthHasChanged\r\n\t\t} = resetStateUpdateFlags.call(this)\r\n\r\n\t\tlet layoutUpdateReason\r\n\r\n\t\tif (this.updateLayoutAfterRenderBecauseItemHeightChanged) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.ITEM_HEIGHT_CHANGED\r\n\t\t}\r\n\r\n\t\tif (!prevState) {\r\n\t\t\tif (!layoutUpdateReason) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If the `VirtualScroller`, while calculating layout parameters, encounters\r\n\t\t// a not-shown item with a non-measured height, it calls `updateState()` just to\r\n\t\t// render that item first, and then, after the list has been re-rendered, it measures\r\n\t\t// the item's height and then proceeds with calculating the correct layout parameters.\r\n\t\tif (nonMeasuredItemsHaveBeenRendered) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED\r\n\t\t}\r\n\r\n\t\t// If scrollable container width has changed, and it has been re-rendered,\r\n\t\t// then it's time to measure the new item heights and then perform a re-layout\r\n\t\t// with the correctly calculated layout parameters.\r\n\t\t//\r\n\t\t// A re-layout is required because the layout parameters calculated on resize\r\n\t\t// are approximate ones, and the exact item heights aren't known at that point.\r\n\t\t// So on resize, it calls `updateState()` 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\tif (widthHasChanged) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.VIEWPORT_WIDTH_CHANGED\r\n\r\n\t\t\t// Reset measured item heights on viewport width change.\r\n\t\t\tthis.itemHeights.reset()\r\n\r\n\t\t\t// Reset `verticalSpacing` (will be re-measured).\r\n\t\t\tthis.verticalSpacing = undefined\r\n\t\t}\r\n\r\n\t\tif (prevState) {\r\n\t\t\tconst { items: previousItems } = prevState\r\n\t\t\tconst { items: newItems } = newState\r\n\t\t\t// Even if `this.newItemsWillBeRendered` flag is `true`,\r\n\t\t\t// `newItems` could still be equal to `previousItems`.\r\n\t\t\t// For example, when `updateState()` calls don't update `state` immediately\r\n\t\t\t// and a developer first calls `setItems(newItems)` and then calls `setItems(oldItems)`:\r\n\t\t\t// in that case, `this.newItemsWillBeRendered` flag will be `true` but the actual `items`\r\n\t\t\t// in state wouldn't have changed due to the first `updateState()` call being overwritten\r\n\t\t\t// by the second `updateState()` call (that's called \"batching state updates\" in React).\r\n\t\t\tif (newItems !== previousItems) {\r\n\t\t\t\tconst itemsDiff = this.getItemsDiff(previousItems, newItems)\r\n\t\t\t\tif (itemsDiff) {\r\n\t\t\t\t\t// The call to `.onPrepend()` must precede the call to `.measureItemHeights()`\r\n\t\t\t\t\t// which is called in `.onRender()`.\r\n\t\t\t\t\t// `this.itemHeights.onPrepend()` updates `firstMeasuredItemIndex`\r\n\t\t\t\t\t// and `lastMeasuredItemIndex` of `this.itemHeights`.\r\n\t\t\t\t\tconst { prependedItemsCount } = itemsDiff\r\n\t\t\t\t\tthis.itemHeights.onPrepend(prependedItemsCount)\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.itemHeights.reset()\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (!widthHasChanged) {\r\n\t\t\t\t\t// The call to `this.onNewItemsRendered()` must precede the call to\r\n\t\t\t\t\t// `.measureItemHeights()` which is called in `.onRender()` because\r\n\t\t\t\t\t// `this.onNewItemsRendered()` updates `firstMeasuredItemIndex` and\r\n\t\t\t\t\t// `lastMeasuredItemIndex` of `this.itemHeights` in case of a prepend.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// If after prepending items the scroll position\r\n\t\t\t\t\t// should be \"restored\" so that there's no \"jump\" of content\r\n\t\t\t\t\t// then it means that all previous items have just been rendered\r\n\t\t\t\t\t// in a single pass, and there's no need to update layout again.\r\n\t\t\t\t\t//\r\n\t\t\t\t\tif (onNewItemsRendered.call(this, itemsDiff, newState) !== 'SEAMLESS_PREPEND') {\r\n\t\t\t\t\t\tlayoutUpdateReason = LAYOUT_REASON.ITEMS_CHANGED\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\tlet stateUpdate\r\n\r\n\t\t// Re-measure item heights.\r\n\t\t// Also, measure vertical spacing (if not measured) and fix `<table/>` padding.\r\n\t\t//\r\n\t\t// This block should go after `if (newItems !== previousItems) {}`\r\n\t\t// because `this.itemHeights` can get `.reset()` there, which would\r\n\t\t// discard all the measurements done here, and having currently shown\r\n\t\t// item height measurements is required.\r\n\t\t//\r\n\t\tif (\r\n\t\t\t(prevState && (\r\n\t\t\t\tnewState.firstShownItemIndex !== prevState.firstShownItemIndex ||\r\n\t\t\t\tnewState.lastShownItemIndex !== prevState.lastShownItemIndex ||\r\n\t\t\t\tnewState.items !== prevState.items\r\n\t\t\t)) ||\r\n\t\t\twidthHasChanged\r\n\t\t) {\r\n\t\t\tconst verticalSpacingStateUpdate = this.measureItemHeightsAndSpacing()\r\n\t\t\tif (verticalSpacingStateUpdate) {\r\n\t\t\t\tstateUpdate = {\r\n\t\t\t\t\t...stateUpdate,\r\n\t\t\t\t\t...verticalSpacingStateUpdate\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Clean up \"before resize\" item heights and adjust the scroll position accordingly.\r\n\t\t// Calling `this.beforeResize.cleanUpBeforeResizeItemHeights()` might trigger\r\n\t\t// a `this.updateState()` call but that wouldn't matter because `beforeResize`\r\n\t\t// properties have already been modified directly in `state` (a hacky technique)\r\n\t\tconst cleanedUpBeforeResize = this.beforeResize.cleanUpBeforeResizeItemHeights()\r\n\t\tif (cleanedUpBeforeResize !== undefined) {\r\n\t\t\tconst { scrollBy, beforeResize } = cleanedUpBeforeResize\r\n\t\t\tlog('Correct scroll position by', scrollBy)\r\n\t\t\tthis.scroll.scrollByY(scrollBy)\r\n\t\t\tstateUpdate = {\r\n\t\t\t\t...stateUpdate,\r\n\t\t\t\tbeforeResize\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!this._isActive) {\r\n\t\t\tthis._stoppedStateUpdate = stateUpdate\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (layoutUpdateReason) {\r\n\t\t\tupdateStateRightAfterRender.call(this, {\r\n\t\t\t\tstateUpdate,\r\n\t\t\t\treason: layoutUpdateReason\r\n\t\t\t})\r\n\t\t} else if (stateUpdate) {\r\n\t\t\tthis.updateState(stateUpdate)\r\n\t\t} else {\r\n\t\t\tlog('~ Finished Layout ~')\r\n\t\t}\r\n\t}\r\n\r\n\t// After a new set of items has been rendered:\r\n\t//\r\n\t// * Restores scroll position when using `preserveScrollPositionOnPrependItems`\r\n\t// and items have been prepended.\r\n\t//\r\n\t// * Applies any \"pending\" `itemHeights` updates — those ones that happened\r\n\t// while an asynchronous `updateState()` call in `setItems()` was pending.\r\n\t//\r\n\t// * Either creates or resets the snapshot of the current layout.\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\t// The \"previously calculated layout\" feature is not currently used.\r\n\t//\r\n\tfunction onNewItemsRendered(itemsDiff, newLayout) {\r\n\t\t// If it's an \"incremental\" update.\r\n\t\tif (itemsDiff) {\r\n\t\t\tconst {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t} = itemsDiff\r\n\r\n\t\t\tconst {\r\n\t\t\t\titemHeights,\r\n\t\t\t\titemStates\r\n\t\t\t} = this.getState()\r\n\r\n\t\t\t// See if any items' heights changed while new items were being rendered.\r\n\t\t\tif (this.itemHeightsThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tfor (const i of Object.keys(this.itemHeightsThatChangedWhileNewItemsWereBeingRendered)) {\r\n\t\t\t\t\titemHeights[prependedItemsCount + Number(i)] = this.itemHeightsThatChangedWhileNewItemsWereBeingRendered[i]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// See if any items' states changed while new items were being rendered.\r\n\t\t\tif (this.itemStatesThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tfor (const i of Object.keys(this.itemStatesThatChangedWhileNewItemsWereBeingRendered)) {\r\n\t\t\t\t\titemStates[prependedItemsCount + Number(i)] = this.itemStatesThatChangedWhileNewItemsWereBeingRendered[i]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (prependedItemsCount === 0) {\r\n\t\t\t\t// Adjust `this.previouslyCalculatedLayout`.\r\n\t\t\t\tif (this.previouslyCalculatedLayout) {\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout.firstShownItemIndex === newLayout.firstShownItemIndex &&\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout.lastShownItemIndex === newLayout.lastShownItemIndex\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\t// `this.previouslyCalculatedLayout` stays the same.\r\n\t\t\t\t\t\t// `firstShownItemIndex` / `lastShownItemIndex` didn't get changed in `setItems()`,\r\n\t\t\t\t\t\t// so `beforeItemsHeight` and `shownItemsHeight` also stayed the same.\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\twarn('Unexpected (non-matching) \"firstShownItemIndex\" or \"lastShownItemIndex\" encountered in \"onRender()\" after appending items')\r\n\t\t\t\t\t\twarn('Previously calculated layout', this.previouslyCalculatedLayout)\r\n\t\t\t\t\t\twarn('New layout', newLayout)\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout = undefined\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn 'SEAMLESS_APPEND'\r\n\t\t\t} else {\r\n\t\t\t\tif (this.listHeightMeasurement.hasSnapshot()) {\r\n\t\t\t\t\tif (newLayout.firstShownItemIndex === 0) {\r\n\t\t\t\t\t\t// Restore (adjust) scroll position.\r\n\t\t\t\t\t\tlog('~ Restore Scroll Position ~')\r\n\t\t\t\t\t\tconst listBottomOffsetChange = this.listHeightMeasurement.getListBottomOffsetChange({\r\n\t\t\t\t\t\t\tbeforeItemsHeight: newLayout.beforeItemsHeight\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t\tthis.listHeightMeasurement.reset()\r\n\t\t\t\t\t\tif (listBottomOffsetChange) {\r\n\t\t\t\t\t\t\tlog('Scroll down by', listBottomOffsetChange)\r\n\t\t\t\t\t\t\tthis.scroll.scrollByY(listBottomOffsetChange)\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tlog('Scroll position hasn\\'t changed')\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t// Create new `this.previouslyCalculatedLayout`.\r\n\t\t\t\t\t\tif (this.previouslyCalculatedLayout) {\r\n\t\t\t\t\t\t\tif (\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout.firstShownItemIndex === 0 &&\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout.lastShownItemIndex === newLayout.lastShownItemIndex - prependedItemsCount\r\n\t\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout = {\r\n\t\t\t\t\t\t\t\t\tbeforeItemsHeight: 0,\r\n\t\t\t\t\t\t\t\t\tshownItemsHeight: this.previouslyCalculatedLayout.shownItemsHeight + listBottomOffsetChange,\r\n\t\t\t\t\t\t\t\t\tfirstShownItemIndex: 0,\r\n\t\t\t\t\t\t\t\t\tlastShownItemIndex: newLayout.lastShownItemIndex\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\twarn('Unexpected (non-matching) \"firstShownItemIndex\" or \"lastShownItemIndex\" encountered in \"onRender()\" after prepending items')\r\n\t\t\t\t\t\t\t\twarn('Previously calculated layout', this.previouslyCalculatedLayout)\r\n\t\t\t\t\t\t\t\twarn('New layout', newLayout)\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout = undefined\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn 'SEAMLESS_PREPEND'\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\twarn(`Unexpected \"firstShownItemIndex\" ${newLayout.firstShownItemIndex} encountered in \"onRender()\" after prepending items. Expected 0.`)\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\t// Reset `this.previouslyCalculatedLayout` in any case other than\r\n\t\t// SEAMLESS_PREPEND or SEAMLESS_APPEND.\r\n\t\tthis.previouslyCalculatedLayout = undefined\r\n\t}\r\n\r\n\tfunction updateStateRightAfterRender({\r\n\t\treason,\r\n\t\tstateUpdate\r\n\t}) {\r\n\t\t// In React, `setTimeout()` is used to prevent a React error:\r\n\t\t// \"Maximum update depth exceeded.\r\n\t\t// This can happen when a component repeatedly calls\r\n\t\t// `.updateState()` inside `componentWillUpdate()` or `componentDidUpdate()`.\r\n\t\t// React limits the number of nested updates to prevent infinite loops.\"\r\n\t\tif (this._useTimeoutInRenderLoop) {\r\n\t\t\t// Cancel a previously scheduled re-layout.\r\n\t\t\tstateUpdate = this.cancelLayoutTimer({ stateUpdate })\r\n\t\t\t// Schedule a new re-layout.\r\n\t\t\tthis.scheduleLayoutTimer({\r\n\t\t\t\treason,\r\n\t\t\t\tstateUpdate\r\n\t\t\t})\r\n\t\t} else {\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}\r\n\t}\r\n\r\n\tfunction resetStateUpdateFlags() {\r\n\t\t// Read and reset `this.widthHasChanged` flag.\r\n\t\t//\r\n\t\t// If `this.widthHasChanged` flag was reset after calling\r\n\t\t// `this.measureWidthHeightsAndSpacingAndUpdateTablePadding()`\r\n\t\t// then there would be a bug because\r\n\t\t// `this.measureWidthHeightsAndSpacingAndUpdateTablePadding()`\r\n\t\t// calls `this.updateState({ verticalSpacing })` which calls\r\n\t\t// `this.onRender()` immediately, so `this.widthHasChanged`\r\n\t\t// flag wouldn't be reset by that time and would trigger things\r\n\t\t// like `this.itemHeights.reset()` a second time.\r\n\t\t//\r\n\t\t// So, instead read the value of `this.widthHasChanged` flag\r\n\t\t// and reset it right away to prevent any such potential bugs.\r\n\t\t//\r\n\t\tconst widthHasChanged = Boolean(this.widthHasChanged)\r\n\t\t//\r\n\t\t// Reset `this.widthHasChanged` flag.\r\n\t\tthis.widthHasChanged = undefined\r\n\r\n\t\t// Read `this.firstNonMeasuredItemIndex` flag.\r\n\t\tconst nonMeasuredItemsHaveBeenRendered = this.firstNonMeasuredItemIndex !== undefined\r\n\t\tif (nonMeasuredItemsHaveBeenRendered) {\r\n\t\t\tlog('Non-measured item index', this.firstNonMeasuredItemIndex)\r\n\t\t}\r\n\t\t// Reset `this.firstNonMeasuredItemIndex` flag.\r\n\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\r\n\t\t// Reset `this.newItemsWillBeRendered` flag.\r\n\t\tthis.newItemsWillBeRendered = undefined\r\n\r\n\t\t// Reset `this.itemHeightsThatChangedWhileNewItemsWereBeingRendered`.\r\n\t\tthis.itemHeightsThatChangedWhileNewItemsWereBeingRendered = undefined\r\n\r\n\t\t// Reset `this.itemStatesThatChangedWhileNewItemsWereBeingRendered`.\r\n\t\tthis.itemStatesThatChangedWhileNewItemsWereBeingRendered = undefined\r\n\r\n\t\t// Reset `this.updateLayoutAfterRenderBecauseItemHeightChanged`.\r\n\t\tconst itemHeightHasChanged = this.updateLayoutAfterRenderBecauseItemHeightChanged\r\n\t\tthis.updateLayoutAfterRenderBecauseItemHeightChanged = undefined\r\n\r\n\t\treturn {\r\n\t\t\tnonMeasuredItemsHaveBeenRendered,\r\n\t\t\titemHeightHasChanged,\r\n\t\t\twidthHasChanged\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;AAAA,OAAOA,GAAP,IAAcC,IAAd,EAAoBC,WAApB,EAAiCC,OAAjC,QAAgD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C;;;IACA,KAAKA,yBAAL,GAAiC/C,SAAjC,CA1BgC,CA4BhC;;IACA,KAAKgD,sBAAL,GAA8BhD,SAA9B,CA7BgC,CA+BhC;;IACA,KAAK8B,oDAAL,GAA4D9B,SAA5D,CAhCgC,CAkChC;;IACA,KAAKmC,mDAAL,GAA2DnC,SAA3D,CAnCgC,CAqChC;;IACA,IAAMV,oBAAoB,GAAG,KAAKG,+CAAlC;IACA,KAAKA,+CAAL,GAAuDO,SAAvD;IAEA,OAAO;MACNX,gCAAgC,EAAhCA,gCADM;MAENC,oBAAoB,EAApBA,oBAFM;MAGNC,eAAe,EAAfA;IAHM,CAAP;EAKA;AACD"}
1
+ {"version":3,"file":"VirtualScroller.onRender.js","names":["log","warn","reportError","isDebug","getStateSnapshot","shallowEqual","LAYOUT_REASON","setTbodyPadding","_onRender","newState","prevState","waitingForRender","onStateChange","tbody","getItemsContainerElement","beforeItemsHeight","afterItemsHeight","mostRecentSetStateValue","resetStateUpdateFlags","call","nonMeasuredItemsHaveBeenRendered","itemHeightHasChanged","widthHasChanged","layoutUpdateReason","ITEM_HEIGHT_CHANGED","NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED","VIEWPORT_WIDTH_CHANGED","itemHeights","reset","verticalSpacing","undefined","previousItems","items","newItems","itemsDiff","getItemsDiff","prependedItemsCount","onPrepend","onNewItemsRendered","ITEMS_CHANGED","stateUpdate","firstShownItemIndex","lastShownItemIndex","verticalSpacingStateUpdate","measureItemHeightsAndSpacing","cleanedUpBeforeResize","beforeResize","cleanUpBeforeResizeItemHeights","scrollBy","scroll","scrollByY","_isActive","_stoppedStateUpdate","updateStateRightAfterRender","reason","updateState","newLayout","appendedItemsCount","getState","itemStates","itemHeightsThatChangedWhileNewItemsWereBeingRendered","Object","keys","i","Number","itemStatesThatChangedWhileNewItemsWereBeingRendered","previouslyCalculatedLayout","listHeightMeasurement","hasSnapshot","listBottomOffsetChange","getListBottomOffsetChange","shownItemsHeight","_useTimeoutInRenderLoop","cancelLayoutTimer","scheduleLayoutTimer","onUpdateShownItemIndexes","Boolean","firstNonMeasuredItemIndex","newItemsWillBeRendered","updateLayoutAfterRenderBecauseItemHeightChanged"],"sources":["../source/VirtualScroller.onRender.js"],"sourcesContent":["import log, { warn, reportError, isDebug } from './utility/debug.js'\r\nimport getStateSnapshot from './utility/getStateSnapshot.js'\r\nimport shallowEqual from './utility/shallowEqual.js'\r\nimport { LAYOUT_REASON } from './Layout.js'\r\nimport { setTbodyPadding } from './DOM/tbody.js'\r\n\r\nexport default function() {\r\n\t/**\r\n\t * Should be called right after updates to `state` have been rendered.\r\n\t * @param {object} newState\r\n\t * @param {object} [prevState]\r\n\t */\r\n\tthis._onRender = (newState, prevState) => {\r\n\t\tthis.waitingForRender = false\r\n\r\n\t\tlog('~ Rendered ~')\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('State', getStateSnapshot(newState))\r\n\t\t}\r\n\r\n\t\tif (this.onStateChange) {\r\n\t\t\tif (!shallowEqual(newState, prevState)) {\r\n\t\t\t\tthis.onStateChange(newState)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Update `<tbody/>` `padding`.\r\n\t\t// (`<tbody/>` is different in a way that it can't have `margin`, only `padding`).\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1\r\n\t\tif (this.tbody) {\r\n\t\t\tsetTbodyPadding(\r\n\t\t\t\tthis.getItemsContainerElement(),\r\n\t\t\t\tnewState.beforeItemsHeight,\r\n\t\t\t\tnewState.afterItemsHeight\r\n\t\t\t)\r\n\t\t}\r\n\r\n\t\t// `this.mostRecentlySetState` checks that state management behavior is correct:\r\n\t\t// that in situations when there're multiple new states waiting to be set,\r\n\t\t// only the latest one gets applied.\r\n\t\t// It keeps the code simpler and prevents possible race condition bugs.\r\n\t\t// For example, `VirtualScroller` keeps track of its latest requested\r\n\t\t// state update in different instance variable flags which assume that\r\n\t\t// only that latest requested state update gets actually applied.\r\n\t\t//\r\n\t\t// This check should also be performed for the initial render in order to\r\n\t\t// guarantee that no potentially incorrect state update goes unnoticed.\r\n\t\t// Incorrect state updates could happen when `VirtualScroller` state\r\n\t\t// is managed externally by passing `getState()`/`updateState()` options.\r\n\t\t//\r\n\t\t// Perform the check only when `this.mostRecentSetStateValue` is defined.\r\n\t\t// `this.mostRecentSetStateValue` is normally gonna be `undefined` at the initial render\r\n\t\t// because the initial state is not set by calling `this.updateState()`.\r\n\t\t// At the same time, it is possible that the initial render is delayed\r\n\t\t// for whatever reason, and `this.updateState()` gets called before the initial render,\r\n\t\t// so `this.mostRecentSetStateValue` could also be defined at the initial render,\r\n\t\t// in which case the check should be performed.\r\n\t\t//\r\n\t\tif (this.mostRecentSetStateValue) {\r\n\t\t\t// \"Shallow equality\" is used here instead of \"strict equality\"\r\n\t\t\t// because a developer might choose to supply an `updateState()` function\r\n\t\t\t// rather than a `setState()` function, in which case the `updateState()` function\r\n\t\t\t// would construct its own state object.\r\n\t\t\tif (!shallowEqual(newState, this.mostRecentSetStateValue)) {\r\n\t\t\t\twarn('The most recent state that was set', getStateSnapshot(this.mostRecentSetStateValue))\r\n\t\t\t\treportError('The state that has been rendered is not the most recent one that was set')\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `this.resetStateUpdateFlags()` must be called before calling\r\n\t\t// `this.measureItemHeightsAndSpacing()`.\r\n\t\tconst {\r\n\t\t\tnonMeasuredItemsHaveBeenRendered,\r\n\t\t\titemHeightHasChanged,\r\n\t\t\twidthHasChanged\r\n\t\t} = resetStateUpdateFlags.call(this)\r\n\r\n\t\tlet layoutUpdateReason\r\n\r\n\t\tif (itemHeightHasChanged) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.ITEM_HEIGHT_CHANGED\r\n\t\t}\r\n\r\n\t\tif (!prevState) {\r\n\t\t\tif (!layoutUpdateReason) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// If the `VirtualScroller`, while calculating layout parameters, encounters\r\n\t\t// a not-shown item with a non-measured height, it calls `updateState()` just to\r\n\t\t// render that item first, and then, after the list has been re-rendered, it measures\r\n\t\t// the item's height and then proceeds with calculating the correct layout parameters.\r\n\t\tif (nonMeasuredItemsHaveBeenRendered) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED\r\n\t\t}\r\n\r\n\t\t// If scrollable container width has changed, and it has been re-rendered,\r\n\t\t// then it's time to measure the new item heights and then perform a re-layout\r\n\t\t// with the correctly calculated layout parameters.\r\n\t\t//\r\n\t\t// A re-layout is required because the layout parameters calculated on resize\r\n\t\t// are approximate ones, and the exact item heights aren't known at that point.\r\n\t\t// So on resize, it calls `updateState()` 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\tif (widthHasChanged) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.VIEWPORT_WIDTH_CHANGED\r\n\r\n\t\t\t// Reset measured item heights on viewport width change.\r\n\t\t\tthis.itemHeights.reset()\r\n\r\n\t\t\t// Reset `verticalSpacing` (will be re-measured).\r\n\t\t\tthis.verticalSpacing = undefined\r\n\t\t}\r\n\r\n\t\tif (prevState) {\r\n\t\t\tconst { items: previousItems } = prevState\r\n\t\t\tconst { items: newItems } = newState\r\n\t\t\t// Even if `this.newItemsWillBeRendered` flag is `true`,\r\n\t\t\t// `newItems` could still be equal to `previousItems`.\r\n\t\t\t// For example, when `updateState()` calls don't update `state` immediately\r\n\t\t\t// and a developer first calls `setItems(newItems)` and then calls `setItems(oldItems)`:\r\n\t\t\t// in that case, `this.newItemsWillBeRendered` flag will be `true` but the actual `items`\r\n\t\t\t// in state wouldn't have changed due to the first `updateState()` call being overwritten\r\n\t\t\t// by the second `updateState()` call (that's called \"batching state updates\" in React).\r\n\t\t\tif (newItems !== previousItems) {\r\n\t\t\t\tconst itemsDiff = this.getItemsDiff(previousItems, newItems)\r\n\t\t\t\tif (itemsDiff) {\r\n\t\t\t\t\t// The call to `.onPrepend()` must precede the call to `.measureItemHeights()`\r\n\t\t\t\t\t// which is called in `.onRender()`.\r\n\t\t\t\t\t// `this.itemHeights.onPrepend()` updates `firstMeasuredItemIndex`\r\n\t\t\t\t\t// and `lastMeasuredItemIndex` of `this.itemHeights`.\r\n\t\t\t\t\tconst { prependedItemsCount } = itemsDiff\r\n\t\t\t\t\tthis.itemHeights.onPrepend(prependedItemsCount)\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.itemHeights.reset()\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (!widthHasChanged) {\r\n\t\t\t\t\t// The call to `this.onNewItemsRendered()` must precede the call to\r\n\t\t\t\t\t// `.measureItemHeights()` which is called in `.onRender()` because\r\n\t\t\t\t\t// `this.onNewItemsRendered()` updates `firstMeasuredItemIndex` and\r\n\t\t\t\t\t// `lastMeasuredItemIndex` of `this.itemHeights` in case of a prepend.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// If after prepending items the scroll position\r\n\t\t\t\t\t// should be \"restored\" so that there's no \"jump\" of content\r\n\t\t\t\t\t// then it means that all previous items have just been rendered\r\n\t\t\t\t\t// in a single pass, and there's no need to update layout again.\r\n\t\t\t\t\t//\r\n\t\t\t\t\tif (onNewItemsRendered.call(this, itemsDiff, newState) !== 'SEAMLESS_PREPEND') {\r\n\t\t\t\t\t\tlayoutUpdateReason = LAYOUT_REASON.ITEMS_CHANGED\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\tlet stateUpdate\r\n\r\n\t\t// Re-measure item heights.\r\n\t\t// Also, measure vertical spacing (if not measured) and fix `<table/>` padding.\r\n\t\t//\r\n\t\t// This block should go after `if (newItems !== previousItems) {}`\r\n\t\t// because `this.itemHeights` can get `.reset()` there, which would\r\n\t\t// discard all the measurements done here, and having currently shown\r\n\t\t// item height measurements is required.\r\n\t\t//\r\n\t\tif (\r\n\t\t\t(prevState && (\r\n\t\t\t\tnewState.firstShownItemIndex !== prevState.firstShownItemIndex ||\r\n\t\t\t\tnewState.lastShownItemIndex !== prevState.lastShownItemIndex ||\r\n\t\t\t\tnewState.items !== prevState.items\r\n\t\t\t)) ||\r\n\t\t\twidthHasChanged\r\n\t\t) {\r\n\t\t\tconst verticalSpacingStateUpdate = this.measureItemHeightsAndSpacing()\r\n\t\t\tif (verticalSpacingStateUpdate) {\r\n\t\t\t\tstateUpdate = {\r\n\t\t\t\t\t...stateUpdate,\r\n\t\t\t\t\t...verticalSpacingStateUpdate\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Clean up \"before resize\" item heights and adjust the scroll position accordingly.\r\n\t\t// Calling `this.beforeResize.cleanUpBeforeResizeItemHeights()` might trigger\r\n\t\t// a `this.updateState()` call but that wouldn't matter because `beforeResize`\r\n\t\t// properties have already been modified directly in `state` (a hacky technique)\r\n\t\tconst cleanedUpBeforeResize = this.beforeResize.cleanUpBeforeResizeItemHeights()\r\n\t\tif (cleanedUpBeforeResize !== undefined) {\r\n\t\t\tconst { scrollBy, beforeResize } = cleanedUpBeforeResize\r\n\t\t\tlog('Correct scroll position by', scrollBy)\r\n\t\t\tthis.scroll.scrollByY(scrollBy)\r\n\t\t\tstateUpdate = {\r\n\t\t\t\t...stateUpdate,\r\n\t\t\t\tbeforeResize\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!this._isActive) {\r\n\t\t\tthis._stoppedStateUpdate = stateUpdate\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (layoutUpdateReason) {\r\n\t\t\tupdateStateRightAfterRender.call(this, {\r\n\t\t\t\tstateUpdate,\r\n\t\t\t\treason: layoutUpdateReason\r\n\t\t\t})\r\n\t\t} else if (stateUpdate) {\r\n\t\t\tthis.updateState(stateUpdate)\r\n\t\t} else {\r\n\t\t\tlog('~ Finished Layout ~')\r\n\t\t}\r\n\t}\r\n\r\n\t// After a new set of items has been rendered:\r\n\t//\r\n\t// * Restores scroll position when using `preserveScrollPositionOnPrependItems`\r\n\t// and items have been prepended.\r\n\t//\r\n\t// * Applies any \"pending\" `itemHeights` updates — those ones that happened\r\n\t// while an asynchronous `updateState()` call in `setItems()` was pending.\r\n\t//\r\n\t// * Either creates or resets the snapshot of the current layout.\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\t// The \"previously calculated layout\" feature is not currently used.\r\n\t//\r\n\tfunction onNewItemsRendered(itemsDiff, newLayout) {\r\n\t\t// If it's an \"incremental\" update.\r\n\t\tif (itemsDiff) {\r\n\t\t\tconst {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t} = itemsDiff\r\n\r\n\t\t\tconst {\r\n\t\t\t\titemHeights,\r\n\t\t\t\titemStates\r\n\t\t\t} = this.getState()\r\n\r\n\t\t\t// See if any items' heights changed while new items were being rendered.\r\n\t\t\tif (this.itemHeightsThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tfor (const i of Object.keys(this.itemHeightsThatChangedWhileNewItemsWereBeingRendered)) {\r\n\t\t\t\t\titemHeights[prependedItemsCount + Number(i)] = this.itemHeightsThatChangedWhileNewItemsWereBeingRendered[i]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// See if any items' states changed while new items were being rendered.\r\n\t\t\tif (this.itemStatesThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tfor (const i of Object.keys(this.itemStatesThatChangedWhileNewItemsWereBeingRendered)) {\r\n\t\t\t\t\titemStates[prependedItemsCount + Number(i)] = this.itemStatesThatChangedWhileNewItemsWereBeingRendered[i]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (prependedItemsCount === 0) {\r\n\t\t\t\t// Adjust `this.previouslyCalculatedLayout`.\r\n\t\t\t\tif (this.previouslyCalculatedLayout) {\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout.firstShownItemIndex === newLayout.firstShownItemIndex &&\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout.lastShownItemIndex === newLayout.lastShownItemIndex\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\t// `this.previouslyCalculatedLayout` stays the same.\r\n\t\t\t\t\t\t// `firstShownItemIndex` / `lastShownItemIndex` didn't get changed in `setItems()`,\r\n\t\t\t\t\t\t// so `beforeItemsHeight` and `shownItemsHeight` also stayed the same.\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\twarn('Unexpected (non-matching) \"firstShownItemIndex\" or \"lastShownItemIndex\" encountered in \"onRender()\" after appending items')\r\n\t\t\t\t\t\twarn('Previously calculated layout', this.previouslyCalculatedLayout)\r\n\t\t\t\t\t\twarn('New layout', newLayout)\r\n\t\t\t\t\t\tthis.previouslyCalculatedLayout = undefined\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\treturn 'SEAMLESS_APPEND'\r\n\t\t\t} else {\r\n\t\t\t\tif (this.listHeightMeasurement.hasSnapshot()) {\r\n\t\t\t\t\tif (newLayout.firstShownItemIndex === 0) {\r\n\t\t\t\t\t\t// Restore (adjust) scroll position.\r\n\t\t\t\t\t\tlog('~ Restore Scroll Position ~')\r\n\t\t\t\t\t\tconst listBottomOffsetChange = this.listHeightMeasurement.getListBottomOffsetChange({\r\n\t\t\t\t\t\t\tbeforeItemsHeight: newLayout.beforeItemsHeight\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t\tthis.listHeightMeasurement.reset()\r\n\t\t\t\t\t\tif (listBottomOffsetChange) {\r\n\t\t\t\t\t\t\tlog('Scroll down by', listBottomOffsetChange)\r\n\t\t\t\t\t\t\tthis.scroll.scrollByY(listBottomOffsetChange)\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\tlog('Scroll position hasn\\'t changed')\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t// Create new `this.previouslyCalculatedLayout`.\r\n\t\t\t\t\t\tif (this.previouslyCalculatedLayout) {\r\n\t\t\t\t\t\t\tif (\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout.firstShownItemIndex === 0 &&\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout.lastShownItemIndex === newLayout.lastShownItemIndex - prependedItemsCount\r\n\t\t\t\t\t\t\t) {\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout = {\r\n\t\t\t\t\t\t\t\t\tbeforeItemsHeight: 0,\r\n\t\t\t\t\t\t\t\t\tshownItemsHeight: this.previouslyCalculatedLayout.shownItemsHeight + listBottomOffsetChange,\r\n\t\t\t\t\t\t\t\t\tfirstShownItemIndex: 0,\r\n\t\t\t\t\t\t\t\t\tlastShownItemIndex: newLayout.lastShownItemIndex\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\twarn('Unexpected (non-matching) \"firstShownItemIndex\" or \"lastShownItemIndex\" encountered in \"onRender()\" after prepending items')\r\n\t\t\t\t\t\t\t\twarn('Previously calculated layout', this.previouslyCalculatedLayout)\r\n\t\t\t\t\t\t\t\twarn('New layout', newLayout)\r\n\t\t\t\t\t\t\t\tthis.previouslyCalculatedLayout = undefined\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn 'SEAMLESS_PREPEND'\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\twarn(`Unexpected \"firstShownItemIndex\" ${newLayout.firstShownItemIndex} encountered in \"onRender()\" after prepending items. Expected 0.`)\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\t// Reset `this.previouslyCalculatedLayout` in any case other than\r\n\t\t// SEAMLESS_PREPEND or SEAMLESS_APPEND.\r\n\t\tthis.previouslyCalculatedLayout = undefined\r\n\t}\r\n\r\n\tfunction updateStateRightAfterRender({\r\n\t\treason,\r\n\t\tstateUpdate\r\n\t}) {\r\n\t\t// In React, `setTimeout()` is used to prevent a React error:\r\n\t\t// \"Maximum update depth exceeded.\r\n\t\t// This can happen when a component repeatedly calls\r\n\t\t// `.updateState()` inside `componentWillUpdate()` or `componentDidUpdate()`.\r\n\t\t// React limits the number of nested updates to prevent infinite loops.\"\r\n\t\tif (this._useTimeoutInRenderLoop) {\r\n\t\t\t// Cancel a previously scheduled re-layout.\r\n\t\t\tstateUpdate = this.cancelLayoutTimer({ stateUpdate })\r\n\t\t\t// Schedule a new re-layout.\r\n\t\t\tthis.scheduleLayoutTimer({\r\n\t\t\t\treason,\r\n\t\t\t\tstateUpdate\r\n\t\t\t})\r\n\t\t} else {\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}\r\n\t}\r\n\r\n\tfunction resetStateUpdateFlags() {\r\n\t\t// Read and reset `this.widthHasChanged` flag.\r\n\t\t//\r\n\t\t// If `this.widthHasChanged` flag was reset after calling\r\n\t\t// `this.measureWidthHeightsAndSpacingAndUpdateTablePadding()`\r\n\t\t// then there would be a bug because\r\n\t\t// `this.measureWidthHeightsAndSpacingAndUpdateTablePadding()`\r\n\t\t// calls `this.updateState({ verticalSpacing })` which calls\r\n\t\t// `this.onRender()` immediately, so `this.widthHasChanged`\r\n\t\t// flag wouldn't be reset by that time and would trigger things\r\n\t\t// like `this.itemHeights.reset()` a second time.\r\n\t\t//\r\n\t\t// So, instead read the value of `this.widthHasChanged` flag\r\n\t\t// and reset it right away to prevent any such potential bugs.\r\n\t\t//\r\n\t\tconst widthHasChanged = Boolean(this.widthHasChanged)\r\n\t\t//\r\n\t\t// Reset `this.widthHasChanged` flag.\r\n\t\tthis.widthHasChanged = undefined\r\n\r\n\t\t// Read `this.firstNonMeasuredItemIndex` flag.\r\n\t\tconst nonMeasuredItemsHaveBeenRendered = this.firstNonMeasuredItemIndex !== undefined\r\n\t\tif (nonMeasuredItemsHaveBeenRendered) {\r\n\t\t\tlog('Non-measured item index', this.firstNonMeasuredItemIndex)\r\n\t\t}\r\n\t\t// Reset `this.firstNonMeasuredItemIndex` flag.\r\n\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\r\n\t\t// Reset `this.newItemsWillBeRendered` flag.\r\n\t\tthis.newItemsWillBeRendered = undefined\r\n\r\n\t\t// Reset `this.itemHeightsThatChangedWhileNewItemsWereBeingRendered`.\r\n\t\tthis.itemHeightsThatChangedWhileNewItemsWereBeingRendered = undefined\r\n\r\n\t\t// Reset `this.itemStatesThatChangedWhileNewItemsWereBeingRendered`.\r\n\t\tthis.itemStatesThatChangedWhileNewItemsWereBeingRendered = undefined\r\n\r\n\t\t// Reset `this.updateLayoutAfterRenderBecauseItemHeightChanged`.\r\n\t\tconst itemHeightHasChanged = this.updateLayoutAfterRenderBecauseItemHeightChanged\r\n\t\tthis.updateLayoutAfterRenderBecauseItemHeightChanged = undefined\r\n\r\n\t\treturn {\r\n\t\t\tnonMeasuredItemsHaveBeenRendered,\r\n\t\t\titemHeightHasChanged,\r\n\t\t\twidthHasChanged\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;AAAA,OAAOA,GAAP,IAAcC,IAAd,EAAoBC,WAApB,EAAiCC,OAAjC,QAAgD,oBAAhD;AACA,OAAOC,gBAAP,MAA6B,+BAA7B;AACA,OAAOC,YAAP,MAAyB,2BAAzB;AACA,SAASC,aAAT,QAA8B,aAA9B;AACA,SAASC,eAAT,QAAgC,gBAAhC;AAEA,eAAe,YAAW;EAAA;;EACzB;AACD;AACA;AACA;AACA;EACC,KAAKC,SAAL,GAAiB,UAACC,QAAD,EAAWC,SAAX,EAAyB;IACzC,KAAI,CAACC,gBAAL,GAAwB,KAAxB;IAEAX,GAAG,CAAC,cAAD,CAAH;;IACA,IAAIG,OAAO,EAAX,EAAe;MACdH,GAAG,CAAC,OAAD,EAAUI,gBAAgB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CAAP;EAKA;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virtual-scroller",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "A component for efficiently rendering large lists of variable height items",
5
5
  "main": "index.cjs",
6
6
  "module": "index.js",
@@ -77,7 +77,7 @@ export default function() {
77
77
 
78
78
  let layoutUpdateReason
79
79
 
80
- if (this.updateLayoutAfterRenderBecauseItemHeightChanged) {
80
+ if (itemHeightHasChanged) {
81
81
  layoutUpdateReason = LAYOUT_REASON.ITEM_HEIGHT_CHANGED
82
82
  }
83
83