virtual-scroller 1.7.6 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/README.md +139 -33
  3. package/babel.config.js +25 -0
  4. package/babel.js +5 -0
  5. package/bundle/index-bypass.html +1 -1
  6. package/bundle/index-dom.html +1 -1
  7. package/bundle/index-grid.html +1 -2
  8. package/bundle/index-scrollableContainer.html +1 -1
  9. package/bundle/index-tbody-scrollableContainer.html +2 -0
  10. package/bundle/index-tbody.html +2 -0
  11. package/bundle/virtual-scroller-dom.js +1 -1
  12. package/bundle/virtual-scroller-dom.js.map +1 -1
  13. package/bundle/virtual-scroller-react.js +1 -1
  14. package/bundle/virtual-scroller-react.js.map +1 -1
  15. package/bundle/virtual-scroller.js +1 -1
  16. package/bundle/virtual-scroller.js.map +1 -1
  17. package/commonjs/BeforeResize.js +319 -0
  18. package/commonjs/BeforeResize.js.map +1 -0
  19. package/commonjs/DOM/Engine.js +46 -0
  20. package/commonjs/DOM/Engine.js.map +1 -0
  21. package/commonjs/DOM/ItemsContainer.js +78 -0
  22. package/commonjs/DOM/ItemsContainer.js.map +1 -0
  23. package/commonjs/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +56 -35
  24. package/commonjs/DOM/ListTopOffsetWatcher.js.map +1 -0
  25. package/commonjs/DOM/ScrollableContainer.js +56 -81
  26. package/commonjs/DOM/ScrollableContainer.js.map +1 -1
  27. package/commonjs/DOM/VirtualScroller.js +20 -15
  28. package/commonjs/DOM/VirtualScroller.js.map +1 -1
  29. package/commonjs/DOM/tbody.js +2 -2
  30. package/commonjs/ItemHeights.js +13 -20
  31. package/commonjs/ItemHeights.js.map +1 -1
  32. package/commonjs/Layout.js +588 -215
  33. package/commonjs/Layout.js.map +1 -1
  34. package/commonjs/Layout.test.js +191 -0
  35. package/commonjs/Layout.test.js.map +1 -0
  36. package/commonjs/ListHeightChangeWatcher.js +126 -0
  37. package/commonjs/ListHeightChangeWatcher.js.map +1 -0
  38. package/commonjs/Resize.js +22 -21
  39. package/commonjs/Resize.js.map +1 -1
  40. package/commonjs/Scroll.js +148 -88
  41. package/commonjs/Scroll.js.map +1 -1
  42. package/commonjs/VirtualScroller.js +1269 -390
  43. package/commonjs/VirtualScroller.js.map +1 -1
  44. package/commonjs/getItemCoordinates.js.map +1 -1
  45. package/commonjs/getItemsDiff.js.map +1 -1
  46. package/commonjs/getVerticalSpacing.js +8 -8
  47. package/commonjs/getVerticalSpacing.js.map +1 -1
  48. package/commonjs/react/VirtualScroller.js +31 -37
  49. package/commonjs/react/VirtualScroller.js.map +1 -1
  50. package/commonjs/utility/debounce.js +26 -4
  51. package/commonjs/utility/debounce.js.map +1 -1
  52. package/commonjs/utility/debug.js +51 -12
  53. package/commonjs/utility/debug.js.map +1 -1
  54. package/commonjs/utility/getStateSnapshot.js +50 -0
  55. package/commonjs/utility/getStateSnapshot.js.map +1 -0
  56. package/commonjs/utility/px.js +1 -1
  57. package/commonjs/utility/px.js.map +1 -1
  58. package/commonjs/utility/px.test.js +14 -0
  59. package/commonjs/utility/px.test.js.map +1 -0
  60. package/commonjs/utility/shallowEqual.js +1 -1
  61. package/commonjs/utility/shallowEqual.js.map +1 -1
  62. package/commonjs/utility/throttle.js.map +1 -1
  63. package/dom/index.d.ts +23 -0
  64. package/index.d.ts +84 -0
  65. package/modules/BeforeResize.js +310 -0
  66. package/modules/BeforeResize.js.map +1 -0
  67. package/modules/DOM/Engine.js +27 -0
  68. package/modules/DOM/Engine.js.map +1 -0
  69. package/modules/DOM/ItemsContainer.js +71 -0
  70. package/modules/DOM/ItemsContainer.js.map +1 -0
  71. package/modules/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +57 -35
  72. package/modules/DOM/ListTopOffsetWatcher.js.map +1 -0
  73. package/modules/DOM/ScrollableContainer.js +55 -80
  74. package/modules/DOM/ScrollableContainer.js.map +1 -1
  75. package/modules/DOM/VirtualScroller.js +15 -14
  76. package/modules/DOM/VirtualScroller.js.map +1 -1
  77. package/modules/ItemHeights.js +8 -19
  78. package/modules/ItemHeights.js.map +1 -1
  79. package/modules/Layout.js +582 -213
  80. package/modules/Layout.js.map +1 -1
  81. package/modules/Layout.test.js +185 -0
  82. package/modules/Layout.test.js.map +1 -0
  83. package/modules/ListHeightChangeWatcher.js +119 -0
  84. package/modules/ListHeightChangeWatcher.js.map +1 -0
  85. package/modules/Resize.js +21 -20
  86. package/modules/Resize.js.map +1 -1
  87. package/modules/Scroll.js +148 -87
  88. package/modules/Scroll.js.map +1 -1
  89. package/modules/VirtualScroller.js +1263 -390
  90. package/modules/VirtualScroller.js.map +1 -1
  91. package/modules/getItemCoordinates.js.map +1 -1
  92. package/modules/getItemsDiff.js.map +1 -1
  93. package/modules/getVerticalSpacing.js +8 -8
  94. package/modules/getVerticalSpacing.js.map +1 -1
  95. package/modules/react/VirtualScroller.js +31 -37
  96. package/modules/react/VirtualScroller.js.map +1 -1
  97. package/modules/utility/debounce.js +26 -4
  98. package/modules/utility/debounce.js.map +1 -1
  99. package/modules/utility/debug.js +47 -10
  100. package/modules/utility/debug.js.map +1 -1
  101. package/modules/utility/getStateSnapshot.js +43 -0
  102. package/modules/utility/getStateSnapshot.js.map +1 -0
  103. package/modules/utility/px.js +1 -1
  104. package/modules/utility/px.js.map +1 -1
  105. package/modules/utility/px.test.js +9 -0
  106. package/modules/utility/px.test.js.map +1 -0
  107. package/modules/utility/shallowEqual.js +1 -1
  108. package/modules/utility/shallowEqual.js.map +1 -1
  109. package/modules/utility/throttle.js.map +1 -1
  110. package/package.json +24 -22
  111. package/react/index.d.ts +27 -0
  112. package/source/BeforeResize.js +317 -0
  113. package/source/DOM/Engine.js +32 -0
  114. package/source/DOM/ItemsContainer.js +48 -0
  115. package/source/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +48 -22
  116. package/source/DOM/ScrollableContainer.js +39 -56
  117. package/source/DOM/VirtualScroller.js +6 -7
  118. package/source/ItemHeights.js +10 -15
  119. package/source/Layout.js +626 -252
  120. package/source/Layout.test.js +171 -0
  121. package/source/ListHeightChangeWatcher.js +94 -0
  122. package/source/Resize.js +23 -15
  123. package/source/Scroll.js +139 -78
  124. package/source/VirtualScroller.js +1240 -286
  125. package/source/getVerticalSpacing.js +7 -7
  126. package/source/react/VirtualScroller.js +2 -18
  127. package/source/utility/debounce.js +20 -3
  128. package/source/utility/debug.js +34 -3
  129. package/source/utility/getStateSnapshot.js +36 -0
  130. package/source/utility/px.js +1 -1
  131. package/source/utility/px.test.js +9 -0
  132. package/website/index-bypass.html +195 -0
  133. package/website/index-grid.html +0 -1
  134. package/website/index-scrollableContainer.html +208 -0
  135. package/website/index-tbody-scrollableContainer.html +68 -0
  136. package/website/index-tbody.html +55 -0
  137. package/commonjs/DOM/RenderingEngine.js +0 -33
  138. package/commonjs/DOM/RenderingEngine.js.map +0 -1
  139. package/commonjs/DOM/Screen.js +0 -87
  140. package/commonjs/DOM/Screen.js.map +0 -1
  141. package/commonjs/DOM/WaitForStylesToLoad.js.map +0 -1
  142. package/commonjs/RestoreScroll.js +0 -118
  143. package/commonjs/RestoreScroll.js.map +0 -1
  144. package/modules/DOM/RenderingEngine.js +0 -19
  145. package/modules/DOM/RenderingEngine.js.map +0 -1
  146. package/modules/DOM/Screen.js +0 -80
  147. package/modules/DOM/Screen.js.map +0 -1
  148. package/modules/DOM/WaitForStylesToLoad.js.map +0 -1
  149. package/modules/RestoreScroll.js +0 -111
  150. package/modules/RestoreScroll.js.map +0 -1
  151. package/source/DOM/RenderingEngine.js +0 -22
  152. package/source/DOM/Screen.js +0 -51
  153. package/source/RestoreScroll.js +0 -86
@@ -1 +1 @@
1
- {"version":3,"sources":["../source/VirtualScroller.js"],"names":["setTimeout","clearTimeout","supportsTbody","BROWSER_NOT_SUPPORTED_ERROR","addTbodyStyles","setTbodyPadding","DOMRenderingEngine","WaitForStylesToLoad","Layout","LAYOUT_REASON","Resize","Scroll","RestoreScroll","ItemHeights","getItemsDiff","getVerticalSpacing","log","warn","isDebug","reportError","shallowEqual","VirtualScroller","getContainerElement","items","options","listTopOffset","scrollableContainer","getTopOffset","waitForStylesToLoad","onGotListTopOffset","newState","prevState","getState","onStateChange","isRendered","newItemsPending","undefined","layoutResetPending","redoLayoutReason","previousItems","newItems","layoutNeedsReCalculating","itemsDiff","prependedItemsCount","appendedItemsCount","itemHeights","onPrepend","restoreScroll","shouldRestoreScrollAfterRender","scrollByY","getScrollDifference","scroll","reset","initialize","ITEMS_CHANGED","firstShownItemIndex","lastShownItemIndex","onRenderedNewLayout","redoLayoutRightAfterRender","reason","bypass","visibleAreaIncludingMargins","getVisibleAreaBoundsIncludingMargins","latestLayoutVisibleAreaIncludingMargins","listTopOffsetInsideScrollableContainer","getListTopOffsetInsideScrollableContainer","layout","getShownItemIndexes","listHeight","screen","getElementHeight","itemsCount","getItemsCount","redoLayoutAfterMeasuringItemHeights","getAnchorItemIndex","validateWillBeHiddenItemHeightsAreAccurate","updateShownItemIndexes","beforeItemsHeight","getBeforeItemsHeight","afterItemsHeight","getAfterItemsHeight","_getColumnsCount","getColumnsCount","getAverage","slice","itemStates","ITEM_HEIGHT_NOT_MEASURED","onBeforeShowItems","setState","onLayout","layoutTimer","onUpdateShownItemIndexes","MANUAL","updateLayout","customState","preserveScrollPositionAtBottomOnMount","preserveScrollPositionOfTheBottomOfTheListOnMount","initialScrollPosition","onScrollPositionChange","measureItemsBatchSize","getScrollableContainer","getItemId","tbody","_useTimeoutInRenderLoop","estimatedItemHeight","onItemInitialRender","onItemFirstRender","state","renderingEngine","createScreen","createScrollableContainer","name","Error","isItemEqual","a","b","initialItems","item","i","indexOf","length","willUpdateState","didUpdateState","clearElement","height","getItemHeight","getAverageItemHeight","resize","resetStateAndLayout","RESIZE","getInitialLayoutState","isImmediateLayoutScheduled","hasNonRenderedItemsAtTheTop","hasNonRenderedItemsAtTheBottom","getLatestLayoutVisibleAreaIncludingMargins","getInitialState","Array","getInitialLayoutValues","visibleAreaHeightIncludingMargins","getMargin","getHeight","columnsCount","verticalSpacing","renderAheadMarginRatio","listen","MOUNT","measureVerticalSpacing","measureItemHeights","visibleArea","getVisibleAreaBounds","top","bottom","stop","container","remeasureItemHeight","itemState","JSON","stringify","previousHeight","newHeight","ITEM_HEIGHT_CHANGED","isValid","previouslyMeasuredItemHeight","actualItemHeight","setItems","concat","updateLayoutForItemsDiff","preserveScrollPositionOnPrependItems","preserveScrollPosition","captureScroll","showItemsFromTheStart"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,YAArB,QAAyC,iCAAzC;AAEA,SACCC,aADD,EAECC,2BAFD,EAGCC,cAHD,EAICC,eAJD,QAKO,aALP;AAOA,OAAOC,kBAAP,MAA+B,uBAA/B;AACA,OAAOC,mBAAP,MAAgC,2BAAhC;AAEA,OAAOC,MAAP,IAAiBC,aAAjB,QAAsC,UAAtC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,aAAP,MAAyB,gBAAzB;AACA,OAAOC,kBAAP,MAA+B,sBAA/B,C,CACA;;AAEA,OAAOC,GAAP,IAAcC,IAAd,EAAoBC,OAApB,EAA6BC,WAA7B,QAAgD,iBAAhD;AACA,OAAOC,YAAP,MAAyB,wBAAzB;;IAEqBC,e;;;AACpB;;;;;;AAMA,2BACCC,mBADD,EAECC,KAFD,EAIE;AAAA;;AAAA,QADDC,OACC,uEADS,EACT;;AAAA;;AAAA,uEAyc0C,YAAM;AACjD,UAAMC,aAAa,GAAG,KAAI,CAACC,mBAAL,CAAyBC,YAAzB,CAAsC,KAAI,CAACL,mBAAL,EAAtC,CAAtB;;AACA,MAAA,KAAI,CAACM,mBAAL,CAAyBC,kBAAzB,CAA4CJ,aAA5C;;AACA,aAAOA,aAAP;A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HR,EAICW,MAAM,CAACV,kBAJR,EA7EgC,CAmFhC;;AACA,WAAKrB,eAAL,GAAuBK,QAAvB,CApFgC,CAqFhC;;AACA,WAAKgD,QAAL,mBAEItB,MAFJ;AAGC3C,QAAAA,KAAK,EAAEiB,QAHR;AAIC6C,QAAAA,UAAU,EAAVA,UAJD;AAKCxC,QAAAA,WAAW,EAAXA;AALD;AAOA;;;iCAEYN,a,EAAeC,Q,EAAU;AACrC,aAAO1B,aAAY,CAACyB,aAAD,EAAgBC,QAAhB,EAA0B,KAAKyE,WAA/B,CAAnB;AACA;;;;;;SAp9BmB5F,e","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 {\r\n\tsupportsTbody,\r\n\tBROWSER_NOT_SUPPORTED_ERROR,\r\n\taddTbodyStyles,\r\n\tsetTbodyPadding\r\n} from './DOM/tbody'\r\n\r\nimport DOMRenderingEngine from './DOM/RenderingEngine'\r\nimport WaitForStylesToLoad from './DOM/WaitForStylesToLoad'\r\n\r\nimport Layout, { LAYOUT_REASON } from './Layout'\r\nimport Resize from './Resize'\r\nimport Scroll from './Scroll'\r\nimport RestoreScroll from './RestoreScroll'\r\nimport ItemHeights from './ItemHeights'\r\nimport getItemsDiff from './getItemsDiff'\r\nimport getVerticalSpacing from './getVerticalSpacing'\r\n// import getItemCoordinates from './getItemCoordinates'\r\n\r\nimport log, { warn, isDebug, reportError } from './utility/debug'\r\nimport shallowEqual from './utility/shallowEqual'\r\n\r\nexport default class VirtualScroller {\r\n\t/**\r\n\t * @param {function} getContainerElement — Returns the container DOM `Element`.\r\n\t * @param {any[]} items — The list of items.\r\n\t * @param {Object} [options] — See README.md.\r\n\t * @return {VirtualScroller}\r\n\t */\r\n\tconstructor(\r\n\t\tgetContainerElement,\r\n\t\titems,\r\n\t\toptions = {}\r\n\t) {\r\n\t\tconst {\r\n\t\t\tgetState,\r\n\t\t\tsetState,\r\n\t\t\tonStateChange,\r\n\t\t\tcustomState,\r\n\t\t\t// `preserveScrollPositionAtBottomOnMount` option name is deprecated,\r\n\t\t\t// use `preserveScrollPositionOfTheBottomOfTheListOnMount` option instead.\r\n\t\t\tpreserveScrollPositionAtBottomOnMount,\r\n\t\t\tpreserveScrollPositionOfTheBottomOfTheListOnMount,\r\n\t\t\tinitialScrollPosition,\r\n\t\t\tonScrollPositionChange,\r\n\t\t\tmeasureItemsBatchSize,\r\n\t\t\t// `getScrollableContainer` option is deprecated.\r\n\t\t\t// Use `scrollableContainer` instead.\r\n\t\t\tgetScrollableContainer,\r\n\t\t\tgetColumnsCount,\r\n\t\t\tgetItemId,\r\n\t\t\ttbody,\r\n\t\t\t_useTimeoutInRenderLoop,\r\n\t\t\t// bypassBatchSize\r\n\t\t} = options\r\n\r\n\t\tlet {\r\n\t\t\tbypass,\r\n\t\t\t// margin,\r\n\t\t\testimatedItemHeight,\r\n\t\t\t// getItemState,\r\n\t\t\tonItemInitialRender,\r\n\t\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\t\tonItemFirstRender,\r\n\t\t\tscrollableContainer,\r\n\t\t\tstate,\r\n\t\t\trenderingEngine\r\n\t\t} = options\r\n\r\n\t\tlog('~ Initialize ~')\r\n\r\n\t\t// If `state` is passed then use `items` from `state`\r\n\t\t// instead of the `items` argument.\r\n\t\tif (state) {\r\n\t\t\titems = state.items\r\n\t\t}\r\n\r\n\t\t// `getScrollableContainer` option is deprecated.\r\n\t\t// Use `scrollableContainer` instead.\r\n\t\tif (!scrollableContainer && getScrollableContainer) {\r\n\t\t\tscrollableContainer = getScrollableContainer()\r\n\t\t}\r\n\r\n\t\t// Could support non-DOM rendering engines.\r\n\t\t// For example, React Native, `<canvas/>`, etc.\r\n\t\tif (!renderingEngine) {\r\n\t\t\trenderingEngine = DOMRenderingEngine\r\n\t\t}\r\n\r\n\t\tthis.screen = renderingEngine.createScreen()\r\n\t\tthis.scrollableContainer = renderingEngine.createScrollableContainer(scrollableContainer)\r\n\r\n\t\t// if (margin === undefined) {\r\n\t\t// \t// Renders items which are outside of the screen by this \"margin\".\r\n\t\t// \t// Is the screen height by default: seems to be the optimal value\r\n\t\t// \t// for \"Page Up\" / \"Page Down\" navigation and optimized mouse wheel scrolling.\r\n\t\t// \tmargin = this.scrollableContainer ? this.scrollableContainer.getHeight() : 0\r\n\t\t// }\r\n\r\n\t\t// Work around `<tbody/>` not being able to have `padding`.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1\r\n\t\tif (tbody) {\r\n\t\t\tif (renderingEngine.name !== 'DOM') {\r\n\t\t\t\tthrow new Error('`tbody` option is only supported for DOM rendering engine')\r\n\t\t\t}\r\n\t\t\tlog('~ <tbody/> detected ~')\r\n\t\t\tthis.tbody = true\r\n\t\t\tif (!supportsTbody()) {\r\n\t\t\t\tlog('~ <tbody/> not supported ~')\r\n\t\t\t\treportError(BROWSER_NOT_SUPPORTED_ERROR)\r\n\t\t\t\tbypass = true\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (bypass) {\r\n\t\t\tlog('~ \"bypass\" mode ~')\r\n\t\t}\r\n\r\n\t\t// In `bypass` mode, `VirtualScroller` doesn't wait\r\n\t\t// for the user to scroll down to render all items:\r\n\t\t// instead, it renders all items right away, as if\r\n\t\t// the list is rendered without using `VirtualScroller`.\r\n\t\t// It was added just to measure how much is the\r\n\t\t// performance difference between using a `VirtualScroller`\r\n\t\t// and not using a `VirtualScroller`.\r\n\t\t// It turned out that unmounting large React component trees\r\n\t\t// is a very long process, so `VirtualScroller` does seem to\r\n\t\t// make sense when used in a React application.\r\n\t\tthis.bypass = bypass\r\n\t\t// this.bypassBatchSize = bypassBatchSize || 10\r\n\r\n\t\t// Using `setTimeout()` in render loop is a workaround\r\n\t\t// for avoiding a React error message:\r\n\t\t// \"Maximum update depth exceeded.\r\n\t\t// This can happen when a component repeatedly calls\r\n\t\t// `.setState()` inside `componentWillUpdate()` or `componentDidUpdate()`.\r\n\t\t// React limits the number of nested updates to prevent infinite loops.\"\r\n\t\tthis._useTimeoutInRenderLoop = _useTimeoutInRenderLoop\r\n\r\n\t\tif (getItemId) {\r\n\t\t\tthis.isItemEqual = (a, b) => getItemId(a) === getItemId(b)\r\n\t\t} else {\r\n\t\t\tthis.isItemEqual = (a, b) => a === b\r\n\t\t}\r\n\r\n\t\tthis.initialItems = items\r\n\t\t// this.margin = margin\r\n\r\n\t\tthis.onStateChange = onStateChange\r\n\r\n\t\tthis._getColumnsCount = getColumnsCount\r\n\r\n\t\tif (onItemInitialRender) {\r\n\t\t\tthis.onItemInitialRender = onItemInitialRender\r\n\t\t}\r\n\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\telse if (onItemFirstRender) {\r\n\t\t\tthis.onItemInitialRender = (item) => {\r\n\t\t\t\twarn('`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.')\r\n\t\t\t\tconst { items } = this.getState()\r\n\t\t\t\tconst i = items.indexOf(item)\r\n\t\t\t\t// The `item` could also be non-found due to the inconsistency bug:\r\n\t\t\t\t// The reason is that `i` can be non-consistent with the `items`\r\n\t\t\t\t// passed to `<VirtualScroller/>` in React due to `setState()` not being\r\n\t\t\t\t// instanteneous: when new `items` are passed to `<VirtualScroller/>`,\r\n\t\t\t\t// `VirtualScroller.setState({ items })` is called, and if `onItemFirstRender(i)`\r\n\t\t\t\t// is called after the aforementioned `setState()` is called but before it finishes,\r\n\t\t\t\t// `i` would point to an index in \"previous\" `items` while the application\r\n\t\t\t\t// would assume that `i` points to an index in the \"new\" `items`,\r\n\t\t\t\t// resulting in an incorrect item being assumed by the application\r\n\t\t\t\t// or even in an \"array index out of bounds\" error.\r\n\t\t\t\tif (i >= 0) {\r\n\t\t\t\t\tonItemFirstRender(i)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlog('Items count', items.length)\r\n\t\tif (estimatedItemHeight) {\r\n\t\t\tlog('Estimated item height', estimatedItemHeight)\r\n\t\t}\r\n\r\n\t\tif (setState) {\r\n\t\t\tthis.getState = getState\r\n\t\t\tthis.setState = (state) => {\r\n\t\t\t\tlog('Set state', state)\r\n\t\t\t\tsetState(state, {\r\n\t\t\t\t\twillUpdateState: this.willUpdateState,\r\n\t\t\t\t\tdidUpdateState: this.didUpdateState\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tthis.getState = () => this.state\r\n\t\t\tthis.setState = (state) => {\r\n\t\t\t\tlog('Set state', state)\r\n\t\t\t\tconst prevState = this.getState()\r\n\t\t\t\t// Because this variant of `.setState()` is \"synchronous\" (immediate),\r\n\t\t\t\t// it can be written like `...prevState`, and no state updates would be lost.\r\n\t\t\t\t// But if it was \"asynchronous\" (not immediate), then `...prevState`\r\n\t\t\t\t// wouldn't work in all cases, because it could be stale in cases\r\n\t\t\t\t// when more than a single `setState()` call is made before\r\n\t\t\t\t// the state actually updates, making `prevState` stale.\r\n\t\t\t\tconst newState = {\r\n\t\t\t\t\t...prevState,\r\n\t\t\t\t\t...state\r\n\t\t\t\t}\r\n\t\t\t\tthis.willUpdateState(newState, prevState)\r\n\t\t\t\tthis.state = newState\r\n\t\t\t\tthis.didUpdateState(prevState)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (state) {\r\n\t\t\tlog('Initial state (passed)', state)\r\n\t\t}\r\n\r\n\t\t// Sometimes, when `new VirtualScroller()` instance is created,\r\n\t\t// `getContainerElement()` might not be ready to return the \"container\" DOM Element yet\r\n\t\t// (for example, because it's not rendered yet). That's the reason why it's a getter function.\r\n\t\t// For example, in React `<VirtualScroller/>` component, a `VirtualScroller`\r\n\t\t// instance is created in the React component's `constructor()`, and at that time\r\n\t\t// the container Element is not yet available. The container Element is available\r\n\t\t// in `componentDidMount()`, but `componentDidMount()` is not executed on server,\r\n\t\t// which would mean that React `<VirtualScroller/>` wouldn't render at all\r\n\t\t// on server side, while with the `getContainerElement()` approach, on server side,\r\n\t\t// it still \"renders\" a list with a predefined amount of items in it by default.\r\n\t\t// (`initiallyRenderedItemsCount`, or `1`).\r\n\t\tthis.getContainerElement = getContainerElement\r\n\t\t// Remove any accidental text nodes from container (like whitespace).\r\n\t\t// Also guards against cases when someone accidentally tries\r\n\t\t// using `VirtualScroller` on a non-empty element.\r\n\t\tif (getContainerElement()) {\r\n\t\t\tthis.screen.clearElement(getContainerElement())\r\n\t\t}\r\n\r\n\t\tthis.itemHeights = new ItemHeights(\r\n\t\t\tthis.screen,\r\n\t\t\tthis.getContainerElement,\r\n\t\t\t(i) => this.getState().itemHeights[i],\r\n\t\t\t(i, height) => this.getState().itemHeights[i] = height\r\n\t\t)\r\n\r\n\t\t// Initialize `ItemHeights` from the initially passed `state`.\r\n\t\tif (state) {\r\n\t\t\tthis.itemHeights.initialize(state.itemHeights)\r\n\t\t}\r\n\r\n\t\tthis.layout = new Layout({\r\n\t\t\tbypass,\r\n\t\t\testimatedItemHeight,\r\n\t\t\tmeasureItemsBatchSize: measureItemsBatchSize === undefined ? 50 : measureItemsBatchSize,\r\n\t\t\tgetVerticalSpacing: () => this.getVerticalSpacing(),\r\n\t\t\tgetColumnsCount: () => this.getColumnsCount(),\r\n\t\t\tgetItemHeight: (i) => this.getState().itemHeights[i],\r\n\t\t\tgetAverageItemHeight: () => this.itemHeights.getAverage()\r\n\t\t})\r\n\r\n\t\tthis.resize = new Resize({\r\n\t\t\tbypass,\r\n\t\t\tscrollableContainer: this.scrollableContainer,\r\n\t\t\tgetContainerElement: this.getContainerElement,\r\n\t\t\tupdateLayout: ({ reason }) => this.onUpdateShownItemIndexes({ reason }),\r\n\t\t\tresetStateAndLayout: () => {\r\n\t\t\t\t// Reset item heights, because if scrollable container's width (or height)\r\n\t\t\t\t// has changed, then the list width (or height) most likely also has changed,\r\n\t\t\t\t// and also some CSS `@media()` rules might have been added or removed.\r\n\t\t\t\t// So re-render the list entirely.\r\n\t\t\t\tlog('~ Scrollable container size changed, re-measure item heights. ~')\r\n\t\t\t\tthis.redoLayoutReason = LAYOUT_REASON.RESIZE\r\n\t\t\t\t// `this.layoutResetPending` flag will be cleared in `didUpdateState()`.\r\n\t\t\t\tthis.layoutResetPending = true\r\n\t\t\t\tlog('Reset state')\r\n\t\t\t\t// Calling `this.setState(state)` will trigger `didUpdateState()`.\r\n\t\t\t\t// `didUpdateState()` will detect `this.redoLayoutReason`.\r\n\t\t\t\tthis.setState(this.getInitialLayoutState(this.newItemsPending || this.getState().items))\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\tif (preserveScrollPositionAtBottomOnMount) {\r\n\t\t\twarn('`preserveScrollPositionAtBottomOnMount` option/property has been renamed to `preserveScrollPositionOfTheBottomOfTheListOnMount`')\r\n\t\t}\r\n\r\n\t\tthis.preserveScrollPositionOfTheBottomOfTheListOnMount = preserveScrollPositionOfTheBottomOfTheListOnMount || preserveScrollPositionAtBottomOnMount\r\n\r\n\t\tthis.scroll = new Scroll({\r\n\t\t\tbypass: this.bypass,\r\n\t\t\tscrollableContainer: this.scrollableContainer,\r\n\t\t\tupdateLayout: ({ reason }) => this.onUpdateShownItemIndexes({ reason }),\r\n\t\t\tinitialScrollPosition,\r\n\t\t\tonScrollPositionChange,\r\n\t\t\tisImmediateLayoutScheduled: () => this.layoutTimer,\r\n\t\t\thasNonRenderedItemsAtTheTop: () => this.getState().firstShownItemIndex > 0,\r\n\t\t\thasNonRenderedItemsAtTheBottom: () => this.getState().lastShownItemIndex < this.getItemsCount() - 1,\r\n\t\t\tgetLatestLayoutVisibleAreaIncludingMargins: () => this.latestLayoutVisibleAreaIncludingMargins,\r\n\t\t\tpreserveScrollPositionOfTheBottomOfTheListOnMount: this.preserveScrollPositionOfTheBottomOfTheListOnMount\r\n\t\t})\r\n\r\n\t\tthis.restoreScroll = new RestoreScroll({\r\n\t\t\tscreen: this.screen,\r\n\t\t\tgetContainerElement: this.getContainerElement\r\n\t\t})\r\n\r\n\t\tthis.waitForStylesToLoad = new WaitForStylesToLoad({\r\n\t\t\tupdateLayout: ({ reason }) => this.onUpdateShownItemIndexes({ reason }),\r\n\t\t\tgetListTopOffsetInsideScrollableContainer: this.getListTopOffsetInsideScrollableContainer\r\n\t\t})\r\n\r\n\t\tthis.setState(state || this.getInitialState(customState))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the initial state of the `VirtualScroller`.\r\n\t * @param {object} [customState] — Any additional \"custom\" state may be stored in `VirtualScroller`'s state. For example, React implementation stores item \"refs\" as \"custom\" state.\r\n\t * @return {object}\r\n\t */\r\n\tgetInitialState(customState) {\r\n\t\tconst items = this.initialItems\r\n\t\tconst state = {\r\n\t\t\t...customState,\r\n\t\t\t...this.getInitialLayoutState(items),\r\n\t\t\titems,\r\n\t\t\titemStates: new Array(items.length)\r\n\t\t}\r\n\t\tlog('Initial state (autogenerated)', state)\r\n\t\tlog('First shown item index', state.firstShownItemIndex)\r\n\t\tlog('Last shown item index', state.lastShownItemIndex)\r\n\t\treturn state\r\n\t}\r\n\r\n\tgetInitialLayoutValues({ itemsCount, bypass }) {\r\n\t\treturn this.layout.getInitialLayoutValues({\r\n\t\t\tbypass,\r\n\t\t\titemsCount,\r\n\t\t\tvisibleAreaHeightIncludingMargins: this.scrollableContainer && (2 * this.getMargin() + this.scrollableContainer.getHeight())\r\n\t\t})\r\n\t}\r\n\r\n\tgetInitialLayoutState(items) {\r\n\t\tconst itemsCount = items.length\r\n\t\tconst {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight\r\n\t\t} = this.getInitialLayoutValues({\r\n\t\t\titemsCount,\r\n\t\t\tbypass: this.preserveScrollPositionOfTheBottomOfTheListOnMount\r\n\t\t})\r\n\t\tconst itemHeights = new Array(itemsCount)\r\n\t\t// Optionally preload items to be rendered.\r\n\t\tthis.onBeforeShowItems(\r\n\t\t\titems,\r\n\t\t\titemHeights,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t)\r\n\t\t// This \"initial\" state object must include all possible state properties\r\n\t\t// because `this.setState()` gets called with this state on window resize,\r\n\t\t// when `VirtualScroller` gets reset.\r\n\t\t// Item states aren't included here because the state of all items should be\r\n\t\t// preserved on window resize.\r\n\t\treturn {\r\n\t\t\titemHeights,\r\n\t\t\tcolumnsCount: this._getColumnsCount ? this._getColumnsCount(this.scrollableContainer) : undefined,\r\n\t\t\tverticalSpacing: undefined,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight\r\n\t\t}\r\n\t}\r\n\r\n\tgetVerticalSpacing() {\r\n\t\treturn this.getState() && this.getState().verticalSpacing || 0\r\n\t}\r\n\r\n\tgetColumnsCount() {\r\n\t\treturn this.getState() && this.getState().columnsCount || 1\r\n\t}\r\n\r\n\tgetItemsCount() {\r\n\t\treturn this.getState().items.length\r\n\t}\r\n\r\n\tgetMargin() {\r\n\t\t// `VirtualScroller` also items that are outside of the screen\r\n\t\t// by the amount of this \"render ahead margin\" (both on top and bottom).\r\n\t\t// The default \"render ahead 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 height of a screen, and when they stop scrolling,\r\n\t\t// the list is re-rendered).\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\tonBeforeShowItems(\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\tonMount() {\r\n\t\twarn('`.onMount()` instance method name is deprecated, use `.listen()` instance method name instead.')\r\n\t\tthis.listen()\r\n\t}\r\n\r\n\trender() {\r\n\t\twarn('`.render()` instance method name is deprecated, use `.listen()` instance method name instead.')\r\n\t\tthis.listen()\r\n\t}\r\n\r\n\t/**\r\n\t * Should be invoked after a \"container\" DOM Element is mounted (inserted into the DOM tree).\r\n\t */\r\n\tlisten() {\r\n\t\tif (this.isRendered === false) {\r\n\t\t\tthrow new Error('[virtual-scroller] Can\\'t restart a `VirtualScroller` after it has been stopped')\r\n\t\t}\r\n\t\tlog('~ Rendered (initial) ~')\r\n\t\t// `this.isRendered = true` should be the first statement in this function,\r\n\t\t// otherwise `DOMVirtualScroller` would enter an infinite re-render loop.\r\n\t\tthis.isRendered = true\r\n\t\tthis.onRenderedNewLayout()\r\n\t\tthis.resize.listen()\r\n\t\tthis.scroll.listen()\r\n\t\t// Work around `<tbody/>` not being able to have `padding`.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1\r\n\t\tif (this.tbody) {\r\n\t\t\taddTbodyStyles(this.getContainerElement())\r\n\t\t}\r\n\t\tif (this.preserveScrollPositionOfTheBottomOfTheListOnMount) {\r\n\t\t\t// In this case, all items are shown, so there's no need to call\r\n\t\t\t// `this.onUpdateShownItemIndexes()` after the initial render.\r\n\t\t} else {\r\n\t\t\tthis.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.MOUNT })\r\n\t\t}\r\n\t}\r\n\r\n\tonRenderedNewLayout() {\r\n\t\t// Update item vertical spacing.\r\n\t\tthis.measureVerticalSpacing()\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\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.getContainerElement(),\r\n\t\t\t\tthis.getState().beforeItemsHeight,\r\n\t\t\t\tthis.getState().afterItemsHeight\r\n\t\t\t)\r\n\t\t}\r\n\t}\r\n\r\n\tgetVisibleAreaBoundsIncludingMargins() {\r\n\t\tconst visibleArea = this.scroll.getVisibleAreaBounds()\r\n\t\tvisibleArea.top -= this.getMargin()\r\n\t\tvisibleArea.bottom += this.getMargin()\r\n\t\treturn visibleArea\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\tgetListTopOffsetInsideScrollableContainer = () => {\r\n\t\tconst listTopOffset = this.scrollableContainer.getTopOffset(this.getContainerElement())\r\n\t\tthis.waitForStylesToLoad.onGotListTopOffset(listTopOffset)\r\n\t\treturn listTopOffset\r\n\t}\r\n\r\n\tonUnmount() {\r\n\t\twarn('`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.')\r\n\t\tthis.stop()\r\n\t}\r\n\r\n\tdestroy() {\r\n\t\twarn('`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.')\r\n\t\tthis.stop()\r\n\t}\r\n\r\n\tstop() {\r\n\t\tthis.isRendered = false\r\n\t\tthis.resize.stop()\r\n\t\tthis.scroll.stop()\r\n\t\tthis.waitForStylesToLoad.stop()\r\n\t\tif (this.layoutTimer) {\r\n\t\t\tclearTimeout(this.layoutTimer)\r\n\t\t\tthis.layoutTimer = undefined\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Should be called right before `state` is updated.\r\n\t * @param {object} prevState\r\n\t * @param {object} newState\r\n\t */\r\n\twillUpdateState = (newState, prevState) => {\r\n\t\t// Ignore setting initial state.\r\n\t\tif (!prevState) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\t// This function isn't currently used.\r\n\t\t// Was previously used to capture scroll position in order to\r\n\t\t// restore it later after the new state is rendered.\r\n\t}\r\n\r\n\t/**\r\n\t * Should be called right after `state` is updated.\r\n\t * @param {object} prevState\r\n\t */\r\n\tdidUpdateState = (prevState) => {\r\n\t\tconst newState = this.getState()\r\n\t\tif (this.onStateChange) {\r\n\t\t\tif (!shallowEqual(newState, prevState)) {\r\n\t\t\t\tthis.onStateChange(newState, prevState)\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Ignore setting initial state.\r\n\t\tif (!prevState) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\tif (!this.isRendered) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\tlog('~ Rendered ~')\r\n\t\tthis.newItemsPending = undefined\r\n\t\tthis.layoutResetPending = undefined\r\n\t\tlet redoLayoutReason = this.redoLayoutReason\r\n\t\tthis.redoLayoutReason = undefined\r\n\t\tconst { items: previousItems } = prevState\r\n\t\tconst { items: newItems } = newState\r\n\t\tif (newItems !== previousItems) {\r\n\t\t\tlet layoutNeedsReCalculating = true\r\n\t\t\tconst itemsDiff = this.getItemsDiff(previousItems, newItems)\r\n\t\t\t// If it's an \"incremental\" update.\r\n\t\t\tif (itemsDiff) {\r\n\t\t\t\tconst {\r\n\t\t\t\t\tprependedItemsCount,\r\n\t\t\t\t\tappendedItemsCount\r\n\t\t\t\t} = itemsDiff\r\n\t\t\t\tif (prependedItemsCount > 0) {\r\n\t\t\t\t\t// The call to `.onPrepend()` must precede\r\n\t\t\t\t\t// the call to `.measureItemHeights()`\r\n\t\t\t\t\t// which is called in `.onRendered()`.\r\n\t\t\t\t\tthis.itemHeights.onPrepend(prependedItemsCount)\r\n\t\t\t\t\tif (this.restoreScroll.shouldRestoreScrollAfterRender()) {\r\n\t\t\t\t\t\tlayoutNeedsReCalculating = false\r\n\t\t\t\t\t\tlog('~ Restore Scroll Position ~')\r\n\t\t\t\t\t\tconst scrollByY = this.restoreScroll.getScrollDifference()\r\n\t\t\t\t\t\tif (scrollByY) {\r\n\t\t\t\t\t\t\tlog('Scroll down by', scrollByY)\r\n\t\t\t\t\t\t\tthis.scroll.scrollByY(scrollByY)\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}\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tthis.itemHeights.reset()\r\n\t\t\t\tthis.itemHeights.initialize(this.getState().itemHeights)\r\n\t\t\t}\r\n\t\t\tif (layoutNeedsReCalculating) {\r\n\t\t\t\tredoLayoutReason = LAYOUT_REASON.ITEMS_CHANGED\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Call `.onRendered()` if shown items configuration changed.\r\n\t\tif (newState.firstShownItemIndex !== prevState.firstShownItemIndex ||\r\n\t\t\tnewState.lastShownItemIndex !== prevState.lastShownItemIndex ||\r\n\t\t\tnewState.items !== prevState.items) {\r\n\t\t\tthis.onRenderedNewLayout()\r\n\t\t}\r\n\t\tif (redoLayoutReason) {\r\n\t\t\treturn this.redoLayoutRightAfterRender({\r\n\t\t\t\treason: redoLayoutReason\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\tredoLayoutRightAfterRender({ reason }) {\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// `.setState()` 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\tif (this.layoutTimer) {\r\n\t\t\t\tclearTimeout(this.layoutTimer)\r\n\t\t\t}\r\n\t\t\t// Schedule a new re-layout.\r\n\t\t\tthis.layoutTimer = setTimeout(() => {\r\n\t\t\t\tthis.layoutTimer = undefined\r\n\t\t\t\tthis.onUpdateShownItemIndexes({ reason })\r\n\t\t\t}, 0)\r\n\t\t} else {\r\n\t\t\tthis.onUpdateShownItemIndexes({ reason })\r\n\t\t}\r\n\t}\r\n\r\n\tmeasureVerticalSpacing() {\r\n\t\tif (this.getState().verticalSpacing === undefined) {\r\n\t\t\tlog('~ Measure item vertical spacing ~')\r\n\t\t\tconst verticalSpacing = getVerticalSpacing({\r\n\t\t\t\tcontainer: this.getContainerElement(),\r\n\t\t\t\tscreen: this.screen\r\n\t\t\t})\r\n\t\t\tif (verticalSpacing === undefined) {\r\n\t\t\t\tlog('Not enough items rendered to measure vertical spacing')\r\n\t\t\t} else {\r\n\t\t\t\tlog('Item vertical spacing', verticalSpacing)\r\n\t\t\t\tthis.setState({ verticalSpacing })\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tremeasureItemHeight(i) {\r\n\t\tconst { firstShownItemIndex } = this.getState()\r\n\t\treturn this.itemHeights.remeasureItemHeight(i, firstShownItemIndex)\r\n\t}\r\n\r\n\tonItemStateChange(i, itemState) {\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('~ Item state changed ~')\r\n\t\t\tlog('Item', i)\r\n\t\t\tlog('Previous state' + '\\n' + JSON.stringify(this.getState().itemStates[i], null, 2))\r\n\t\t\tlog('New state' + '\\n' + JSON.stringify(itemState, null, 2))\r\n\t\t}\r\n\t\tthis.getState().itemStates[i] = itemState\r\n\t}\r\n\r\n\tonItemHeightChange(i) {\r\n\t\tlog('~ Re-measure item height ~')\r\n\t\tlog('Item', i)\r\n\t\tconst { itemHeights } = this.getState()\r\n\t\tconst previousHeight = itemHeights[i]\r\n\t\tif (previousHeight === undefined) {\r\n\t\t\treturn reportError(`\"onItemHeightChange()\" has been called for item ${i}, but that item hasn't been rendered before.`)\r\n\t\t}\r\n\t\tconst newHeight = this.remeasureItemHeight(i)\r\n\t\t// Check if the item is still rendered.\r\n\t\tif (newHeight === undefined) {\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 `.onItemHeightChange(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 `.onItemHeightChange(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 `.onItemHeightChange(i)` calls. No issues so far.\r\n\t\t\t// But, as the first `.onItemHeightChange(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 `.onItemHeightChange(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 `.onItemHeightChange(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// `.onItemHeightChange(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 there\\'re several `onItemHeightChange(i)` calls issued at the same time.')\r\n\t\t}\r\n\t\tlog('Previous height', previousHeight)\r\n\t\tlog('New height', newHeight)\r\n\t\tif (previousHeight !== newHeight) {\r\n\t\t\tlog('~ Item height has changed ~')\r\n\t\t\t// log('Item', i)\r\n\t\t\tthis.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.ITEM_HEIGHT_CHANGED })\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 `.onItemStateChange()` and `.onItemHeightChange(i)`.\r\n\t */\r\n\tvalidateWillBeHiddenItemHeightsAreAccurate(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// `.onItemHeightChange(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 `.onItemHeightChange(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 `.onItemHeightChange(i)` calls. No issues so far.\r\n\t\t\t\t// But, as the first `.onItemHeightChange(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 `.onItemHeightChange(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 `.onItemHeightChange(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 = this.remeasureItemHeight(i)\r\n\t\t\t\tif (actualItemHeight !== previouslyMeasuredItemHeight) {\r\n\t\t\t\t\tisValid = false\r\n\t\t\t\t\twarn('Item', i, 'will be unmounted at next render. Its height has changed from', previouslyMeasuredItemHeight, 'to', actualItemHeight, 'since it was last measured. This is not necessarily a bug, and could happen, for example, when there\\'re several `onItemHeightChange(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\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 * `redoLayoutAfterMeasuringItemHeights` is `true`.\r\n\t * If the list is visible and all items being shown have been encountered\r\n\t * (and measured) before, then `redoLayoutAfterMeasuringItemHeights` is `false`.\r\n\t */\r\n\tupdateShownItemIndexes = () => {\r\n\t\tlog('~ Layout results ' + (this.bypass ? '(bypass) ' : '') + '~')\r\n\t\tconst visibleAreaIncludingMargins = this.getVisibleAreaBoundsIncludingMargins()\r\n\t\tthis.latestLayoutVisibleAreaIncludingMargins = visibleAreaIncludingMargins\r\n\t\tconst listTopOffsetInsideScrollableContainer = this.getListTopOffsetInsideScrollableContainer()\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\tredoLayoutAfterMeasuringItemHeights\r\n\t\t} = this.layout.getShownItemIndexes({\r\n\t\t\tlistHeight: this.screen.getElementHeight(this.getContainerElement()),\r\n\t\t\titemsCount: this.getItemsCount(),\r\n\t\t\tvisibleAreaIncludingMargins,\r\n\t\t\tlistTopOffsetInsideScrollableContainer\r\n\t\t})\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.restoreScroll.shouldRestoreScrollAfterRender()) {\r\n\t\t\tif (lastShownItemIndex < this.restoreScroll.getAnchorItemIndex()) {\r\n\t\t\t\tlastShownItemIndex = this.restoreScroll.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 `redoLayoutAfterMeasuringItemHeights` to `true`\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\tredoLayoutAfterMeasuringItemHeights = false\r\n\t\t}\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 `.onItemStateChange()` and `.onItemHeightChange(i)`.\r\n\t\tif (!this.validateWillBeHiddenItemHeightsAreAccurate(firstShownItemIndex, lastShownItemIndex)) {\r\n\t\t\t// Redo layout, now with the correct item heights.\r\n\t\t\tlog('~ Some of the will-be-hidden item heights have changed since they\\'ve last been measured. Redo layout. ~')\r\n\t\t\treturn this.updateShownItemIndexes();\r\n\t\t}\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\tlastShownItemIndex\r\n\t\t)\r\n\t\t// Measure \"after\" items height.\r\n\t\tconst afterItemsHeight = this.layout.getAfterItemsHeight(\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tthis.getItemsCount()\r\n\t\t)\r\n\t\t// Debugging.\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 (calculated on previous render)', 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\t\tif (redoLayoutAfterMeasuringItemHeights) {\r\n\t\t\t// `this.redoLayoutReason` will be detected in `didUpdateState()`.\r\n\t\t\t// `didUpdateState()` is triggered by `this.setState()` below.\r\n\t\t\tthis.redoLayoutReason = LAYOUT_REASON.ITEM_HEIGHT_NOT_MEASURED\r\n\t\t}\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\t\t// Render.\r\n\t\tthis.setState({\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// // Average item height is stored in state to differentiate between\r\n\t\t\t// // the initial state and \"anything has been measured already\" state.\r\n\t\t\t// averageItemHeight: this.itemHeights.getAverage()\r\n\t\t})\r\n\t}\r\n\r\n\tonUpdateShownItemIndexes = ({ reason }) => {\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\r\n\t\t}\r\n\t\t// Cancel a \"re-layout when user stops scrolling\" timer.\r\n\t\tthis.scroll.onLayout()\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\tif (this.layoutTimer) {\r\n\t\t\tclearTimeout(this.layoutTimer)\r\n\t\t\tthis.layoutTimer = undefined\r\n\t\t}\r\n\t\t// Perform a re-layout.\r\n\t\tlog(`~ Calculate Layout (on ${reason}) ~`)\r\n\t\tthis.updateShownItemIndexes()\r\n\t}\r\n\r\n\tupdateLayout = () => this.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.MANUAL })\r\n\r\n\t// `.layout()` method name is deprecated, use `.updateLayout()` instead.\r\n\tlayout = () => this.updateLayout()\r\n\r\n\t/**\r\n\t * @deprecated\r\n\t * `.updateItems()` has been renamed to `.setItems()`.\r\n\t */\r\n\tupdateItems(newItems, options) {\r\n\t\treturn this.setItems(newItems, options)\r\n\t}\r\n\r\n\t/**\r\n\t * Updates `items`. For example, can prepend or append new items to the list.\r\n\t * @param {any[]} newItems\r\n\t * @param {boolean} [options.preserveScrollPositionOnPrependItems] — Set to `true` to enable \"restore scroll position after prepending items\" feature (could be useful when implementing \"Show previous items\" button).\r\n\t */\r\n\tsetItems(newItems, options = {}) {\r\n\t\t// * @param {object} [newCustomState] — If `customState` was passed to `getInitialState()`, this `newCustomState` updates it.\r\n\t\tconst {\r\n\t\t\titems: previousItems\r\n\t\t} = this.getState()\r\n\t\tlet {\r\n\t\t\titemStates,\r\n\t\t\titemHeights\r\n\t\t} = this.getState()\r\n\t\tlog('~ Update items ~')\r\n\t\tlet layout\r\n\t\tconst itemsDiff = this.getItemsDiff(previousItems, newItems)\r\n\t\t// If it's an \"incremental\" update.\r\n\t\tif (itemsDiff && !this.layoutResetPending) {\r\n\t\t\tconst {\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tafterItemsHeight\r\n\t\t\t} = this.getState()\r\n\t\t\tlayout = {\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tafterItemsHeight\r\n\t\t\t}\r\n\t\t\tconst {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t} = itemsDiff\r\n\t\t\tif (prependedItemsCount > 0) {\r\n\t\t\t\tlog('Prepend', prependedItemsCount, 'items')\r\n\t\t\t\titemHeights = new Array(prependedItemsCount).concat(itemHeights)\r\n\t\t\t\tif (itemStates) {\r\n\t\t\t\t\titemStates = new Array(prependedItemsCount).concat(itemStates)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (appendedItemsCount > 0) {\r\n\t\t\t\tlog('Append', appendedItemsCount, 'items')\r\n\t\t\t\titemHeights = itemHeights.concat(new Array(appendedItemsCount))\r\n\t\t\t\tif (itemStates) {\r\n\t\t\t\t\titemStates = itemStates.concat(new Array(appendedItemsCount))\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.layout.updateLayoutForItemsDiff(layout, itemsDiff, {\r\n\t\t\t\titemsCount: newItems.length\r\n\t\t\t})\r\n\t\t\tif (prependedItemsCount > 0) {\r\n\t\t\t\t// `preserveScrollPosition` option name is deprecated,\r\n\t\t\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\t\t\tif (options.preserveScrollPositionOnPrependItems || options.preserveScrollPosition) {\r\n\t\t\t\t\tif (this.getState().firstShownItemIndex === 0) {\r\n\t\t\t\t\t\tthis.restoreScroll.captureScroll({\r\n\t\t\t\t\t\t\tpreviousItems,\r\n\t\t\t\t\t\t\tnewItems,\r\n\t\t\t\t\t\t\tprependedItemsCount\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t\tthis.layout.showItemsFromTheStart(layout)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tlog('Items have changed, and', (itemsDiff ? 'a re-layout from scratch has been requested.' : 'it\\'s not a simple append and/or prepend.'), 'Rerender the entire list from scratch.')\r\n\t\t\tlog('Previous items', previousItems)\r\n\t\t\tlog('New items', newItems)\r\n\t\t\titemHeights = new Array(newItems.length)\r\n\t\t\titemStates = new Array(newItems.length)\r\n\t\t\tlayout = this.getInitialLayoutValues({\r\n\t\t\t\titemsCount: newItems.length\r\n\t\t\t})\r\n\t\t}\r\n\t\tlog('~ Update state ~')\r\n\t\tlog('First shown item index', layout.firstShownItemIndex)\r\n\t\tlog('Last shown item index', layout.lastShownItemIndex)\r\n\t\tlog('Before items height', layout.beforeItemsHeight)\r\n\t\tlog('After items height (actual or estimated)', layout.afterItemsHeight)\r\n\t\t// Optionally preload items to be rendered.\r\n\t\tthis.onBeforeShowItems(\r\n\t\t\tnewItems,\r\n\t\t\titemHeights,\r\n\t\t\tlayout.firstShownItemIndex,\r\n\t\t\tlayout.lastShownItemIndex\r\n\t\t)\r\n\t\t// `this.newItemsPending` will be cleared in `didUpdateState()`.\r\n\t\tthis.newItemsPending = newItems\r\n\t\t// Update state.\r\n\t\tthis.setState({\r\n\t\t\t// ...customState,\r\n\t\t\t...layout,\r\n\t\t\titems: newItems,\r\n\t\t\titemStates,\r\n\t\t\titemHeights\r\n\t\t})\r\n\t}\r\n\r\n\tgetItemsDiff(previousItems, newItems) {\r\n\t\treturn getItemsDiff(previousItems, newItems, this.isItemEqual)\r\n\t}\r\n}"],"file":"VirtualScroller.js"}
1
+ {"version":3,"sources":["../source/VirtualScroller.js"],"names":["setTimeout","clearTimeout","supportsTbody","BROWSER_NOT_SUPPORTED_ERROR","addTbodyStyles","setTbodyPadding","DOMEngine","Layout","LAYOUT_REASON","Resize","BeforeResize","Scroll","ListHeightChangeWatcher","ItemHeights","getItemsDiff","getVerticalSpacing","log","warn","isDebug","reportError","shallowEqual","getStateSnapshot","VirtualScroller","getItemsContainerElement","items","options","_getColumnsCount","scrollableContainer","undefined","verticalSpacing","listTopOffset","getItemsContainerTopOffset","listTopOffsetWatcher","onListTopOffset","isRendered","resize","stop","scroll","cancelLayoutTimer","newState","prevState","getState","onStateChange","layoutUpdateReason","firstNonMeasuredItemIndex","ACTUAL_ITEM_HEIGHTS_HAVE_BEEN_MEASURED","resetLayoutAfterResize","VIEWPORT_WIDTH_CHANGED","newItemsWillBeRendered","itemHeightsThatChangedWhileNewItemsWereBeingRendered","itemStatesThatChangedWhileNewItemsWereBeingRendered","itemHeights","reset","previousItems","newItems","itemsDiff","prependedItemsCount","onPrepend","initialize","onNewItemsRendered","ITEMS_CHANGED","stateUpdate","firstShownItemIndex","lastShownItemIndex","verticalSpacingStateUpdate","measureItemHeightsAndSpacingAndUpdateTablePadding","cleanedUpBeforeResize","beforeResize","cleanUpBeforeResizeItemHeights","scrollBy","scrollByY","updateStateRightAfterRender","reason","setState","startedAt","Date","now","getShownItemIndexes","shownItemsHeight","listHeightChangeWatcher","hasSnapshot","getAnchorItemIndex","validateWillBeHiddenItemHeightsAreAccurate","updateShownItemIndexes","beforeItemsHeight","layout","getBeforeItemsHeight","afterItemsHeight","getAfterItemsHeight","getItemsCount","layoutDuration","bypass","SLOW_LAYOUT_DURATION","getColumnsCount","getAverage","slice","itemStates","onBeforeShowItems","previouslyCalculatedLayout","skip","isResizing","cancelScheduledLayout","onUpdateShownItemIndexes","MANUAL","updateLayout","customState","initialScrollPosition","onScrollPositionChange","measureItemsBatchSize","getScrollableContainer","getItemId","tbody","_useTimeoutInRenderLoop","_waitForScrollingToStop","estimatedItemHeight","onItemInitialRender","onItemFirstRender","state","engine","itemsContainer","createItemsContainer","clear","createScrollableContainer","Error","isItemEqual","a","b","initialItems","item","i","indexOf","length","willUpdateState","didUpdateState","shouldResetLayout","columnsCountForState","getActualColumnsCountForState","columnsCount","getActualColumnsCount","Math","floor","getInitialLayoutState","height","getPrerenderMargin","getVerticalSpacingBeforeResize","getColumnsCountBeforeResize","getItemHeight","getItemHeightBeforeResize","getBeforeResizeItemsCount","getAverageItemHeight","getMaxVisibleAreaHeight","getHeight","getPreviouslyCalculatedLayout","onStart","onStop","onNoChange","VIEWPORT_SIZE_UNCHANGED","onHeightChange","VIEWPORT_HEIGHT_CHANGED","onWidthChange","prevWidth","newWidth","onResize","waitForScrollingToStop","onScroll","delayed","STOPPED_SCROLLING","SCROLL","isImmediateLayoutScheduled","layoutTimer","hasNonRenderedItemsAtTheTop","hasNonRenderedItemsAtTheBottom","getLatestLayoutVisibleArea","latestLayoutVisibleArea","getListTopOffset","getListTopOffsetInsideScrollableContainer","watchListTopOffset","onListTopOffsetChange","TOP_OFFSET_CHANGED","onInitialState","getInitialState","Array","itemsCount","getInitialLayoutValues","renderAheadMarginRatio","listen","MOUNTED","measureItemHeights","measureVerticalSpacing","visibleArea","getVisibleAreaBounds","listTopOffsetInsideScrollableContainer","top","bottom","itemTopOffsetInList","getItemTopOffset","layoutTimerStateUpdate","newLayout","appendedItemsCount","Object","keys","parseInt","listBottomOffsetChange","getListBottomOffsetChange","scheduleLayoutTimer","renderedItemsCount","remeasureItemHeight","newItemState","JSON","stringify","String","previousHeight","newHeight","updatePreviouslyCalculatedLayoutOnItemHeightChange","ITEM_HEIGHT_CHANGED","heightDifference","isValid","previouslyMeasuredItemHeight","actualItemHeight","getVisibleArea","visibleAreaTop","visibleAreaBottom","isVisible","getNonVisibleListShownItemIndexes","setItems","layoutUpdate","itemsUpdateInfo","shouldRestoreScrollPosition","preserveScrollPositionOnPrependItems","preserveScrollPosition","getLayoutUpdateForItemsDiff","concat","snapshot","prepend","append","replace","count","shouldIncludeBeforeResizeValuesInState","shouldDiscardBeforeResizeItemHeights","newColumnsCount","newFirstShownItemIndex","newLastShownItemIndex","ceil","snapshotBeforeResizeItemHeights"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,YAArB,QAAyC,iCAAzC;AAEA,SACCC,aADD,EAECC,2BAFD,EAGCC,cAHD,EAICC,eAJD,QAKO,aALP;AAOA,OAAOC,SAAP,MAAsB,cAAtB;AAEA,OAAOC,MAAP,IAAiBC,aAAjB,QAAsC,UAAtC;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,MAA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,QAAQ,CAAC4B,YAAT,GAAwBvC,SAAxB;AACA;AACD,OAJD,CAKA;AACA;AANA,WAOK;AACJ;AACA;AACA;AACA;AACAW,QAAAA,QAAQ,CAAC4B,YAAT,GAAwB;AACvBtC,UAAAA,eAAe,EAAfA,eADuB;AAEvB4G,UAAAA,YAAY,EAAZA,YAFuB;AAGvBtF,UAAAA,WAAW,EAAE,KAAKgB,YAAL,CAAkBgL,+BAAlB,CAAkD;AAC9DrL,YAAAA,mBAAmB,EAAnBA,mBAD8D;AAE9DkL,YAAAA,sBAAsB,EAAtBA,sBAF8D;AAG9DD,YAAAA,eAAe,EAAfA;AAH8D,WAAlD;AAHU,SAAxB;AASA,OApIS,CAsIV;AACA;AACA;AACA;;;AACA,WAAKjM,sBAAL,GAA8B;AAC7Be,QAAAA,WAAW,EAAEtB;AADgB,OAA9B,CA1IU,CA8IV;;AACA,WAAKkC,QAAL,CAAclC,QAAd;AACA;;;;;;SA54DmBjB,e;AA+4DrB,IAAMsE,oBAAoB,GAAG,EAA7B,C,CAAgC","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 {\r\n\tsupportsTbody,\r\n\tBROWSER_NOT_SUPPORTED_ERROR,\r\n\taddTbodyStyles,\r\n\tsetTbodyPadding\r\n} from './DOM/tbody'\r\n\r\nimport DOMEngine from './DOM/Engine'\r\n\r\nimport Layout, { LAYOUT_REASON } from './Layout'\r\nimport Resize from './Resize'\r\nimport BeforeResize from './BeforeResize'\r\nimport Scroll from './Scroll'\r\nimport ListHeightChangeWatcher from './ListHeightChangeWatcher'\r\nimport ItemHeights from './ItemHeights'\r\nimport getItemsDiff from './getItemsDiff'\r\nimport getVerticalSpacing from './getVerticalSpacing'\r\n\r\nimport log, { warn, isDebug, reportError } from './utility/debug'\r\nimport shallowEqual from './utility/shallowEqual'\r\nimport getStateSnapshot from './utility/getStateSnapshot'\r\n\r\nexport default class VirtualScroller {\r\n\t/**\r\n\t * @param {function} getItemsContainerElement — Returns the container DOM `Element`.\r\n\t * @param {any[]} items — The list of items.\r\n\t * @param {Object} [options] — See README.md.\r\n\t * @return {VirtualScroller}\r\n\t */\r\n\tconstructor(\r\n\t\tgetItemsContainerElement,\r\n\t\titems,\r\n\t\toptions = {}\r\n\t) {\r\n\t\tconst {\r\n\t\t\tonStateChange,\r\n\t\t\tcustomState,\r\n\t\t\tinitialScrollPosition,\r\n\t\t\tonScrollPositionChange,\r\n\t\t\tmeasureItemsBatchSize,\r\n\t\t\t// `getScrollableContainer` option is deprecated.\r\n\t\t\t// Use `scrollableContainer` instead.\r\n\t\t\tgetScrollableContainer,\r\n\t\t\tgetColumnsCount,\r\n\t\t\tgetItemId,\r\n\t\t\ttbody,\r\n\t\t\t_useTimeoutInRenderLoop,\r\n\t\t\t_waitForScrollingToStop,\r\n\t\t\t// bypassBatchSize\r\n\t\t} = options\r\n\r\n\t\tlet {\r\n\t\t\tgetState,\r\n\t\t\tsetState\r\n\t\t} = options\r\n\r\n\t\tlet {\r\n\t\t\tbypass,\r\n\t\t\t// prerenderMargin,\r\n\t\t\testimatedItemHeight,\r\n\t\t\t// getItemState,\r\n\t\t\tonItemInitialRender,\r\n\t\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\t\tonItemFirstRender,\r\n\t\t\tscrollableContainer,\r\n\t\t\tstate,\r\n\t\t\tengine\r\n\t\t} = options\r\n\r\n\t\tlog('~ Initialize ~')\r\n\r\n\t\t// If `state` is passed then use `items` from `state`\r\n\t\t// instead of the `items` argument.\r\n\t\tif (state) {\r\n\t\t\titems = state.items\r\n\t\t}\r\n\r\n\t\t// `getScrollableContainer` option is deprecated.\r\n\t\t// Use `scrollableContainer` instead.\r\n\t\tif (!scrollableContainer && getScrollableContainer) {\r\n\t\t\tscrollableContainer = getScrollableContainer()\r\n\t\t}\r\n\r\n\t\t// Could support non-DOM rendering engines.\r\n\t\t// For example, React Native, `<canvas/>`, etc.\r\n\t\tif (!engine) {\r\n\t\t\tengine = DOMEngine\r\n\t\t}\r\n\r\n\t\t// Sometimes, when `new VirtualScroller()` instance is created,\r\n\t\t// `getItemsContainerElement()` might not be ready to return the \"container\" DOM Element yet\r\n\t\t// (for example, because it's not rendered yet). That's the reason why it's a getter function.\r\n\t\t// For example, in React `<VirtualScroller/>` component, a `VirtualScroller`\r\n\t\t// instance is created in the React component's `constructor()`, and at that time\r\n\t\t// the container Element is not yet available. The container Element is available\r\n\t\t// in `componentDidMount()`, but `componentDidMount()` is not executed on server,\r\n\t\t// which would mean that React `<VirtualScroller/>` wouldn't render at all\r\n\t\t// on server side, while with the `getItemsContainerElement()` approach, on server side,\r\n\t\t// it still \"renders\" a list with a predefined amount of items in it by default.\r\n\t\t// (`initiallyRenderedItemsCount`, or `1`).\r\n\t\tthis.getItemsContainerElement = getItemsContainerElement\r\n\t\tthis.itemsContainer = engine.createItemsContainer(getItemsContainerElement)\r\n\r\n\t\t// Remove any accidental text nodes from container (like whitespace).\r\n\t\t// Also guards against cases when someone accidentally tries\r\n\t\t// using `VirtualScroller` on a non-empty element.\r\n\t\tif (getItemsContainerElement()) {\r\n\t\t\tthis.itemsContainer.clear()\r\n\t\t}\r\n\r\n\t\tthis.scrollableContainer = engine.createScrollableContainer(\r\n\t\t\tscrollableContainer,\r\n\t\t\tgetItemsContainerElement\r\n\t\t)\r\n\r\n\t\t// if (prerenderMargin === undefined) {\r\n\t\t// \t// Renders items which are outside of the screen by this \"prerender margin\".\r\n\t\t// \t// Is the screen height by default: seems to be the optimal value\r\n\t\t// \t// for \"Page Up\" / \"Page Down\" navigation and optimized mouse wheel scrolling.\r\n\t\t// \tprerenderMargin = this.scrollableContainer ? this.scrollableContainer.getHeight() : 0\r\n\t\t// }\r\n\r\n\t\t// Work around `<tbody/>` not being able to have `padding`.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1\r\n\t\tif (tbody) {\r\n\t\t\tif (engine !== DOMEngine) {\r\n\t\t\t\tthrow new Error('[virtual-scroller] `tbody` option is only supported for DOM rendering engine')\r\n\t\t\t}\r\n\t\t\tlog('~ <tbody/> detected ~')\r\n\t\t\tthis.tbody = true\r\n\t\t\tif (!supportsTbody()) {\r\n\t\t\t\tlog('~ <tbody/> not supported ~')\r\n\t\t\t\treportError(BROWSER_NOT_SUPPORTED_ERROR)\r\n\t\t\t\tbypass = true\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (bypass) {\r\n\t\t\tlog('~ \"bypass\" mode ~')\r\n\t\t}\r\n\r\n\t\t// In `bypass` mode, `VirtualScroller` doesn't wait\r\n\t\t// for the user to scroll down to render all items:\r\n\t\t// instead, it renders all items right away, as if\r\n\t\t// the list is rendered without using `VirtualScroller`.\r\n\t\t// It was added just to measure how much is the\r\n\t\t// performance difference between using a `VirtualScroller`\r\n\t\t// and not using a `VirtualScroller`.\r\n\t\t// It turned out that unmounting large React component trees\r\n\t\t// is a very long process, so `VirtualScroller` does seem to\r\n\t\t// make sense when used in a React application.\r\n\t\tthis.bypass = bypass\r\n\t\t// this.bypassBatchSize = bypassBatchSize || 10\r\n\r\n\t\t// Using `setTimeout()` in render loop is a workaround\r\n\t\t// for avoiding a React error message:\r\n\t\t// \"Maximum update depth exceeded.\r\n\t\t// This can happen when a component repeatedly calls\r\n\t\t// `.setState()` inside `componentWillUpdate()` or `componentDidUpdate()`.\r\n\t\t// React limits the number of nested updates to prevent infinite loops.\"\r\n\t\tthis._useTimeoutInRenderLoop = _useTimeoutInRenderLoop\r\n\r\n\t\tif (getItemId) {\r\n\t\t\tthis.isItemEqual = (a, b) => getItemId(a) === getItemId(b)\r\n\t\t} else {\r\n\t\t\tthis.isItemEqual = (a, b) => a === b\r\n\t\t}\r\n\r\n\t\tthis.initialItems = items\r\n\t\t// this.prerenderMargin = prerenderMargin\r\n\r\n\t\tthis.onStateChange = onStateChange\r\n\r\n\t\tthis._getColumnsCount = getColumnsCount\r\n\r\n\t\tif (onItemInitialRender) {\r\n\t\t\tthis.onItemInitialRender = onItemInitialRender\r\n\t\t}\r\n\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\telse if (onItemFirstRender) {\r\n\t\t\tthis.onItemInitialRender = (item) => {\r\n\t\t\t\twarn('`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.')\r\n\t\t\t\tconst { items } = this.getState()\r\n\t\t\t\tconst i = items.indexOf(item)\r\n\t\t\t\t// The `item` could also be non-found due to the inconsistency bug:\r\n\t\t\t\t// The reason is that `i` can be non-consistent with the `items`\r\n\t\t\t\t// passed to `<VirtualScroller/>` in React due to `setState()` not being\r\n\t\t\t\t// instanteneous: when new `items` are passed to `<VirtualScroller/>`,\r\n\t\t\t\t// `VirtualScroller.setState({ items })` is called, and if `onItemFirstRender(i)`\r\n\t\t\t\t// is called after the aforementioned `setState()` is called but before it finishes,\r\n\t\t\t\t// `i` would point to an index in \"previous\" `items` while the application\r\n\t\t\t\t// would assume that `i` points to an index in the \"new\" `items`,\r\n\t\t\t\t// resulting in an incorrect item being assumed by the application\r\n\t\t\t\t// or even in an \"array index out of bounds\" error.\r\n\t\t\t\tif (i >= 0) {\r\n\t\t\t\t\tonItemFirstRender(i)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlog('Items count', items.length)\r\n\t\tif (estimatedItemHeight) {\r\n\t\t\tlog('Estimated item height', estimatedItemHeight)\r\n\t\t}\r\n\r\n\t\t// There're three main places where state is updated:\r\n\t\t//\r\n\t\t// * On scroll.\r\n\t\t// * On window resize.\r\n\t\t// * On set new items.\r\n\t\t//\r\n\t\t// State updates may be \"asynchronous\" (like in React), in which case the\r\n\t\t// corresponding operation is \"pending\" until the state update is applied.\r\n\t\t//\r\n\t\t// If there's a \"pending\" window resize or a \"pending\" update of the set of items,\r\n\t\t// then \"on scroll\" updates aren't dispatched.\r\n\t\t//\r\n\t\t// If there's a \"pending\" on scroll update and the window is resize or a new set\r\n\t\t// of items is set, then that \"pending\" on scroll update gets overwritten.\r\n\t\t//\r\n\t\t// If there's a \"pending\" update of the set of items, then window resize handler\r\n\t\t// sees that \"pending\" update and dispatches its own state update so that the\r\n\t\t// \"pending\" state update originating from `setItems()` is not lost.\r\n\t\t//\r\n\t\t// If there's a \"pending\" window resize, and a new set of items is set,\r\n\t\t// then the state update of the window resize handler gets overwritten.\r\n\r\n\t\t// Create default `getState()`/`setState()` functions.\r\n\t\tif (!getState) {\r\n\t\t\tgetState = () => this.state\r\n\t\t\tsetState = (stateUpdate, { willUpdateState, didUpdateState }) => {\r\n\t\t\t\tconst prevState = getState()\r\n\t\t\t\t// Because this variant of `.setState()` is \"synchronous\" (immediate),\r\n\t\t\t\t// it can be written like `...prevState`, and no state updates would be lost.\r\n\t\t\t\t// But if it was \"asynchronous\" (not immediate), then `...prevState`\r\n\t\t\t\t// wouldn't work in all cases, because it could be stale in cases\r\n\t\t\t\t// when more than a single `setState()` call is made before\r\n\t\t\t\t// the state actually updates, making `prevState` stale.\r\n\t\t\t\tconst newState = {\r\n\t\t\t\t\t...prevState,\r\n\t\t\t\t\t...stateUpdate\r\n\t\t\t\t}\r\n\t\t\t\twillUpdateState(newState, prevState)\r\n\t\t\t\tthis.state = newState\r\n\t\t\t\t// // Is only used in tests.\r\n\t\t\t\t// if (this._onStateUpdate) {\r\n\t\t\t\t// \tthis._onStateUpdate(stateUpdate)\r\n\t\t\t\t// }\r\n\t\t\t\tdidUpdateState(prevState)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.getState = getState\r\n\t\tthis.setState = (stateUpdate) => {\r\n\t\t\tif (isDebug()) {\r\n\t\t\t\tlog('Set state', getStateSnapshot(stateUpdate))\r\n\t\t\t}\r\n\t\t\tsetState(stateUpdate, {\r\n\t\t\t\twillUpdateState: this.willUpdateState,\r\n\t\t\t\tdidUpdateState: this.didUpdateState\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\tif (state) {\r\n\t\t\tif (isDebug()) {\r\n\t\t\t\tlog('Initial state (passed)', getStateSnapshot(state))\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Check if the current `columnsCount` matches the one from state.\r\n\t\t// For example, a developer might snapshot `VirtualScroller` state\r\n\t\t// when the user navigates from the page containing the list\r\n\t\t// in order to later restore the list's state when the user goes \"Back\".\r\n\t\t// But, the user might have also resized the window while being on that\r\n\t\t// \"other\" page, and when they come \"Back\", their snapshotted state\r\n\t\t// no longer qualifies. Well, it does qualify, but only partially.\r\n\t\t// For example, `itemStates` are still valid, but first and last shown\r\n\t\t// item indexes aren't.\r\n\t\tif (state) {\r\n\t\t\tlet shouldResetLayout\r\n\t\t\tconst columnsCountForState = this.getActualColumnsCountForState()\r\n\t\t\tif (columnsCountForState !== state.columnsCount) {\r\n\t\t\t\twarn('~ Columns Count changed from', state.columnsCount || 1, 'to', columnsCountForState || 1, '~')\r\n\t\t\t\tshouldResetLayout = true\r\n\t\t\t}\r\n\t\t\tconst columnsCount = this.getActualColumnsCount()\r\n\t\t\tconst firstShownItemIndex = Math.floor(state.firstShownItemIndex / columnsCount) * columnsCount\r\n\t\t\tif (firstShownItemIndex !== state.firstShownItemIndex) {\r\n\t\t\t\twarn('~ First Shown Item Index', state.firstShownItemIndex, 'is not divisible by Columns Count', columnsCount, '~')\r\n\t\t\t\tshouldResetLayout = true\r\n\t\t\t}\r\n\t\t\tif (shouldResetLayout) {\r\n\t\t\t\twarn('Reset Layout')\r\n\t\t\t\tstate = {\r\n\t\t\t\t\t...state,\r\n\t\t\t\t\t...this.getInitialLayoutState(state.items)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Reset `verticalSpacing` so that it re-measures it after the list\r\n\t\t// has been rendered initially. The rationale is that the `state`\r\n\t\t// can't be \"trusted\" in a sense that the user might have resized\r\n\t\t// their window after the `state` has been snapshotted, and changing\r\n\t\t// window width might have activated different CSS `@media()` \"queries\"\r\n\t\t// resulting in a potentially different vertical spacing.\r\n\t\tif (state) {\r\n\t\t\tstate = {\r\n\t\t\t\t...state,\r\n\t\t\t\tverticalSpacing: undefined\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Create `ItemHeights` instance.\r\n\t\tthis.itemHeights = new ItemHeights(\r\n\t\t\tthis.itemsContainer,\r\n\t\t\t(i) => this.getState().itemHeights[i],\r\n\t\t\t(i, height) => this.getState().itemHeights[i] = height\r\n\t\t)\r\n\r\n\t\t// Initialize `ItemHeights` from the initially passed `state`.\r\n\t\tif (state) {\r\n\t\t\tthis.itemHeights.initialize(state.itemHeights)\r\n\t\t}\r\n\r\n\t\tthis.layout = new Layout({\r\n\t\t\tbypass,\r\n\t\t\testimatedItemHeight,\r\n\t\t\tmeasureItemsBatchSize: measureItemsBatchSize === undefined ? 50 : measureItemsBatchSize,\r\n\t\t\tgetPrerenderMargin: () => this.getPrerenderMargin(),\r\n\t\t\tgetVerticalSpacing: () => this.getVerticalSpacing(),\r\n\t\t\tgetVerticalSpacingBeforeResize: () => this.getVerticalSpacingBeforeResize(),\r\n\t\t\tgetColumnsCount: () => this.getColumnsCount(),\r\n\t\t\tgetColumnsCountBeforeResize: () => this.getState().beforeResize && this.getState().beforeResize.columnsCount,\r\n\t\t\tgetItemHeight: (i) => this.getState().itemHeights[i],\r\n\t\t\tgetItemHeightBeforeResize: (i) => this.getState().beforeResize && this.getState().beforeResize.itemHeights[i],\r\n\t\t\tgetBeforeResizeItemsCount: () => this.getState().beforeResize ? this.getState().beforeResize.itemHeights.length : 0,\r\n\t\t\tgetAverageItemHeight: () => this.itemHeights.getAverage(),\r\n\t\t\tgetMaxVisibleAreaHeight: () => this.scrollableContainer && this.scrollableContainer.getHeight(),\r\n\t\t\t//\r\n\t\t\t// The \"previously calculated layout\" feature is not currently used.\r\n\t\t\t//\r\n\t\t\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t\t\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t\t\t// rather than from scratch, which would be an optimization.\r\n\t\t\t//\r\n\t\t\tgetPreviouslyCalculatedLayout: () => this.previouslyCalculatedLayout\r\n\t\t})\r\n\r\n\t\tthis.resize = new Resize({\r\n\t\t\tbypass,\r\n\t\t\tscrollableContainer: this.scrollableContainer,\r\n\t\t\tonStart: () => {\r\n\t\t\t\tlog('~ Scrollable container resize started ~')\r\n\t\t\t\tthis.isResizing = true\r\n\t\t\t},\r\n\t\t\tonStop: () => {\r\n\t\t\t\tlog('~ Scrollable container resize finished ~')\r\n\t\t\t\tthis.isResizing = undefined\r\n\t\t\t},\r\n\t\t\tonNoChange: () => {\r\n\t\t\t\t// There might have been some missed `this.onUpdateShownItemIndexes()` calls\r\n\t\t\t\t// due to setting `this.isResizing` flag to `true` during the resize.\r\n\t\t\t\t// So, update shown item indexes just in case.\r\n\t\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\t\treason: LAYOUT_REASON.VIEWPORT_SIZE_UNCHANGED\r\n\t\t\t\t})\r\n\t\t\t},\r\n\t\t\tonHeightChange: () => this.onUpdateShownItemIndexes({\r\n\t\t\t\treason: LAYOUT_REASON.VIEWPORT_HEIGHT_CHANGED\r\n\t\t\t}),\r\n\t\t\tonWidthChange: (prevWidth, newWidth) => {\r\n\t\t\t\tlog('~ Scrollable container width changed from', prevWidth, 'to', newWidth, '~')\r\n\t\t\t\tthis.onResize()\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\tthis.scroll = new Scroll({\r\n\t\t\tbypass: this.bypass,\r\n\t\t\tscrollableContainer: this.scrollableContainer,\r\n\t\t\titemsContainer: this.itemsContainer,\r\n\t\t\twaitForScrollingToStop: _waitForScrollingToStop,\r\n\t\t\tonScroll: ({ delayed } = {}) => {\r\n\t\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\t\treason: delayed ? LAYOUT_REASON.STOPPED_SCROLLING : LAYOUT_REASON.SCROLL\r\n\t\t\t\t})\r\n\t\t\t},\r\n\t\t\tinitialScrollPosition,\r\n\t\t\tonScrollPositionChange,\r\n\t\t\tisImmediateLayoutScheduled: () => this.layoutTimer,\r\n\t\t\thasNonRenderedItemsAtTheTop: () => this.getState().firstShownItemIndex > 0,\r\n\t\t\thasNonRenderedItemsAtTheBottom: () => this.getState().lastShownItemIndex < this.getItemsCount() - 1,\r\n\t\t\tgetLatestLayoutVisibleArea: () => this.latestLayoutVisibleArea,\r\n\t\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer,\r\n\t\t\tgetPrerenderMargin: () => this.getPrerenderMargin()\r\n\t\t})\r\n\r\n\t\tthis.listHeightChangeWatcher = new ListHeightChangeWatcher({\r\n\t\t\titemsContainer: this.itemsContainer,\r\n\t\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer\r\n\t\t})\r\n\r\n\t\tif (engine.watchListTopOffset) {\r\n\t\t\tthis.listTopOffsetWatcher = engine.watchListTopOffset({\r\n\t\t\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer,\r\n\t\t\t\tonListTopOffsetChange: ({ reason }) => this.onUpdateShownItemIndexes({\r\n\t\t\t\t\treason: LAYOUT_REASON.TOP_OFFSET_CHANGED\r\n\t\t\t\t})\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\tthis.beforeResize = new BeforeResize({\r\n\t\t\tgetState: this.getState,\r\n\t\t\tgetVerticalSpacing: this.getVerticalSpacing,\r\n\t\t\tgetColumnsCount: this.getColumnsCount\r\n\t\t})\r\n\r\n\t\t// Possibly clean up \"before resize\" property in state.\r\n\t\t// \"Before resize\" state property is cleaned up when all \"before resize\" item heights\r\n\t\t// have been re-measured in an asynchronous `this.setState({ beforeResize: undefined })` call.\r\n\t\t// If `VirtualScroller` state was snapshotted externally before that `this.setState()` call\r\n\t\t// has been applied, then \"before resize\" property might have not been cleaned up properly.\r\n\t\tthis.beforeResize.onInitialState(state)\r\n\r\n\t\t// `this.verticalSpacing` acts as a \"true\" source for vertical spacing value.\r\n\t\t// Vertical spacing is also stored in `state` but `state` updates could be\r\n\t\t// \"asynchronous\" (not applied immediately) and `this.onUpdateShownItemIndexes()`\r\n\t\t// requires vertical spacing to be correct at any time, without any delays.\r\n\t\t// So, vertical spacing is also duplicated in `state`, but the \"true\" source\r\n\t\t// is still `this.verticalSpacing`.\r\n\t\t//\r\n\t\t// `this.verticalSpacing` must be initialized before calling `this.getInitialState()`.\r\n\t\t//\r\n\t\tthis.verticalSpacing = state ? state.verticalSpacing : undefined\r\n\r\n\t\t// Set initial `state`.\r\n\t\tthis.setState(state || this.getInitialState(customState))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the initial state of the `VirtualScroller`.\r\n\t * @param {object} [customState] — Any additional \"custom\" state may be stored in `VirtualScroller`'s state. For example, React implementation stores item \"refs\" as \"custom\" state.\r\n\t * @return {object}\r\n\t */\r\n\tgetInitialState(customState) {\r\n\t\tconst items = this.initialItems\r\n\t\tconst state = {\r\n\t\t\t...customState,\r\n\t\t\t...this.getInitialLayoutState(items),\r\n\t\t\titems,\r\n\t\t\titemStates: new Array(items.length)\r\n\t\t}\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('Initial state (autogenerated)', getStateSnapshot(state))\r\n\t\t}\r\n\t\tlog('First shown item index', state.firstShownItemIndex)\r\n\t\tlog('Last shown item index', state.lastShownItemIndex)\r\n\t\treturn state\r\n\t}\r\n\r\n\tgetInitialLayoutState(items) {\r\n\t\tconst itemsCount = items.length\r\n\t\tconst {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight\r\n\t\t} = this.layout.getInitialLayoutValues({\r\n\t\t\titemsCount,\r\n\t\t\tcolumnsCount: this.getColumnsCount()\r\n\t\t})\r\n\t\tconst itemHeights = new Array(itemsCount)\r\n\t\t// Optionally preload items to be rendered.\r\n\t\tthis.onBeforeShowItems(\r\n\t\t\titems,\r\n\t\t\titemHeights,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t)\r\n\t\treturn {\r\n\t\t\titemHeights,\r\n\t\t\tcolumnsCount: this.getActualColumnsCountForState(),\r\n\t\t\tverticalSpacing: this.verticalSpacing,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight\r\n\t\t}\r\n\t}\r\n\r\n\t// Bind to `this` in order to prevent bugs when this function is passed by reference\r\n\t// and then called with its `this` being unintentionally `window` resulting in\r\n\t// the `if` condition being \"falsy\".\r\n\tgetActualColumnsCountForState = () => {\r\n\t\treturn this._getColumnsCount ? this._getColumnsCount(this.scrollableContainer) : undefined\r\n\t}\r\n\r\n\tgetActualColumnsCount() {\r\n\t\treturn this.getActualColumnsCountForState() || 1\r\n\t}\r\n\r\n\t// Bind to `this` in order to prevent bugs when this function is passed by reference\r\n\t// and then called with its `this` being unintentionally `window` resulting in\r\n\t// the `if` condition being \"falsy\".\r\n\tgetVerticalSpacing = () => {\r\n\t\treturn this.verticalSpacing || 0\r\n\t}\r\n\r\n\tgetVerticalSpacingBeforeResize() {\r\n\t\t// `beforeResize.verticalSpacing` can be `undefined`.\r\n\t\t// For example, if `this.setState({ verticalSpacing })` call hasn't been applied\r\n\t\t// before the resize happened (in case of an \"asynchronous\" state update).\r\n\t\treturn this.getState().beforeResize && this.getState().beforeResize.verticalSpacing || 0\r\n\t}\r\n\r\n\tgetColumnsCount() {\r\n\t\treturn this.getState() && this.getState().columnsCount || 1\r\n\t}\r\n\r\n\tgetItemsCount() {\r\n\t\treturn this.getState().items.length\r\n\t}\r\n\r\n\tgetPrerenderMargin() {\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\tonBeforeShowItems(\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\tonMount() {\r\n\t\twarn('`.onMount()` instance method name is deprecated, use `.listen()` instance method name instead.')\r\n\t\tthis.listen()\r\n\t}\r\n\r\n\trender() {\r\n\t\twarn('`.render()` instance method name is deprecated, use `.listen()` instance method name instead.')\r\n\t\tthis.listen()\r\n\t}\r\n\r\n\t/**\r\n\t * Should be invoked after a \"container\" DOM Element is mounted (inserted into the DOM tree).\r\n\t */\r\n\tlisten() {\r\n\t\tif (this.isRendered === false) {\r\n\t\t\tthrow new Error('[virtual-scroller] Can\\'t restart a `VirtualScroller` after it has been stopped')\r\n\t\t}\r\n\r\n\t\tlog('~ Rendered (initial) ~')\r\n\t\t// `this.isRendered = true` should be the first statement in this function,\r\n\t\t// otherwise `DOMVirtualScroller` would enter an infinite re-render loop.\r\n\t\tthis.isRendered = true\r\n\r\n\t\tconst stateUpdate = this.measureItemHeightsAndSpacingAndUpdateTablePadding()\r\n\r\n\t\tthis.resize.listen()\r\n\t\tthis.scroll.listen()\r\n\r\n\t\t// Work around `<tbody/>` not being able to have `padding`.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1\r\n\t\tif (this.tbody) {\r\n\t\t\taddTbodyStyles(this.getItemsContainerElement())\r\n\t\t}\r\n\r\n\t\t// Re-calculate layout and re-render the list.\r\n\t\t// Do that even if when an initial `state` parameter, containing layout values,\r\n\t\t// has been passed. The reason is that the `state` parameter can't be \"trusted\"\r\n\t\t// in a way that it could have been snapshotted for another window width and\r\n\t\t// the user might have resized their window since then.\r\n\t\tthis.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.MOUNTED, stateUpdate })\r\n\t}\r\n\r\n\tmeasureItemHeightsAndSpacingAndUpdateTablePadding() {\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// Update item vertical spacing.\r\n\t\tconst verticalSpacing = this.measureVerticalSpacing()\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\tthis.getState().beforeItemsHeight,\r\n\t\t\t\tthis.getState().afterItemsHeight\r\n\t\t\t)\r\n\t\t}\r\n\r\n\t\t// Return a state update.\r\n\t\tif (verticalSpacing !== undefined) {\r\n\t\t\treturn { verticalSpacing }\r\n\t\t}\r\n\t}\r\n\r\n\tgetVisibleArea() {\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\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\tgetListTopOffsetInsideScrollableContainer = () => {\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\t/**\r\n\t * Returns the items's top offset relative to the scrollable container's top edge.\r\n\t * @param {number} i — Item index\r\n\t * @return {[number]} Returns the item's scroll Y position. Returns `undefined` if any of the previous items haven't been rendered yet.\r\n\t */\r\n\tgetItemScrollPosition(i) {\r\n\t\tconst itemTopOffsetInList = this.layout.getItemTopOffset(i)\r\n\t\tif (itemTopOffsetInList === undefined) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\treturn this.getListTopOffsetInsideScrollableContainer() + itemTopOffsetInList\r\n\t}\r\n\r\n\tonUnmount() {\r\n\t\twarn('`.onUnmount()` instance method name is deprecated, use `.stop()` instance method name instead.')\r\n\t\tthis.stop()\r\n\t}\r\n\r\n\tdestroy() {\r\n\t\twarn('`.destroy()` instance method name is deprecated, use `.stop()` instance method name instead.')\r\n\t\tthis.stop()\r\n\t}\r\n\r\n\tstop = () => {\r\n\t\tthis.isRendered = false\r\n\t\tthis.resize.stop()\r\n\t\tthis.scroll.stop()\r\n\t\tif (this.listTopOffsetWatcher) {\r\n\t\t\tthis.listTopOffsetWatcher.stop()\r\n\t\t}\r\n\t\tthis.cancelLayoutTimer({})\r\n\t}\r\n\r\n\tcancelLayoutTimer({ 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\tscheduleLayoutTimer({ 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\t/**\r\n\t * Should be called right before `state` is updated.\r\n\t * @param {object} prevState\r\n\t * @param {object} newState\r\n\t */\r\n\twillUpdateState = (newState, prevState) => {\r\n\t\t// Ignore setting initial state.\r\n\t\tif (!prevState) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\t// This function isn't currently used.\r\n\t\t// Was previously used to capture scroll position in order to\r\n\t\t// restore it later after the new state is rendered.\r\n\t}\r\n\r\n\t/**\r\n\t * Should be called right after `state` is updated.\r\n\t * @param {object} prevState\r\n\t */\r\n\tdidUpdateState = (prevState) => {\r\n\t\tconst newState = this.getState()\r\n\r\n\t\tif (this.onStateChange) {\r\n\t\t\tif (!shallowEqual(newState, prevState)) {\r\n\t\t\t\tthis.onStateChange(newState, prevState)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Ignore setting initial state.\r\n\t\tif (!prevState) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (!this.isRendered) {\r\n\t\t\treturn\r\n\t\t}\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\tlet layoutUpdateReason\r\n\r\n\t\tif (this.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.ACTUAL_ITEM_HEIGHTS_HAVE_BEEN_MEASURED\r\n\t\t}\r\n\r\n\t\tif (this.resetLayoutAfterResize) {\r\n\t\t\tlayoutUpdateReason = LAYOUT_REASON.VIEWPORT_WIDTH_CHANGED\r\n\t\t}\r\n\r\n\t\t// If `this.resetLayoutAfterResize` flag was reset after calling\r\n\t\t// `this.measureItemHeightsAndSpacingAndUpdateTablePadding()`\r\n\t\t// then there would be a bug because\r\n\t\t// `this.measureItemHeightsAndSpacingAndUpdateTablePadding()`\r\n\t\t// calls `this.setState({ verticalSpacing })` which calls\r\n\t\t// `this.didUpdateState()` immediately, so `this.resetLayoutAfterResize`\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.resetLayoutAfterResize` flag\r\n\t\t// and reset it right away to prevent any such potential bugs.\r\n\t\t//\r\n\t\tconst resetLayoutAfterResize = this.resetLayoutAfterResize\r\n\r\n\t\t// Reset `this.firstNonMeasuredItemIndex`.\r\n\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\r\n\t\t// Reset `this.resetLayoutAfterResize` flag.\r\n\t\tthis.resetLayoutAfterResize = 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\tif (resetLayoutAfterResize) {\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\tconst { items: previousItems } = prevState\r\n\t\tconst { items: newItems } = newState\r\n\t\t// Even if `this.newItemsWillBeRendered` flag is `true`,\r\n\t\t// `newItems` could still be equal to `previousItems`.\r\n\t\t// For example, when `setState()` calls don't update `state` immediately\r\n\t\t// and a developer first calls `setItems(newItems)` and then calls `setItems(oldItems)`:\r\n\t\t// in that case, `this.newItemsWillBeRendered` flag will be `true` but the actual `items`\r\n\t\t// in state wouldn't have changed due to the first `setState()` call being overwritten\r\n\t\t// by the second `setState()` call (that's called \"batching state updates\" in React).\r\n\t\tif (newItems !== previousItems) {\r\n\t\t\tconst itemsDiff = this.getItemsDiff(previousItems, newItems)\r\n\t\t\tif (itemsDiff) {\r\n\t\t\t\t// The call to `.onPrepend()` must precede the call to `.measureItemHeights()`\r\n\t\t\t\t// which is called in `.onRendered()`.\r\n\t\t\t\t// `this.itemHeights.onPrepend()` updates `firstMeasuredItemIndex`\r\n\t\t\t\t// and `lastMeasuredItemIndex` of `this.itemHeights`.\r\n\t\t\t\tconst { prependedItemsCount } = itemsDiff\r\n\t\t\t\tthis.itemHeights.onPrepend(prependedItemsCount)\r\n\t\t\t} else {\r\n\t\t\t\tthis.itemHeights.reset()\r\n\t\t\t\t// `newState.itemHeights` is an array of `undefined`s.\r\n\t\t\t\tthis.itemHeights.initialize(newState.itemHeights)\r\n\t\t\t}\r\n\r\n\t\t\tif (!resetLayoutAfterResize) {\r\n\t\t\t\t// The call to `this.onNewItemsRendered()` must precede the call to\r\n\t\t\t\t// `.measureItemHeights()` which is called in `.onRendered()` because\r\n\t\t\t\t// `this.onNewItemsRendered()` updates `firstMeasuredItemIndex` and\r\n\t\t\t\t// `lastMeasuredItemIndex` of `this.itemHeights` in case of a prepend.\r\n\t\t\t\t//\r\n\t\t\t\t// If after prepending items the scroll position\r\n\t\t\t\t// should be \"restored\" so that there's no \"jump\" of content\r\n\t\t\t\t// then it means that all previous items have just been rendered\r\n\t\t\t\t// in a single pass, and there's no need to update layout again.\r\n\t\t\t\t//\r\n\t\t\t\tif (this.onNewItemsRendered(itemsDiff, newState) !== 'SEAMLESS_PREPEND') {\r\n\t\t\t\t\tlayoutUpdateReason = LAYOUT_REASON.ITEMS_CHANGED\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\tnewState.firstShownItemIndex !== prevState.firstShownItemIndex ||\r\n\t\t\tnewState.lastShownItemIndex !== prevState.lastShownItemIndex ||\r\n\t\t\tnewState.items !== prevState.items ||\r\n\t\t\tresetLayoutAfterResize\r\n\t\t) {\r\n\t\t\tconst verticalSpacingStateUpdate = this.measureItemHeightsAndSpacingAndUpdateTablePadding()\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.setState()` 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(prevState)\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 (layoutUpdateReason) {\r\n\t\t\tthis.updateStateRightAfterRender({\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.setState(stateUpdate)\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 `setState()` 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\tonNewItemsRendered(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 + parseInt(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 + parseInt(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 \"didUpdateState()\" 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.listHeightChangeWatcher.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.listHeightChangeWatcher.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.listHeightChangeWatcher.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 \"didUpdateState()\" 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 \"didUpdateState()\" 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\tupdateStateRightAfterRender({\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// `.setState()` 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\tmeasureVerticalSpacing() {\r\n\t\tif (this.verticalSpacing === undefined) {\r\n\t\t\tconst { firstShownItemIndex, lastShownItemIndex } = this.getState()\r\n\t\t\tlog('~ Measure item vertical spacing ~')\r\n\t\t\tconst verticalSpacing = getVerticalSpacing({\r\n\t\t\t\titemsContainer: this.itemsContainer,\r\n\t\t\t\trenderedItemsCount: lastShownItemIndex - firstShownItemIndex + 1\r\n\t\t\t})\r\n\t\t\tif (verticalSpacing === undefined) {\r\n\t\t\t\tlog('Not enough items rendered to measure vertical spacing')\r\n\t\t\t} else {\r\n\t\t\t\tlog('Item vertical spacing', verticalSpacing)\r\n\t\t\t\tthis.verticalSpacing = verticalSpacing\r\n\t\t\t\tif (verticalSpacing !== 0) {\r\n\t\t\t\t\treturn verticalSpacing\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tremeasureItemHeight(i) {\r\n\t\tconst { firstShownItemIndex } = this.getState()\r\n\t\treturn this.itemHeights.remeasureItemHeight(i, firstShownItemIndex)\r\n\t}\r\n\r\n\tonItemStateChange(i, newItemState) {\r\n\t\tif (isDebug()) {\r\n\t\t\tlog('~ Item state changed ~')\r\n\t\t\tlog('Item', i)\r\n\t\t\t// Uses `JSON.stringify()` here instead of just outputting the JSON objects as is\r\n\t\t\t// because outputting JSON objects as is would show different results later when\r\n\t\t\t// the developer inspects those in the web browser console if those state objects\r\n\t\t\t// get modified in between they've been output to the console and the developer\r\n\t\t\t// decided to inspect them.\r\n\t\t\tlog('Previous state' + '\\n' + JSON.stringify(this.getState().itemStates[i], null, 2))\r\n\t\t\tlog('New state' + '\\n' + JSON.stringify(newItemState, null, 2))\r\n\t\t}\r\n\r\n\t\tthis.getState().itemStates[i] = newItemState\r\n\r\n\t\t// Schedule the item state update for after the new items have been rendered.\r\n\t\tif (this.newItemsWillBeRendered) {\r\n\t\t\tif (!this.itemStatesThatChangedWhileNewItemsWereBeingRendered) {\r\n\t\t\t\tthis.itemStatesThatChangedWhileNewItemsWereBeingRendered = {}\r\n\t\t\t}\r\n\t\t\tthis.itemStatesThatChangedWhileNewItemsWereBeingRendered[String(i)] = newItemState\r\n\t\t}\r\n\t}\r\n\r\n\tonItemHeightChange(i) {\r\n\t\tlog('~ Re-measure item height ~')\r\n\t\tlog('Item', 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 `.onItemHeightChange(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 `.onItemHeightChange(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 `.onItemHeightChange(i)` calls. No issues so far.\r\n\t\t\t// But, as the first `.onItemHeightChange(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 `.onItemHeightChange(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 `.onItemHeightChange(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// `.onItemHeightChange(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 there\\'re several `onItemHeightChange(i)` calls issued at the same time.')\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(`\"onItemHeightChange()\" has been called for item ${i}, but that item hasn't been rendered before.`)\r\n\t\t}\r\n\r\n\t\tconst newHeight = this.remeasureItemHeight(i)\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 ~')\r\n\r\n\t\t\t// Update or reset previously calculated layout.\r\n\t\t\tthis.updatePreviouslyCalculatedLayoutOnItemHeightChange(i, previousHeight, newHeight)\r\n\r\n\t\t\t// Recalculate layout.\r\n\t\t\tthis.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.ITEM_HEIGHT_CHANGED })\r\n\r\n\t\t\t// Schedule the item height update for after the new items have been rendered.\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\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\tupdatePreviouslyCalculatedLayoutOnItemHeightChange(i, previousHeight, newHeight) {\r\n\t\tif (this.previouslyCalculatedLayout) {\r\n\t\t\tconst heightDifference = newHeight - previousHeight\r\n\t\t\tif (i < this.previouslyCalculatedLayout.firstShownItemIndex) {\r\n\t\t\t\t// Patch `this.previouslyCalculatedLayout`'s `.beforeItemsHeight`.\r\n\t\t\t\tthis.previouslyCalculatedLayout.beforeItemsHeight += heightDifference\r\n\t\t\t} else if (i > this.previouslyCalculatedLayout.lastShownItemIndex) {\r\n\t\t\t\t// Could patch `.afterItemsHeight` of `this.previouslyCalculatedLayout` here,\r\n\t\t\t\t// if `.afterItemsHeight` property existed in `this.previouslyCalculatedLayout`.\r\n\t\t\t\tif (this.previouslyCalculatedLayout.afterItemsHeight !== undefined) {\r\n\t\t\t\t\tthis.previouslyCalculatedLayout.afterItemsHeight += heightDifference\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\t// Patch `this.previouslyCalculatedLayout`'s shown items height.\r\n\t\t\t\tthis.previouslyCalculatedLayout.shownItemsHeight += newHeight - previousHeight\r\n\t\t\t}\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 `.onItemStateChange()` and `.onItemHeightChange(i)`.\r\n\t */\r\n\tvalidateWillBeHiddenItemHeightsAreAccurate(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// `.onItemHeightChange(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 `.onItemHeightChange(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 `.onItemHeightChange(i)` calls. No issues so far.\r\n\t\t\t\t// But, as the first `.onItemHeightChange(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 `.onItemHeightChange(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 `.onItemHeightChange(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 = this.remeasureItemHeight(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\tthis.updatePreviouslyCalculatedLayoutOnItemHeightChange(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 `onItemHeightChange(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\tgetShownItemIndexes() {\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} = this.getVisibleArea()\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 * 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\tupdateShownItemIndexes = ({ 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} = this.getShownItemIndexes()\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.listHeightChangeWatcher.hasSnapshot()) {\r\n\t\t\tif (lastShownItemIndex < this.listHeightChangeWatcher.getAnchorItemIndex()) {\r\n\t\t\t\tlastShownItemIndex = this.listHeightChangeWatcher.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 `.onItemStateChange()` and `.onItemHeightChange(i)`.\r\n\t\tif (!this.validateWillBeHiddenItemHeightsAreAccurate(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 this.updateShownItemIndexes({ 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('~ Layout values ' + (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\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 `.onItemHeightChange(i)`.\r\n\t\t\t//\r\n\t\t\t// If, for example, an item height was updated externally via `.onItemHeightChange(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 `setState()` 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.setState({\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\tonUpdateShownItemIndexes = ({ 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.setState(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.resetLayoutAfterResize || 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\tthis.updateShownItemIndexes({ stateUpdate })\r\n\t}\r\n\r\n\tupdateLayout = () => this.onUpdateShownItemIndexes({ reason: LAYOUT_REASON.MANUAL })\r\n\r\n\t// `.layout()` method name is deprecated, use `.updateLayout()` instead.\r\n\tlayout = () => this.updateLayout()\r\n\r\n\t/**\r\n\t * @deprecated\r\n\t * `.updateItems()` has been renamed to `.setItems()`.\r\n\t */\r\n\tupdateItems(newItems, options) {\r\n\t\treturn this.setItems(newItems, options)\r\n\t}\r\n\r\n\t/**\r\n\t * Updates `items`. For example, can prepend or append new items to the list.\r\n\t * @param {any[]} newItems\r\n\t * @param {boolean} [options.preserveScrollPositionOnPrependItems] — Set to `true` to enable \"restore scroll position after prepending items\" feature (could be useful when implementing \"Show previous items\" button).\r\n\t */\r\n\tsetItems(newItems, options = {}) {\r\n\t\t// * @param {object} [newCustomState] — If `customState` was passed to `getInitialState()`, this `newCustomState` updates it.\r\n\t\tconst {\r\n\t\t\titems: previousItems\r\n\t\t} = this.getState()\r\n\r\n\t\t// Even if `newItems` are equal to `this.state.items`,\r\n\t\t// still perform a `setState()` call, because, if `setState()` calls\r\n\t\t// were \"asynchronous\", there could be a situation when a developer\r\n\t\t// first calls `setItems(newItems)` and then `setItems(oldItems)`:\r\n\t\t// if this function did `return` `if (newItems === this.state.items)`\r\n\t\t// then `setState({ items: newItems })` would be scheduled as part of\r\n\t\t// `setItems(newItems)` call, but the subsequent `setItems(oldItems)` call\r\n\t\t// wouldn't do anything resulting in `newItems` being set as a result,\r\n\t\t// and that wouldn't be what the developer intended.\r\n\r\n\t\tlet { itemStates } = this.getState()\r\n\t\tlet { itemHeights } = this.resetLayoutAfterResize\r\n\t\t\t? this.resetLayoutAfterResize.stateUpdate\r\n\t\t\t: this.getState()\r\n\r\n\t\tlog('~ Update items ~')\r\n\r\n\t\tlet layoutUpdate\r\n\t\tlet itemsUpdateInfo\r\n\r\n\t\t// Compare the new items to the current items.\r\n\t\tconst itemsDiff = this.getItemsDiff(previousItems, newItems)\r\n\r\n\t\t// See if it's an \"incremental\" items update.\r\n\t\tif (itemsDiff) {\r\n\t\t\tconst {\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tafterItemsHeight\r\n\t\t\t} = this.resetLayoutAfterResize\r\n\t\t\t\t? this.resetLayoutAfterResize.stateUpdate\r\n\t\t\t\t: this.getState()\r\n\r\n\t\t\tconst shouldRestoreScrollPosition = firstShownItemIndex === 0 &&\r\n\t\t\t\t// `preserveScrollPosition` option name is deprecated,\r\n\t\t\t\t// use `preserveScrollPositionOnPrependItems` instead.\r\n\t\t\t\t(options.preserveScrollPositionOnPrependItems || options.preserveScrollPosition)\r\n\r\n\t\t\tconst {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t} = itemsDiff\r\n\r\n\t\t\tlayoutUpdate = this.layout.getLayoutUpdateForItemsDiff({\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tafterItemsHeight\r\n\t\t\t}, {\r\n\t\t\t\tprependedItemsCount,\r\n\t\t\t\tappendedItemsCount\r\n\t\t\t}, {\r\n\t\t\t\titemsCount: newItems.length,\r\n\t\t\t\tcolumnsCount: this.getActualColumnsCount(),\r\n\t\t\t\tshouldRestoreScrollPosition\r\n\t\t\t})\r\n\r\n\t\t\tif (prependedItemsCount > 0) {\r\n\t\t\t\tlog('Prepend', prependedItemsCount, 'items')\r\n\r\n\t\t\t\titemHeights = new Array(prependedItemsCount).concat(itemHeights)\r\n\r\n\t\t\t\tif (itemStates) {\r\n\t\t\t\t\titemStates = new Array(prependedItemsCount).concat(itemStates)\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Restore scroll position after prepending items (if requested).\r\n\t\t\t\tif (shouldRestoreScrollPosition) {\r\n\t\t\t\t\tlog('Will restore scroll position')\r\n\t\t\t\t\tthis.listHeightChangeWatcher.snapshot({\r\n\t\t\t\t\t\tpreviousItems,\r\n\t\t\t\t\t\tnewItems,\r\n\t\t\t\t\t\tprependedItemsCount\r\n\t\t\t\t\t})\r\n\t\t\t\t\t// \"Seamless prepend\" scenario doesn't result in a re-layout,\r\n\t\t\t\t\t// so if any \"non measured item\" is currently pending,\r\n\t\t\t\t\t// it doesn't get reset and will be handled after `state` is updated.\r\n\t\t\t\t\tif (this.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\t\t\t\tthis.firstNonMeasuredItemIndex += prependedItemsCount\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\tlog('Reset layout')\r\n\t\t\t\t\t// Reset layout because none of the prepended items have been measured.\r\n\t\t\t\t\tlayoutUpdate = this.layout.getInitialLayoutValues({\r\n\t\t\t\t\t\titemsCount: newItems.length,\r\n\t\t\t\t\t\tcolumnsCount: this.getActualColumnsCount()\r\n\t\t\t\t\t})\r\n\t\t\t\t\t// Unschedule a potentially scheduled layout update\r\n\t\t\t\t\t// after measuring a previously non-measured item\r\n\t\t\t\t\t// because the list will be re-layout anyway\r\n\t\t\t\t\t// due to the new items being set.\r\n\t\t\t\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (appendedItemsCount > 0) {\r\n\t\t\t\tlog('Append', appendedItemsCount, 'items')\r\n\t\t\t\titemHeights = itemHeights.concat(new Array(appendedItemsCount))\r\n\t\t\t\tif (itemStates) {\r\n\t\t\t\t\titemStates = itemStates.concat(new Array(appendedItemsCount))\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\titemsUpdateInfo = {\r\n\t\t\t\tprepend: prependedItemsCount > 0,\r\n\t\t\t\tappend: appendedItemsCount > 0\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tlog('Items have changed, and', (itemsDiff ? 'a re-layout from scratch has been requested.' : 'it\\'s not a simple append and/or prepend.'), 'Rerender the entire list from scratch.')\r\n\t\t\tlog('Previous items', previousItems)\r\n\t\t\tlog('New items', newItems)\r\n\r\n\t\t\t// Reset item heights and item states.\r\n\t\t\titemHeights = new Array(newItems.length)\r\n\t\t\titemStates = new Array(newItems.length)\r\n\r\n\t\t\tlayoutUpdate = this.layout.getInitialLayoutValues({\r\n\t\t\t\titemsCount: newItems.length,\r\n\t\t\t\tcolumnsCount: this.getActualColumnsCount()\r\n\t\t\t})\r\n\r\n\t\t\t// Unschedule a potentially scheduled layout update\r\n\t\t\t// after measuring a previously non-measured item\r\n\t\t\t// because the list will be re-layout from scratch\r\n\t\t\t// due to the new items being set.\r\n\t\t\tthis.firstNonMeasuredItemIndex = undefined\r\n\r\n\t\t\t// Also reset any potential pending scroll position restoration.\r\n\t\t\t// For example, imagine a developer first called `.setItems(incrementalItemsUpdate)`\r\n\t\t\t// and then called `.setItems(differentItems)` and there was no state update\r\n\t\t\t// in between those two calls. This could happen because state updates aren't\r\n\t\t\t// required to be \"synchronous\". On other words, calling `this.setState()`\r\n\t\t\t// doesn't necessarily mean that the state is applied immediately.\r\n\t\t\t// Imagine also that such \"delayed\" state updates could be batched,\r\n\t\t\t// like they do in React inside event handlers (though that doesn't apply to this case):\r\n\t\t\t// https://github.com/facebook/react/issues/10231#issuecomment-316644950\r\n\t\t\t// If `this.listHeightChangeWatcher` wasn't reset on `.setItems(differentItems)`\r\n\t\t\t// and if the second `this.setState()` call overwrites the first one\r\n\t\t\t// then it would attempt to restore scroll position in a situation when\r\n\t\t\t// it should no longer do that. Hence the reset here.\r\n\t\t\tthis.listHeightChangeWatcher.reset()\r\n\r\n\t\t\titemsUpdateInfo = {\r\n\t\t\t\treplace: true\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tlog('~ Update state ~')\r\n\r\n\t\t// const layoutValuesAfterUpdate = {\r\n\t\t// \t...this.getState(),\r\n\t\t// \t...layoutUpdate\r\n\t\t// }\r\n\r\n\t\t// `layoutUpdate` is equivalent to `layoutValuesAfterUpdate` because\r\n\t\t// `layoutUpdate` contains all the relevant properties.\r\n\t\tlog('First shown item index', layoutUpdate.firstShownItemIndex)\r\n\t\tlog('Last shown item index', layoutUpdate.lastShownItemIndex)\r\n\t\tlog('Before items height', layoutUpdate.beforeItemsHeight)\r\n\t\tlog('After items height (actual or estimated)', layoutUpdate.afterItemsHeight)\r\n\r\n\t\t// Optionally preload items to be rendered.\r\n\t\t//\r\n\t\t// `layoutUpdate` is equivalent to `layoutValuesAfterUpdate` because\r\n\t\t// `layoutUpdate` contains all the relevant properties.\r\n\t\t//\r\n\t\tthis.onBeforeShowItems(\r\n\t\t\tnewItems,\r\n\t\t\titemHeights,\r\n\t\t\tlayoutUpdate.firstShownItemIndex,\r\n\t\t\tlayoutUpdate.lastShownItemIndex\r\n\t\t)\r\n\r\n\t\t// `this.newItemsWillBeRendered` signals that new `items` are being rendered,\r\n\t\t// and that `VirtualScroller` should temporarily stop all other updates.\r\n\t\t//\r\n\t\t// `this.newItemsWillBeRendered` is cleared in `didUpdateState()`.\r\n\t\t//\r\n\t\t// The values in `this.newItemsWillBeRendered` are used, for example,\r\n\t\t// in `.onResize()` handler in order to not break state consistency when\r\n\t\t// state updates are \"asynchronous\" (delayed) and there's a window resize event\r\n\t\t// in between calling `setState()` below and that call actually being applied.\r\n\t\t//\r\n\t\tthis.newItemsWillBeRendered = {\r\n\t\t\t...itemsUpdateInfo,\r\n\t\t\tcount: newItems.length,\r\n\t\t\t// `layoutUpdate` now contains all layout-related properties, even if those that\r\n\t\t\t// didn't change. So `firstShownItemIndex` is always in `this.newItemsWillBeRendered`.\r\n\t\t\tlayout: layoutUpdate\r\n\t\t}\r\n\r\n\t\t// `layoutUpdate` now contains all layout-related properties, even if those that\r\n\t\t// didn't change. So this part is no longer relevant.\r\n\t\t//\r\n\t\t// // If `firstShownItemIndex` is gonna be modified as a result of setting new items\r\n\t\t// // then keep that \"new\" `firstShownItemIndex` in order for it to be used by\r\n\t\t// // `onResize()` handler when it calculates \"new\" `firstShownItemIndex`\r\n\t\t// // based on the new columns count (corresponding to the new window width).\r\n\t\t// if (layoutUpdate.firstShownItemIndex !== undefined) {\r\n\t\t// \tthis.newItemsWillBeRendered = {\r\n\t\t// \t\t...this.newItemsWillBeRendered,\r\n\t\t// \t\tfirstShownItemIndex: layoutUpdate.firstShownItemIndex\r\n\t\t// \t}\r\n\t\t// }\r\n\r\n\t\t// Update `VirtualScroller` state.\r\n\t\t//\r\n\t\t// This state update should overwrite all the `state` properties\r\n\t\t// that are also updated in the \"on scroll\" handler (`getShownItemIndexes()`):\r\n\t\t//\r\n\t\t// * `firstShownItemIndex`\r\n\t\t// * `lastShownItemIndex`\r\n\t\t// * `beforeItemsHeight`\r\n\t\t// * `afterItemsHeight`\r\n\t\t//\r\n\t\t// That's because this `setState()` update has a higher priority\r\n\t\t// than that of the \"on scroll\" handler, so it should overwrite\r\n\t\t// any potential state changes dispatched by the \"on scroll\" handler.\r\n\t\t//\r\n\t\tconst newState = {\r\n\t\t\t// ...customState,\r\n\t\t\t...layoutUpdate,\r\n\t\t\titems: newItems,\r\n\t\t\titemStates,\r\n\t\t\titemHeights\r\n\t\t}\r\n\r\n\t\t// Introduced `shouldIncludeBeforeResizeValuesInState()` getter just to prevent\r\n\t\t// cluttering `state` with `beforeResize: undefined` property if `beforeResize`\r\n\t\t// hasn't ever been set in `state` previously.\r\n\t\tif (this.beforeResize.shouldIncludeBeforeResizeValuesInState()) {\r\n\t\t\tif (this.shouldDiscardBeforeResizeItemHeights()) {\r\n\t\t\t\t// Reset \"before resize\" item heights because now there're new items prepended\r\n\t\t\t\t// with unknown heights, or completely new items with unknown heights, so\r\n\t\t\t\t// `beforeItemsHeight` value won't be preserved anyway.\r\n\t\t\t\tnewState.beforeResize = undefined\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\t// Overwrite `beforeResize` property in `state` even if it wasn't modified\r\n\t\t\t\t// because state updates could be \"asynchronous\" and in that case there could be\r\n\t\t\t\t// some previous `setState()` call from some previous `setItems()` call that\r\n\t\t\t\t// hasn't yet been applied, and that previous call might have scheduled setting\r\n\t\t\t\t// `state.beforeResize` property to `undefined` in order to reset it, but this\r\n\t\t\t\t// next `setState()` call might not require resetting `state.beforeResize` property\r\n\t\t\t\t// so it should undo resetting it by simply overwriting it with its normal value.\r\n\t\t\t\tnewState.beforeResize = this.resetLayoutAfterResize\r\n\t\t\t\t\t? this.resetLayoutAfterResize.stateUpdate.beforeResize\r\n\t\t\t\t\t: this.getState().beforeResize\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `newState` should also overwrite all `state` properties that're updated in `onResize()`\r\n\t\t// because `setItems()`'s state updates always overwrite `onResize()`'s state updates.\r\n\t\t// (The least-priority ones are `onScroll()` state updates, but those're simply skipped\r\n\t\t// if there's a pending `setItems()` or `onResize()` update).\r\n\t\t//\r\n\t\t// `state` property exceptions:\r\n\t\t//\r\n\t\t// `verticalSpacing` property is not updated here because it's fine setting it to\r\n\t\t// `undefined` in `onResize()` — it will simply be re-measured after the component re-renders.\r\n\t\t//\r\n\t\t// `columnsCount` property is also not updated here because by definition it's only\r\n\t\t// updated in `onResize()`.\r\n\r\n\t\t// Render.\r\n\t\tthis.setState(newState)\r\n\t}\r\n\r\n\tgetItemsDiff(previousItems, newItems) {\r\n\t\treturn getItemsDiff(previousItems, newItems, this.isItemEqual)\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 `setState()` 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\tshouldDiscardBeforeResizeItemHeights() {\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\r\n\tonResize() {\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.listHeightChangeWatcher.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 `setState()` operation is \"asynchronous\", that is\r\n\t\t// when `setState()` 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 `setState()` operation is \"asynchronous\", that is\r\n\t\t// when `setState()` 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\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 `setState()` 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.ceil((lastShownItemIndex + 1) / newColumnsCount) * newColumnsCount - 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\" `setState()` call, and then, before that\r\n\t\t// `setState()` 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.resetLayoutAfterResize` 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 `didUpdateState()`\r\n\t\t// function will clear this flag and perform a re-layout.\r\n\t\tthis.resetLayoutAfterResize = {\r\n\t\t\tstateUpdate: newState\r\n\t\t}\r\n\r\n\t\t// Rerender.\r\n\t\tthis.setState(newState)\r\n\t}\r\n}\r\n\r\nconst SLOW_LAYOUT_DURATION = 15 // in milliseconds."],"file":"VirtualScroller.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../source/getItemCoordinates.js"],"names":["getItemCoordinates","i","itemHeights","columnsCount","verticalSpacing","listTopOffsetInsideScrollableContainer","rowTop","itemRowIndex","Math","floor","rowIndex","rowHeight","columnIndex","itemHeight","undefined","max","top","bottom","height"],"mappings":"AAAA;;AAEA;;;;;;;;AAQA,eAAe,SAASA,kBAAT,CAA4BC,CAA5B,QAKZ;AAAA,MAJFC,WAIE,QAJFA,WAIE;AAAA,MAHFC,YAGE,QAHFA,YAGE;AAAA,MAFFC,eAEE,QAFFA,eAEE;AAAA,MADFC,sCACE,QADFA,sCACE;AACF,MAAIC,MAAM,GAAGD,sCAAb;AACA,MAAME,YAAY,GAAGC,IAAI,CAACC,KAAL,CAAWR,CAAC,GAAGE,YAAf,CAArB;AACA,MAAIO,QAAQ,GAAG,CAAf;;AACA,SAAOA,QAAQ,GAAGH,YAAlB,EAAgC;AAC/B,QAAII,SAAS,GAAG,CAAhB;AACA,QAAIC,WAAW,GAAG,CAAlB;;AACA,WAAOA,WAAW,GAAGT,YAArB,EAAmC;AAClC,UAAMU,UAAU,GAAGX,WAAW,CAACQ,QAAQ,GAAGP,YAAX,GAA0BS,WAA3B,CAA9B;;AACA,UAAIC,UAAU,KAAKC,SAAnB,EAA8B;AAC7B;AACA;;AACDH,MAAAA,SAAS,GAAGH,IAAI,CAACO,GAAL,CAASJ,SAAT,EAAoBE,UAApB,CAAZ;AACAD,MAAAA,WAAW;AACX;;AACDN,IAAAA,MAAM,IAAIK,SAAV;AACAL,IAAAA,MAAM,IAAIF,eAAV;AACAM,IAAAA,QAAQ;AACR;;AACD,SAAO;AACNM,IAAAA,GAAG,EAAEV,MADC;AAENW,IAAAA,MAAM,EAAEX,MAAM,GAAGJ,WAAW,CAACD,CAAD,CAFtB;AAGNiB,IAAAA,MAAM,EAAEhB,WAAW,CAACD,CAAD;AAHb,GAAP;AAKA","sourcesContent":["// This function isn't currenly used.\r\n\r\n/**\r\n * Returns coordinates of item with index `i` relative to the document.\r\n * `top` is the top offset of the item relative to the start of the document.\r\n * `bottom` is the top offset of the item's bottom edge relative to the start of the document.\r\n * `height` is the item's height.\r\n * @param {number} i\r\n * @return {object} [coordinates] — An object of shape `{ top, bottom, height }`. Returns `undefined` if some of the items along the way haven't been measured.\r\n */\r\nexport default function getItemCoordinates(i, {\r\n\titemHeights,\r\n\tcolumnsCount,\r\n\tverticalSpacing,\r\n\tlistTopOffsetInsideScrollableContainer\r\n}) {\r\n\tlet rowTop = listTopOffsetInsideScrollableContainer\r\n\tconst itemRowIndex = Math.floor(i / columnsCount)\r\n\tlet rowIndex = 0\r\n\twhile (rowIndex < itemRowIndex) {\r\n\t\tlet rowHeight = 0\r\n\t\tlet columnIndex = 0\r\n\t\twhile (columnIndex < columnsCount) {\r\n\t\t\tconst itemHeight = itemHeights[rowIndex * columnsCount + columnIndex]\r\n\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\tcolumnIndex++\r\n\t\t}\r\n\t\trowTop += rowHeight\r\n\t\trowTop += verticalSpacing\r\n\t\trowIndex++\r\n\t}\r\n\treturn {\r\n\t\ttop: rowTop,\r\n\t\tbottom: rowTop + itemHeights[i],\r\n\t\theight: itemHeights[i]\r\n\t}\r\n}"],"file":"getItemCoordinates.js"}
1
+ {"version":3,"sources":["../source/getItemCoordinates.js"],"names":["getItemCoordinates","i","itemHeights","columnsCount","verticalSpacing","listTopOffsetInsideScrollableContainer","rowTop","itemRowIndex","Math","floor","rowIndex","rowHeight","columnIndex","itemHeight","undefined","max","top","bottom","height"],"mappings":"AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,kBAAT,CAA4BC,CAA5B,QAKZ;AAAA,MAJFC,WAIE,QAJFA,WAIE;AAAA,MAHFC,YAGE,QAHFA,YAGE;AAAA,MAFFC,eAEE,QAFFA,eAEE;AAAA,MADFC,sCACE,QADFA,sCACE;AACF,MAAIC,MAAM,GAAGD,sCAAb;AACA,MAAME,YAAY,GAAGC,IAAI,CAACC,KAAL,CAAWR,CAAC,GAAGE,YAAf,CAArB;AACA,MAAIO,QAAQ,GAAG,CAAf;;AACA,SAAOA,QAAQ,GAAGH,YAAlB,EAAgC;AAC/B,QAAII,SAAS,GAAG,CAAhB;AACA,QAAIC,WAAW,GAAG,CAAlB;;AACA,WAAOA,WAAW,GAAGT,YAArB,EAAmC;AAClC,UAAMU,UAAU,GAAGX,WAAW,CAACQ,QAAQ,GAAGP,YAAX,GAA0BS,WAA3B,CAA9B;;AACA,UAAIC,UAAU,KAAKC,SAAnB,EAA8B;AAC7B;AACA;;AACDH,MAAAA,SAAS,GAAGH,IAAI,CAACO,GAAL,CAASJ,SAAT,EAAoBE,UAApB,CAAZ;AACAD,MAAAA,WAAW;AACX;;AACDN,IAAAA,MAAM,IAAIK,SAAV;AACAL,IAAAA,MAAM,IAAIF,eAAV;AACAM,IAAAA,QAAQ;AACR;;AACD,SAAO;AACNM,IAAAA,GAAG,EAAEV,MADC;AAENW,IAAAA,MAAM,EAAEX,MAAM,GAAGJ,WAAW,CAACD,CAAD,CAFtB;AAGNiB,IAAAA,MAAM,EAAEhB,WAAW,CAACD,CAAD;AAHb,GAAP;AAKA","sourcesContent":["// This function isn't currenly used.\r\n\r\n/**\r\n * Returns coordinates of item with index `i` relative to the document.\r\n * `top` is the top offset of the item relative to the start of the document.\r\n * `bottom` is the top offset of the item's bottom edge relative to the start of the document.\r\n * `height` is the item's height.\r\n * @param {number} i\r\n * @return {object} [coordinates] — An object of shape `{ top, bottom, height }`. Returns `undefined` if some of the items along the way haven't been measured.\r\n */\r\nexport default function getItemCoordinates(i, {\r\n\titemHeights,\r\n\tcolumnsCount,\r\n\tverticalSpacing,\r\n\tlistTopOffsetInsideScrollableContainer\r\n}) {\r\n\tlet rowTop = listTopOffsetInsideScrollableContainer\r\n\tconst itemRowIndex = Math.floor(i / columnsCount)\r\n\tlet rowIndex = 0\r\n\twhile (rowIndex < itemRowIndex) {\r\n\t\tlet rowHeight = 0\r\n\t\tlet columnIndex = 0\r\n\t\twhile (columnIndex < columnsCount) {\r\n\t\t\tconst itemHeight = itemHeights[rowIndex * columnsCount + columnIndex]\r\n\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\tcolumnIndex++\r\n\t\t}\r\n\t\trowTop += rowHeight\r\n\t\trowTop += verticalSpacing\r\n\t\trowIndex++\r\n\t}\r\n\treturn {\r\n\t\ttop: rowTop,\r\n\t\tbottom: rowTop + itemHeights[i],\r\n\t\theight: itemHeights[i]\r\n\t}\r\n}"],"file":"getItemCoordinates.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../source/getItemsDiff.js"],"names":["getItemsDiff","previousItems","newItems","isEqual","firstPreviousItemIndex","lastPreviousItemIndex","length","findInArray","arePreviousItemsPreserved","isIncrementalUpdate","prependedItemsCount","appendedItemsCount","offset","i","array","element"],"mappings":"AAAA;;;;;;AAMA,eAAe,SAASA,YAAT,CAAsBC,aAAtB,EAAqCC,QAArC,EAA+CC,OAA/C,EAAwD;AACtE,MAAIC,sBAAsB,GAAG,CAAC,CAA9B;AACA,MAAIC,qBAAqB,GAAG,CAAC,CAA7B;;AACA,MAAIJ,aAAa,CAACK,MAAd,GAAuB,CAA3B,EAA8B;AAC7BF,IAAAA,sBAAsB,GAAGG,WAAW,CAACL,QAAD,EAAWD,aAAa,CAAC,CAAD,CAAxB,EAA6BE,OAA7B,CAApC;;AACA,QAAIC,sBAAsB,IAAI,CAA9B,EAAiC;AAChC,UAAII,yBAAyB,CAACP,aAAD,EAAgBC,QAAhB,EAA0BE,sBAA1B,EAAkDD,OAAlD,CAA7B,EAAyF;AACxFE,QAAAA,qBAAqB,GAAGD,sBAAsB,GAAGH,aAAa,CAACK,MAAvC,GAAgD,CAAxE;AACA;AACD;AACD;;AACD,MAAMG,mBAAmB,GAAGL,sBAAsB,IAAI,CAA1B,IAA+BC,qBAAqB,IAAI,CAApF;;AACA,MAAII,mBAAJ,EAAyB;AACxB,WAAO;AACNC,MAAAA,mBAAmB,EAAEN,sBADf;AAENO,MAAAA,kBAAkB,EAAET,QAAQ,CAACI,MAAT,IAAmBD,qBAAqB,GAAG,CAA3C;AAFd,KAAP;AAIA;AACD;;AAED,SAASG,yBAAT,CAAmCP,aAAnC,EAAkDC,QAAlD,EAA4DU,MAA5D,EAAoET,OAApE,EAA6E;AAC5E;AACA;AACA;AACA,MAAIU,CAAC,GAAG,CAAR;;AACA,SAAOA,CAAC,GAAGZ,aAAa,CAACK,MAAzB,EAAiC;AAChC,QAAIJ,QAAQ,CAACI,MAAT,IAAmBM,MAAM,GAAGC,CAA5B,IACH,CAACV,OAAO,CAACD,QAAQ,CAACU,MAAM,GAAGC,CAAV,CAAT,EAAuBZ,aAAa,CAACY,CAAD,CAApC,CADT,EACmD;AAClD,aAAO,KAAP;AACA;;AACDA,IAAAA,CAAC;AACD;;AACD,SAAO,IAAP;AACA;;AAED,SAASN,WAAT,CAAqBO,KAArB,EAA4BC,OAA5B,EAAqCZ,OAArC,EAA8C;AAC7C,MAAIU,CAAC,GAAG,CAAR;;AACA,SAAOA,CAAC,GAAGC,KAAK,CAACR,MAAjB,EAAyB;AACxB,QAAIH,OAAO,CAACW,KAAK,CAACD,CAAD,CAAN,EAAWE,OAAX,CAAX,EAAgC;AAC/B,aAAOF,CAAP;AACA;;AACDA,IAAAA,CAAC;AACD;;AACD,SAAO,CAAC,CAAR;AACA","sourcesContent":["/**\r\n * Checks whether it's an \"incremental\" items update, and returns the \"diff\".\r\n * @param {any[]} previousItems\r\n * @param {any[]} newItems\r\n * @return {object} [diff]\r\n */\r\nexport default function getItemsDiff(previousItems, newItems, isEqual) {\r\n\tlet firstPreviousItemIndex = -1\r\n\tlet lastPreviousItemIndex = -1\r\n\tif (previousItems.length > 0) {\r\n\t\tfirstPreviousItemIndex = findInArray(newItems, previousItems[0], isEqual)\r\n\t\tif (firstPreviousItemIndex >= 0) {\r\n\t\t\tif (arePreviousItemsPreserved(previousItems, newItems, firstPreviousItemIndex, isEqual)) {\r\n\t\t\t\tlastPreviousItemIndex = firstPreviousItemIndex + previousItems.length - 1\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tconst isIncrementalUpdate = firstPreviousItemIndex >= 0 && lastPreviousItemIndex >= 0\r\n\tif (isIncrementalUpdate) {\r\n\t\treturn {\r\n\t\t\tprependedItemsCount: firstPreviousItemIndex,\r\n\t\t\tappendedItemsCount: newItems.length - (lastPreviousItemIndex + 1)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction arePreviousItemsPreserved(previousItems, newItems, offset, isEqual) {\r\n\t// Check each item of the `previousItems` to determine\r\n\t// whether it's an \"incremental\" items update.\r\n\t// (an update when items are prepended or appended)\r\n\tlet i = 0\r\n\twhile (i < previousItems.length) {\r\n\t\tif (newItems.length <= offset + i ||\r\n\t\t\t!isEqual(newItems[offset + i], previousItems[i])) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\ti++\r\n\t}\r\n\treturn true\r\n}\r\n\r\nfunction findInArray(array, element, isEqual) {\r\n\tlet i = 0\r\n\twhile (i < array.length) {\r\n\t\tif (isEqual(array[i], element)) {\r\n\t\t\treturn i\r\n\t\t}\r\n\t\ti++\r\n\t}\r\n\treturn -1\r\n}"],"file":"getItemsDiff.js"}
1
+ {"version":3,"sources":["../source/getItemsDiff.js"],"names":["getItemsDiff","previousItems","newItems","isEqual","firstPreviousItemIndex","lastPreviousItemIndex","length","findInArray","arePreviousItemsPreserved","isIncrementalUpdate","prependedItemsCount","appendedItemsCount","offset","i","array","element"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,YAAT,CAAsBC,aAAtB,EAAqCC,QAArC,EAA+CC,OAA/C,EAAwD;AACtE,MAAIC,sBAAsB,GAAG,CAAC,CAA9B;AACA,MAAIC,qBAAqB,GAAG,CAAC,CAA7B;;AACA,MAAIJ,aAAa,CAACK,MAAd,GAAuB,CAA3B,EAA8B;AAC7BF,IAAAA,sBAAsB,GAAGG,WAAW,CAACL,QAAD,EAAWD,aAAa,CAAC,CAAD,CAAxB,EAA6BE,OAA7B,CAApC;;AACA,QAAIC,sBAAsB,IAAI,CAA9B,EAAiC;AAChC,UAAII,yBAAyB,CAACP,aAAD,EAAgBC,QAAhB,EAA0BE,sBAA1B,EAAkDD,OAAlD,CAA7B,EAAyF;AACxFE,QAAAA,qBAAqB,GAAGD,sBAAsB,GAAGH,aAAa,CAACK,MAAvC,GAAgD,CAAxE;AACA;AACD;AACD;;AACD,MAAMG,mBAAmB,GAAGL,sBAAsB,IAAI,CAA1B,IAA+BC,qBAAqB,IAAI,CAApF;;AACA,MAAII,mBAAJ,EAAyB;AACxB,WAAO;AACNC,MAAAA,mBAAmB,EAAEN,sBADf;AAENO,MAAAA,kBAAkB,EAAET,QAAQ,CAACI,MAAT,IAAmBD,qBAAqB,GAAG,CAA3C;AAFd,KAAP;AAIA;AACD;;AAED,SAASG,yBAAT,CAAmCP,aAAnC,EAAkDC,QAAlD,EAA4DU,MAA5D,EAAoET,OAApE,EAA6E;AAC5E;AACA;AACA;AACA,MAAIU,CAAC,GAAG,CAAR;;AACA,SAAOA,CAAC,GAAGZ,aAAa,CAACK,MAAzB,EAAiC;AAChC,QAAIJ,QAAQ,CAACI,MAAT,IAAmBM,MAAM,GAAGC,CAA5B,IACH,CAACV,OAAO,CAACD,QAAQ,CAACU,MAAM,GAAGC,CAAV,CAAT,EAAuBZ,aAAa,CAACY,CAAD,CAApC,CADT,EACmD;AAClD,aAAO,KAAP;AACA;;AACDA,IAAAA,CAAC;AACD;;AACD,SAAO,IAAP;AACA;;AAED,SAASN,WAAT,CAAqBO,KAArB,EAA4BC,OAA5B,EAAqCZ,OAArC,EAA8C;AAC7C,MAAIU,CAAC,GAAG,CAAR;;AACA,SAAOA,CAAC,GAAGC,KAAK,CAACR,MAAjB,EAAyB;AACxB,QAAIH,OAAO,CAACW,KAAK,CAACD,CAAD,CAAN,EAAWE,OAAX,CAAX,EAAgC;AAC/B,aAAOF,CAAP;AACA;;AACDA,IAAAA,CAAC;AACD;;AACD,SAAO,CAAC,CAAR;AACA","sourcesContent":["/**\r\n * Checks whether it's an \"incremental\" items update, and returns the \"diff\".\r\n * @param {any[]} previousItems\r\n * @param {any[]} newItems\r\n * @return {object} [diff]\r\n */\r\nexport default function getItemsDiff(previousItems, newItems, isEqual) {\r\n\tlet firstPreviousItemIndex = -1\r\n\tlet lastPreviousItemIndex = -1\r\n\tif (previousItems.length > 0) {\r\n\t\tfirstPreviousItemIndex = findInArray(newItems, previousItems[0], isEqual)\r\n\t\tif (firstPreviousItemIndex >= 0) {\r\n\t\t\tif (arePreviousItemsPreserved(previousItems, newItems, firstPreviousItemIndex, isEqual)) {\r\n\t\t\t\tlastPreviousItemIndex = firstPreviousItemIndex + previousItems.length - 1\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tconst isIncrementalUpdate = firstPreviousItemIndex >= 0 && lastPreviousItemIndex >= 0\r\n\tif (isIncrementalUpdate) {\r\n\t\treturn {\r\n\t\t\tprependedItemsCount: firstPreviousItemIndex,\r\n\t\t\tappendedItemsCount: newItems.length - (lastPreviousItemIndex + 1)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nfunction arePreviousItemsPreserved(previousItems, newItems, offset, isEqual) {\r\n\t// Check each item of the `previousItems` to determine\r\n\t// whether it's an \"incremental\" items update.\r\n\t// (an update when items are prepended or appended)\r\n\tlet i = 0\r\n\twhile (i < previousItems.length) {\r\n\t\tif (newItems.length <= offset + i ||\r\n\t\t\t!isEqual(newItems[offset + i], previousItems[i])) {\r\n\t\t\treturn false\r\n\t\t}\r\n\t\ti++\r\n\t}\r\n\treturn true\r\n}\r\n\r\nfunction findInArray(array, element, isEqual) {\r\n\tlet i = 0\r\n\twhile (i < array.length) {\r\n\t\tif (isEqual(array[i], element)) {\r\n\t\t\treturn i\r\n\t\t}\r\n\t\ti++\r\n\t}\r\n\treturn -1\r\n}"],"file":"getItemsDiff.js"}
@@ -1,15 +1,15 @@
1
1
  export default function getVerticalSpacing(_ref) {
2
- var container = _ref.container,
3
- screen = _ref.screen;
2
+ var itemsContainer = _ref.itemsContainer,
3
+ renderedItemsCount = _ref.renderedItemsCount;
4
4
 
5
- if (screen.getChildElementsCount(container) > 1) {
6
- var firstShownRowTopOffset = screen.getChildElementTopOffset(container, 0);
7
- var firstShownRowHeight = screen.getChildElementHeight(container, 0);
5
+ if (renderedItemsCount > 1) {
6
+ var firstShownRowTopOffset = itemsContainer.getNthRenderedItemTopOffset(0);
7
+ var firstShownRowHeight = itemsContainer.getNthRenderedItemHeight(0);
8
8
  var i = 1;
9
9
 
10
- while (i < screen.getChildElementsCount(container)) {
11
- var itemTopOffset = screen.getChildElementTopOffset(container, i);
12
- var itemHeight = screen.getChildElementHeight(container, i); // If next row is detected.
10
+ while (i < renderedItemsCount) {
11
+ var itemTopOffset = itemsContainer.getNthRenderedItemTopOffset(i);
12
+ var itemHeight = itemsContainer.getNthRenderedItemHeight(i); // If next row is detected.
13
13
 
14
14
  if (itemTopOffset !== firstShownRowTopOffset) {
15
15
  // Measure inter-row spacing.
@@ -1 +1 @@
1
- {"version":3,"sources":["../source/getVerticalSpacing.js"],"names":["getVerticalSpacing","container","screen","getChildElementsCount","firstShownRowTopOffset","getChildElementTopOffset","firstShownRowHeight","getChildElementHeight","i","itemTopOffset","itemHeight","Math","max"],"mappings":"AAAA,eAAe,SAASA,kBAAT,OAAmD;AAAA,MAArBC,SAAqB,QAArBA,SAAqB;AAAA,MAAVC,MAAU,QAAVA,MAAU;;AACjE,MAAIA,MAAM,CAACC,qBAAP,CAA6BF,SAA7B,IAA0C,CAA9C,EAAiD;AAChD,QAAMG,sBAAsB,GAAGF,MAAM,CAACG,wBAAP,CAAgCJ,SAAhC,EAA2C,CAA3C,CAA/B;AACA,QAAIK,mBAAmB,GAAGJ,MAAM,CAACK,qBAAP,CAA6BN,SAA7B,EAAwC,CAAxC,CAA1B;AACA,QAAIO,CAAC,GAAG,CAAR;;AACA,WAAOA,CAAC,GAAGN,MAAM,CAACC,qBAAP,CAA6BF,SAA7B,CAAX,EAAoD;AACnD,UAAMQ,aAAa,GAAGP,MAAM,CAACG,wBAAP,CAAgCJ,SAAhC,EAA2CO,CAA3C,CAAtB;AACA,UAAME,UAAU,GAAGR,MAAM,CAACK,qBAAP,CAA6BN,SAA7B,EAAwCO,CAAxC,CAAnB,CAFmD,CAGnD;;AACA,UAAIC,aAAa,KAAKL,sBAAtB,EAA8C;AAC7C;AACA,eAAOK,aAAa,IAAIL,sBAAsB,GAAGE,mBAA7B,CAApB;AACA,OAPkD,CAQnD;;;AACAA,MAAAA,mBAAmB,GAAGK,IAAI,CAACC,GAAL,CAASN,mBAAT,EAA8BI,UAA9B,CAAtB;AACAF,MAAAA,CAAC;AACD;AACD;AACD","sourcesContent":["export default function getVerticalSpacing({ container, screen }) {\r\n\tif (screen.getChildElementsCount(container) > 1) {\r\n\t\tconst firstShownRowTopOffset = screen.getChildElementTopOffset(container, 0)\r\n\t\tlet firstShownRowHeight = screen.getChildElementHeight(container, 0)\r\n\t\tlet i = 1\r\n\t\twhile (i < screen.getChildElementsCount(container)) {\r\n\t\t\tconst itemTopOffset = screen.getChildElementTopOffset(container, i)\r\n\t\t\tconst itemHeight = screen.getChildElementHeight(container, i)\r\n\t\t\t// If next row is detected.\r\n\t\t\tif (itemTopOffset !== firstShownRowTopOffset) {\r\n\t\t\t\t// Measure inter-row spacing.\r\n\t\t\t\treturn itemTopOffset - (firstShownRowTopOffset + firstShownRowHeight)\r\n\t\t\t}\r\n\t\t\t// A row height is the maximum of its item heights.\r\n\t\t\tfirstShownRowHeight = Math.max(firstShownRowHeight, itemHeight)\r\n\t\t\ti++\r\n\t\t}\r\n\t}\r\n}"],"file":"getVerticalSpacing.js"}
1
+ {"version":3,"sources":["../source/getVerticalSpacing.js"],"names":["getVerticalSpacing","itemsContainer","renderedItemsCount","firstShownRowTopOffset","getNthRenderedItemTopOffset","firstShownRowHeight","getNthRenderedItemHeight","i","itemTopOffset","itemHeight","Math","max"],"mappings":"AAAA,eAAe,SAASA,kBAAT,OAAoE;AAAA,MAAtCC,cAAsC,QAAtCA,cAAsC;AAAA,MAAtBC,kBAAsB,QAAtBA,kBAAsB;;AAClF,MAAIA,kBAAkB,GAAG,CAAzB,EAA4B;AAC3B,QAAMC,sBAAsB,GAAGF,cAAc,CAACG,2BAAf,CAA2C,CAA3C,CAA/B;AACA,QAAIC,mBAAmB,GAAGJ,cAAc,CAACK,wBAAf,CAAwC,CAAxC,CAA1B;AACA,QAAIC,CAAC,GAAG,CAAR;;AACA,WAAOA,CAAC,GAAGL,kBAAX,EAA+B;AAC9B,UAAMM,aAAa,GAAGP,cAAc,CAACG,2BAAf,CAA2CG,CAA3C,CAAtB;AACA,UAAME,UAAU,GAAGR,cAAc,CAACK,wBAAf,CAAwCC,CAAxC,CAAnB,CAF8B,CAG9B;;AACA,UAAIC,aAAa,KAAKL,sBAAtB,EAA8C;AAC7C;AACA,eAAOK,aAAa,IAAIL,sBAAsB,GAAGE,mBAA7B,CAApB;AACA,OAP6B,CAQ9B;;;AACAA,MAAAA,mBAAmB,GAAGK,IAAI,CAACC,GAAL,CAASN,mBAAT,EAA8BI,UAA9B,CAAtB;AACAF,MAAAA,CAAC;AACD;AACD;AACD","sourcesContent":["export default function getVerticalSpacing({ itemsContainer, renderedItemsCount }) {\r\n\tif (renderedItemsCount > 1) {\r\n\t\tconst firstShownRowTopOffset = itemsContainer.getNthRenderedItemTopOffset(0)\r\n\t\tlet firstShownRowHeight = itemsContainer.getNthRenderedItemHeight(0)\r\n\t\tlet i = 1\r\n\t\twhile (i < renderedItemsCount) {\r\n\t\t\tconst itemTopOffset = itemsContainer.getNthRenderedItemTopOffset(i)\r\n\t\t\tconst itemHeight = itemsContainer.getNthRenderedItemHeight(i)\r\n\t\t\t// If next row is detected.\r\n\t\t\tif (itemTopOffset !== firstShownRowTopOffset) {\r\n\t\t\t\t// Measure inter-row spacing.\r\n\t\t\t\treturn itemTopOffset - (firstShownRowTopOffset + firstShownRowHeight)\r\n\t\t\t}\r\n\t\t\t// A row height is the maximum of its item heights.\r\n\t\t\tfirstShownRowHeight = Math.max(firstShownRowHeight, itemHeight)\r\n\t\t\ti++\r\n\t\t}\r\n\t}\r\n}"],"file":"getVerticalSpacing.js"}