virtual-scroller 1.12.2 → 1.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/CODE_OF_CONDUCT.md +78 -0
  3. package/README.md +1 -1
  4. package/bundle/index-bypass.html +2 -2
  5. package/bundle/index-grid.html +2 -2
  6. package/bundle/index-scrollableContainer.html +2 -2
  7. package/bundle/virtual-scroller-dom.js +1 -1
  8. package/bundle/virtual-scroller-dom.js.map +1 -1
  9. package/bundle/virtual-scroller-react.js +1 -1
  10. package/bundle/virtual-scroller-react.js.map +1 -1
  11. package/bundle/virtual-scroller.js +1 -1
  12. package/bundle/virtual-scroller.js.map +1 -1
  13. package/commonjs/Layout.js +10 -13
  14. package/commonjs/Layout.js.map +1 -1
  15. package/commonjs/Layout.test.js +20 -10
  16. package/commonjs/Layout.test.js.map +1 -1
  17. package/commonjs/Scroll.js +2 -1
  18. package/commonjs/Scroll.js.map +1 -1
  19. package/commonjs/{Resize.js → ScrollableContainerResizeHandler.js} +7 -7
  20. package/commonjs/ScrollableContainerResizeHandler.js.map +1 -0
  21. package/commonjs/VirtualScroller.constructor.js +5 -5
  22. package/commonjs/VirtualScroller.constructor.js.map +1 -1
  23. package/commonjs/VirtualScroller.items.js +1 -1
  24. package/commonjs/VirtualScroller.items.js.map +1 -1
  25. package/commonjs/VirtualScroller.js +67 -28
  26. package/commonjs/VirtualScroller.js.map +1 -1
  27. package/commonjs/VirtualScroller.layout.js +24 -22
  28. package/commonjs/VirtualScroller.layout.js.map +1 -1
  29. package/commonjs/{VirtualScroller.resize.js → VirtualScroller.onContainerResize.js} +2 -2
  30. package/commonjs/VirtualScroller.onContainerResize.js.map +1 -0
  31. package/commonjs/VirtualScroller.onRender.js +2 -2
  32. package/commonjs/VirtualScroller.onRender.js.map +1 -1
  33. package/commonjs/react/VirtualScroller.js +3 -0
  34. package/commonjs/react/VirtualScroller.js.map +1 -1
  35. package/commonjs/react/useEffectDontMountTwiceInStrictMode.js +83 -0
  36. package/commonjs/react/useEffectDontMountTwiceInStrictMode.js.map +1 -0
  37. package/commonjs/react/useInsertionEffectDontMountTwiceInStrictMode.js +20 -0
  38. package/commonjs/react/useInsertionEffectDontMountTwiceInStrictMode.js.map +1 -0
  39. package/commonjs/react/useLayoutEffectDontMountTwiceInStrictMode.js +20 -0
  40. package/commonjs/react/useLayoutEffectDontMountTwiceInStrictMode.js.map +1 -0
  41. package/commonjs/react/useState.js +13 -7
  42. package/commonjs/react/useState.js.map +1 -1
  43. package/commonjs/react/useStateNoStaleBug.js +59 -0
  44. package/commonjs/react/useStateNoStaleBug.js.map +1 -0
  45. package/modules/Layout.js +10 -13
  46. package/modules/Layout.js.map +1 -1
  47. package/modules/Layout.test.js +20 -10
  48. package/modules/Layout.test.js.map +1 -1
  49. package/modules/Scroll.js +2 -1
  50. package/modules/Scroll.js.map +1 -1
  51. package/modules/{Resize.js → ScrollableContainerResizeHandler.js} +7 -7
  52. package/modules/ScrollableContainerResizeHandler.js.map +1 -0
  53. package/modules/VirtualScroller.constructor.js +5 -5
  54. package/modules/VirtualScroller.constructor.js.map +1 -1
  55. package/modules/VirtualScroller.items.js +1 -1
  56. package/modules/VirtualScroller.items.js.map +1 -1
  57. package/modules/VirtualScroller.js +67 -28
  58. package/modules/VirtualScroller.js.map +1 -1
  59. package/modules/VirtualScroller.layout.js +24 -22
  60. package/modules/VirtualScroller.layout.js.map +1 -1
  61. package/modules/{VirtualScroller.resize.js → VirtualScroller.onContainerResize.js} +2 -2
  62. package/modules/VirtualScroller.onContainerResize.js.map +1 -0
  63. package/modules/VirtualScroller.onRender.js +2 -2
  64. package/modules/VirtualScroller.onRender.js.map +1 -1
  65. package/modules/react/VirtualScroller.js +3 -1
  66. package/modules/react/VirtualScroller.js.map +1 -1
  67. package/modules/react/useEffectDontMountTwiceInStrictMode.js +75 -0
  68. package/modules/react/useEffectDontMountTwiceInStrictMode.js.map +1 -0
  69. package/modules/react/useInsertionEffectDontMountTwiceInStrictMode.js +9 -0
  70. package/modules/react/useInsertionEffectDontMountTwiceInStrictMode.js.map +1 -0
  71. package/modules/react/useLayoutEffectDontMountTwiceInStrictMode.js +9 -0
  72. package/modules/react/useLayoutEffectDontMountTwiceInStrictMode.js.map +1 -0
  73. package/modules/react/useState.js +11 -8
  74. package/modules/react/useState.js.map +1 -1
  75. package/modules/react/useStateNoStaleBug.js +51 -0
  76. package/modules/react/useStateNoStaleBug.js.map +1 -0
  77. package/package.json +1 -1
  78. package/source/Layout.js +10 -13
  79. package/source/Layout.test.js +20 -10
  80. package/source/Scroll.js +1 -0
  81. package/source/{Resize.js → ScrollableContainerResizeHandler.js} +1 -1
  82. package/source/VirtualScroller.constructor.js +5 -5
  83. package/source/VirtualScroller.items.js +1 -1
  84. package/source/VirtualScroller.js +65 -25
  85. package/source/VirtualScroller.layout.js +22 -20
  86. package/source/{VirtualScroller.resize.js → VirtualScroller.onContainerResize.js} +1 -1
  87. package/source/VirtualScroller.onRender.js +2 -2
  88. package/source/react/VirtualScroller.js +3 -0
  89. package/source/react/useEffectDontMountTwiceInStrictMode.js +68 -0
  90. package/source/react/useInsertionEffectDontMountTwiceInStrictMode.js +10 -0
  91. package/source/react/useLayoutEffectDontMountTwiceInStrictMode.js +10 -0
  92. package/source/react/useState.js +8 -5
  93. package/source/react/useStateNoStaleBug.js +35 -0
  94. package/website/index-bypass.html +4 -14
  95. package/website/index-dom.html +1 -1
  96. package/website/index-grid.html +4 -4
  97. package/website/index-scrollableContainer.html +4 -4
  98. package/website/index-tbody-scrollableContainer.html +2 -0
  99. package/website/index-tbody.html +2 -0
  100. package/website/index.html +3 -3
  101. package/commonjs/Resize.js.map +0 -1
  102. package/commonjs/VirtualScroller.resize.js.map +0 -1
  103. package/modules/Resize.js.map +0 -1
  104. package/modules/VirtualScroller.resize.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"Resize.js","names":["Resize","bypass","getWidth","getHeight","listenForResize","onResizeStart","onResizeStop","onHeightChange","onWidthChange","onNoChange","isActive","prevScrollableContainerWidth","width","prevScrollableContainerHeight","height","onResize","debounce","_onResize","SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL","onStart","onStop","unlistenResize","undefined"],"sources":["../source/Resize.js"],"sourcesContent":["import debounce from './utility/debounce.js'\r\nimport log from './utility/debug.js'\r\n\r\nexport default class Resize {\r\n\tconstructor({\r\n\t\tbypass,\r\n\t\tgetWidth,\r\n\t\tgetHeight,\r\n\t\tlistenForResize,\r\n\t\tonResizeStart,\r\n\t\tonResizeStop,\r\n\t\tonHeightChange,\r\n\t\tonWidthChange,\r\n\t\tonNoChange\r\n\t}) {\r\n\t\tthis.bypass = bypass\r\n\r\n\t\tthis.onHeightChange = onHeightChange\r\n\t\tthis.onWidthChange = onWidthChange\r\n\t\tthis.onNoChange = onNoChange\r\n\r\n\t\tthis.getWidth = getWidth\r\n\t\tthis.getHeight = getHeight\r\n\t\tthis.listenForResize = listenForResize\r\n\r\n\t\tthis.onResize = debounce(\r\n\t\t\tthis._onResize,\r\n\t\t\tSCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL,\r\n\t\t\t{\r\n\t\t\t\tonStart: onResizeStart,\r\n\t\t\t\tonStop: onResizeStop\r\n\t\t\t}\r\n\t\t)\r\n\t}\r\n\r\n\tstart() {\r\n\t\tthis.isActive = true\r\n\t\tif (this.bypass) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\tthis.width = this.getWidth()\r\n\t\tthis.height = this.getHeight()\r\n\t\tthis.unlistenResize = this.listenForResize(this.onResize)\r\n\t}\r\n\r\n\tstop() {\r\n\t\tthis.isActive = false\r\n\t\tthis.width = undefined\r\n\t\tthis.height = undefined\r\n\t\tif (this.unlistenResize) {\r\n\t\t\tthis.unlistenResize()\r\n\t\t\tthis.unlistenResize = undefined\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * On scrollable container resize.\r\n\t */\r\n\t_onResize = () => {\r\n\t\t// If `VirtualScroller` has been unmounted\r\n\t\t// while `debounce()`'s `setTimeout()` was waiting, then exit.\r\n\t\t// If the `VirtualScroller` gets restarted later, it will detect\r\n\t\t// that `state.scrollableContainerWidth` doesn't match the actual\r\n\t\t// scrollable container width, and will call `this.onResize()`.\r\n\t\tif (!this.isActive) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tconst prevScrollableContainerWidth = this.width\r\n\t\tconst prevScrollableContainerHeight = this.height\r\n\r\n\t\tthis.width = this.getWidth()\r\n\t\tthis.height = this.getHeight()\r\n\r\n\t\tif (this.width === prevScrollableContainerWidth) {\r\n\t\t\tif (this.height === prevScrollableContainerHeight) {\r\n\t\t\t\t// The dimensions of the container didn't change,\r\n\t\t\t\t// so there's no need to re-layout anything.\r\n\t\t\t\tthis.onNoChange()\r\n\t\t\t} else {\r\n\t\t\t\t// Scrollable container height has changed,\r\n\t\t\t\t// so just recalculate shown item indexes.\r\n\t\t\t\t// No need to perform a re-layout from scratch.\r\n\t\t\t\tthis.onHeightChange(prevScrollableContainerHeight, this.height)\r\n\t\t\t}\r\n\t\t} else {\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\tthis.onWidthChange(prevScrollableContainerWidth, this.width)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nconst SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL = 250"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;;;;;IAEqBA,M;EACpB,sBAUG;IAAA;;IAAA,IATFC,MASE,QATFA,MASE;IAAA,IARFC,QAQE,QARFA,QAQE;IAAA,IAPFC,SAOE,QAPFA,SAOE;IAAA,IANFC,eAME,QANFA,eAME;IAAA,IALFC,aAKE,QALFA,aAKE;IAAA,IAJFC,YAIE,QAJFA,YAIE;IAAA,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MACD,KAAKW,KAAL,GAAa,KAAKV,QAAL,EAAb;MACA,KAAKY,MAAL,GAAc,KAAKX,SAAL,EAAd;MACA,KAAKkB,cAAL,GAAsB,KAAKjB,eAAL,CAAqB,KAAKW,QAA1B,CAAtB;IACA;;;WAED,gBAAO;MACN,KAAKL,QAAL,GAAgB,KAAhB;MACA,KAAKE,KAAL,GAAaU,SAAb;MACA,KAAKR,MAAL,GAAcQ,SAAd;;MACA,IAAI,KAAKD,cAAT,EAAyB;QACxB,KAAKA,cAAL;QACA,KAAKA,cAAL,GAAsBC,SAAtB;MACA;IACD;IAED;AACD;AACA;;;;;;;;AAsCA,IAAMJ,6CAA6C,GAAG,GAAtD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"VirtualScroller.resize.js","names":["onResize","previouslyCalculatedLayout","undefined","listHeightMeasurement","reset","itemsCount","newItemsWillBeRendered","count","getState","itemHeights","length","layout","newState","scrollableContainerWidth","scrollableContainer","getWidth","firstShownItemIndex","lastShownItemIndex","beforeItemsHeight","afterItemsHeight","Array","columnsCount","getActualColumnsCountForState","verticalSpacing","newColumnsCount","getActualColumnsCount","newFirstShownItemIndex","Math","floor","newLastShownItemIndex","min","ceil","log","getVerticalSpacing","getColumnsCount","shouldDiscardBeforeResizeItemHeights","beforeResize","shouldIncludeBeforeResizeValuesInState","snapshotBeforeResizeItemHeights","widthHasChanged","stateUpdate","updateState","prepend","replace"],"sources":["../source/VirtualScroller.resize.js"],"sourcesContent":["import log from './utility/debug.js'\r\n\r\nexport default function() {\r\n\tthis.onResize = () => {\r\n\t\t// Reset \"previously calculated layout\".\r\n\t\t//\r\n\t\t// The \"previously calculated layout\" feature is not currently used.\r\n\t\t//\r\n\t\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t\t// rather than from scratch, which would be an optimization.\r\n\t\t//\r\n\t\tthis.previouslyCalculatedLayout = undefined\r\n\r\n\t\t// Cancel any potential scheduled scroll position restoration.\r\n\t\tthis.listHeightMeasurement.reset()\r\n\r\n\t\t// Get the most recent items count.\r\n\t\t// If there're a \"pending\" `setItems()` call then use the items count from that call\r\n\t\t// instead of using the count of currently shown `items` from `state`.\r\n\t\t// A `setItems()` call is \"pending\" when `updateState()` operation is \"asynchronous\", that is\r\n\t\t// when `updateState()` calls aren't applied immediately, like in React.\r\n\t\tconst itemsCount = this.newItemsWillBeRendered\r\n\t\t\t? this.newItemsWillBeRendered.count\r\n\t\t\t: this.getState().itemHeights.length\r\n\r\n\t\t// If layout values have been calculated as a result of a \"pending\" `setItems()` call,\r\n\t\t// then don't discard those new layout values and use them instead of the ones from `state`.\r\n\t\t//\r\n\t\t// A `setItems()` call is \"pending\" when `updateState()` operation is \"asynchronous\", that is\r\n\t\t// when `updateState()` calls aren't applied immediately, like in React.\r\n\t\t//\r\n\t\tconst layout = this.newItemsWillBeRendered\r\n\t\t\t? this.newItemsWillBeRendered.layout\r\n\t\t\t: this.getState()\r\n\r\n\t\t// Update `VirtualScroller` state.\r\n\t\tconst newState = {\r\n\t\t\tscrollableContainerWidth: this.scrollableContainer.getWidth(),\r\n\r\n\t\t\t// This state update should also overwrite all the `state` properties\r\n\t\t\t// that are also updated in the \"on scroll\" handler (`getShownItemIndexes()`):\r\n\t\t\t//\r\n\t\t\t// * `firstShownItemIndex`\r\n\t\t\t// * `lastShownItemIndex`\r\n\t\t\t// * `beforeItemsHeight`\r\n\t\t\t// * `afterItemsHeight`\r\n\t\t\t//\r\n\t\t\t// That's because this `updateState()` update has a higher priority\r\n\t\t\t// than that of the \"on scroll\" handler, so it should overwrite\r\n\t\t\t// any potential state changes dispatched by the \"on scroll\" handler.\r\n\t\t\t//\r\n\t\t\t// All these properties might have changed, but they're not\r\n\t\t\t// recalculated here becase they'll be recalculated after\r\n\t\t\t// this new state is applied (rendered).\r\n\t\t\t//\r\n\t\t\tfirstShownItemIndex: layout.firstShownItemIndex,\r\n\t\t\tlastShownItemIndex: layout.lastShownItemIndex,\r\n\t\t\tbeforeItemsHeight: layout.beforeItemsHeight,\r\n\t\t\tafterItemsHeight: layout.afterItemsHeight,\r\n\r\n\t\t\t// Reset item heights, because if scrollable container's width (or height)\r\n\t\t\t// has changed, then the list width (or height) most likely also has changed,\r\n\t\t\t// and also some CSS `@media()` rules might have been added or removed.\r\n\t\t\t// So re-render the list entirely.\r\n\t\t\titemHeights: new Array(itemsCount),\r\n\r\n\t\t\tcolumnsCount: this.getActualColumnsCountForState(),\r\n\r\n\t\t\t// Re-measure vertical spacing after render because new CSS styles\r\n\t\t\t// might be applied for the new window width.\r\n\t\t\tverticalSpacing: undefined\r\n\t\t}\r\n\r\n\t\tconst { firstShownItemIndex, lastShownItemIndex } = layout\r\n\r\n\t\t// Get the `columnsCount` for the new window width.\r\n\t\tconst newColumnsCount = this.getActualColumnsCount()\r\n\r\n\t\t// Re-calculate `firstShownItemIndex` and `lastShownItemIndex`\r\n\t\t// based on the new `columnsCount` so that the whole row is visible.\r\n\t\tconst newFirstShownItemIndex = Math.floor(firstShownItemIndex / newColumnsCount) * newColumnsCount\r\n\t\tconst newLastShownItemIndex = Math.min(\r\n\t\t\tMath.ceil((lastShownItemIndex + 1) / newColumnsCount) * newColumnsCount,\r\n\t\t\titemsCount\r\n\t\t) - 1\r\n\r\n\t\t// Potentially update `firstShownItemIndex` if it needs to be adjusted in order to\r\n\t\t// correspond to the new `columnsCount`.\r\n\t\tif (newFirstShownItemIndex !== firstShownItemIndex) {\r\n\t\t\tlog('Columns Count changed from', this.getState().columnsCount || 1, 'to', newColumnsCount)\r\n\t\t\tlog('First Shown Item Index needs to change from', firstShownItemIndex, 'to', newFirstShownItemIndex)\r\n\t\t}\r\n\r\n\t\t// Always rewrite `firstShownItemIndex` and `lastShownItemIndex`\r\n\t\t// as part of the `state` update, even if it hasn't been modified.\r\n\t\t//\r\n\t\t// The reason is that there could be two subsequent `onResize()` calls:\r\n\t\t// the first one could be user resizing the window to half of its width,\r\n\t\t// resulting in an \"asynchronous\" `updateState()` call, and then, before that\r\n\t\t// `updateState()` call is applied, a second resize event happens when the user\r\n\t\t// has resized the window back to its original width, meaning that the\r\n\t\t// `columnsCount` is back to its original value.\r\n\t\t// In that case, the final `newFirstShownItemIndex` will be equal to the\r\n\t\t// original `firstShownItemIndex` that was in `state` before the user\r\n\t\t// has started resizing the window, so, in the end, `state.firstShownItemIndex`\r\n\t\t// property wouldn't have changed, but it still has to be part of the final\r\n\t\t// state update in order to overwrite the previous update of `firstShownItemIndex`\r\n\t\t// property that has been scheduled to be applied in state after the first resize\r\n\t\t// happened.\r\n\t\t//\r\n\t\tnewState.firstShownItemIndex = newFirstShownItemIndex\r\n\t\tnewState.lastShownItemIndex = newLastShownItemIndex\r\n\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\r\n\t\t// `beforeResize` is always overwritten in `state` here.\r\n\t\t// (once it has started being tracked in `state`)\r\n\t\tif (this.shouldDiscardBeforeResizeItemHeights() || newFirstShownItemIndex === 0) {\r\n\t\t\tif (this.beforeResize.shouldIncludeBeforeResizeValuesInState()) {\r\n\t\t\t\tnewState.beforeResize = undefined\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Snapshot \"before resize\" values in order to preserve the currently\r\n\t\t// shown items' vertical position on screen so that there's no \"content jumping\".\r\n\t\telse {\r\n\t\t\t// Keep \"before resize\" values in order to preserve the currently\r\n\t\t\t// shown items' vertical position on screen so that there's no\r\n\t\t\t// \"content jumping\". These \"before resize\" values will be discarded\r\n\t\t\t// when (if) the user scrolls back to the top of the list.\r\n\t\t\tnewState.beforeResize = {\r\n\t\t\t\tverticalSpacing,\r\n\t\t\t\tcolumnsCount,\r\n\t\t\t\titemHeights: this.beforeResize.snapshotBeforeResizeItemHeights({\r\n\t\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\t\tnewFirstShownItemIndex,\r\n\t\t\t\t\tnewColumnsCount\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `this.widthHasChanged` tells `VirtualScroller` that it should\r\n\t\t// temporarily stop other updates (like \"on scroll\" updates) and wait\r\n\t\t// for the new `state` to be applied, after which the `onRender()`\r\n\t\t// function will clear this flag and perform a re-layout.\r\n\t\t//\r\n\t\t// A re-layout is required because the layout parameters calculated above\r\n\t\t// are approximate ones, and the exact item heights aren't known at this point.\r\n\t\t// So the `updateState()` call below is just to re-render the `VirtualScroller`.\r\n\t\t// After it has been re-rendered, it will measure item heights and then calculate\r\n\t\t// correct layout parameters.\r\n\t\t//\r\n\t\tthis.widthHasChanged = {\r\n\t\t\tstateUpdate: newState\r\n\t\t}\r\n\r\n\t\t// Rerender.\r\n\t\tthis.updateState(newState)\r\n\t}\r\n\r\n\t// Returns whether \"before resize\" item heights should be discarded\r\n\t// as a result of calling `setItems()` with a new set of items\r\n\t// when an asynchronous `updateState()` call inside that function\r\n\t// hasn't been applied yet.\r\n\t//\r\n\t// If `setItems()` update was an \"incremental\" one and no items\r\n\t// have been prepended, then `firstShownItemIndex` is preserved,\r\n\t// and all items' heights before it should be kept in order to\r\n\t// preserve the top offset of the first shown item so that there's\r\n\t// no \"content jumping\".\r\n\t//\r\n\t// If `setItems()` update was an \"incremental\" one but there're\r\n\t// some prepended items, then it means that now there're new items\r\n\t// with unknown heights at the top, so the top offset of the first\r\n\t// shown item won't be preserved because there're no \"before resize\"\r\n\t// heights of those items.\r\n\t//\r\n\t// If `setItems()` update was not an \"incremental\" one, then don't\r\n\t// attempt to restore previous item heights after a potential window\r\n\t// width change because all item heights have been reset.\r\n\t//\r\n\tthis.shouldDiscardBeforeResizeItemHeights = () => {\r\n\t\tif (this.newItemsWillBeRendered) {\r\n\t\t\tconst { prepend, replace } = this.newItemsWillBeRendered\r\n\t\t\treturn prepend || replace\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;;AAAA;;;;AAEe,oBAAW;EAAA;;EACzB,KAAKA,QAAL,GAAgB,YAAM;IACrB;IACA;IACA;IACA;IACA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tBA,sBAF8D;UAG9DF,eAAe,EAAfA;QAH8D,CAAlD;MAHU,CAAxB;IASA,CAzIoB,CA2IrB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;IACA,KAAI,CAACe,eAAL,GAAuB;MACtBC,WAAW,EAAE5B;IADS,CAAvB,CAtJqB,CA0JrB;;IACA,KAAI,CAAC6B,WAAL,CAAiB7B,QAAjB;EACA,CA5JD,CADyB,CA+JzB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;EACA,KAAKuB,oCAAL,GAA4C,YAAM;IACjD,IAAI,KAAI,CAAC7B,sBAAT,EAAiC;MAChC,4BAA6B,KAAI,CAACA,sBAAlC;MAAA,IAAQoC,OAAR,yBAAQA,OAAR;MAAA,IAAiBC,OAAjB,yBAAiBA,OAAjB;MACA,OAAOD,OAAO,IAAIC,OAAlB;IACA;EACD,CALD;AAMA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Resize.js","names":["debounce","log","Resize","bypass","getWidth","getHeight","listenForResize","onResizeStart","onResizeStop","onHeightChange","onWidthChange","onNoChange","isActive","prevScrollableContainerWidth","width","prevScrollableContainerHeight","height","onResize","_onResize","SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL","onStart","onStop","unlistenResize","undefined"],"sources":["../source/Resize.js"],"sourcesContent":["import debounce from './utility/debounce.js'\r\nimport log from './utility/debug.js'\r\n\r\nexport default class Resize {\r\n\tconstructor({\r\n\t\tbypass,\r\n\t\tgetWidth,\r\n\t\tgetHeight,\r\n\t\tlistenForResize,\r\n\t\tonResizeStart,\r\n\t\tonResizeStop,\r\n\t\tonHeightChange,\r\n\t\tonWidthChange,\r\n\t\tonNoChange\r\n\t}) {\r\n\t\tthis.bypass = bypass\r\n\r\n\t\tthis.onHeightChange = onHeightChange\r\n\t\tthis.onWidthChange = onWidthChange\r\n\t\tthis.onNoChange = onNoChange\r\n\r\n\t\tthis.getWidth = getWidth\r\n\t\tthis.getHeight = getHeight\r\n\t\tthis.listenForResize = listenForResize\r\n\r\n\t\tthis.onResize = debounce(\r\n\t\t\tthis._onResize,\r\n\t\t\tSCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL,\r\n\t\t\t{\r\n\t\t\t\tonStart: onResizeStart,\r\n\t\t\t\tonStop: onResizeStop\r\n\t\t\t}\r\n\t\t)\r\n\t}\r\n\r\n\tstart() {\r\n\t\tthis.isActive = true\r\n\t\tif (this.bypass) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\tthis.width = this.getWidth()\r\n\t\tthis.height = this.getHeight()\r\n\t\tthis.unlistenResize = this.listenForResize(this.onResize)\r\n\t}\r\n\r\n\tstop() {\r\n\t\tthis.isActive = false\r\n\t\tthis.width = undefined\r\n\t\tthis.height = undefined\r\n\t\tif (this.unlistenResize) {\r\n\t\t\tthis.unlistenResize()\r\n\t\t\tthis.unlistenResize = undefined\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * On scrollable container resize.\r\n\t */\r\n\t_onResize = () => {\r\n\t\t// If `VirtualScroller` has been unmounted\r\n\t\t// while `debounce()`'s `setTimeout()` was waiting, then exit.\r\n\t\t// If the `VirtualScroller` gets restarted later, it will detect\r\n\t\t// that `state.scrollableContainerWidth` doesn't match the actual\r\n\t\t// scrollable container width, and will call `this.onResize()`.\r\n\t\tif (!this.isActive) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tconst prevScrollableContainerWidth = this.width\r\n\t\tconst prevScrollableContainerHeight = this.height\r\n\r\n\t\tthis.width = this.getWidth()\r\n\t\tthis.height = this.getHeight()\r\n\r\n\t\tif (this.width === prevScrollableContainerWidth) {\r\n\t\t\tif (this.height === prevScrollableContainerHeight) {\r\n\t\t\t\t// The dimensions of the container didn't change,\r\n\t\t\t\t// so there's no need to re-layout anything.\r\n\t\t\t\tthis.onNoChange()\r\n\t\t\t} else {\r\n\t\t\t\t// Scrollable container height has changed,\r\n\t\t\t\t// so just recalculate shown item indexes.\r\n\t\t\t\t// No need to perform a re-layout from scratch.\r\n\t\t\t\tthis.onHeightChange(prevScrollableContainerHeight, this.height)\r\n\t\t\t}\r\n\t\t} else {\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\tthis.onWidthChange(prevScrollableContainerWidth, this.width)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nconst SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL = 250"],"mappings":";;;;;;;;AAAA,OAAOA,QAAP,MAAqB,uBAArB;AACA,OAAOC,GAAP,MAAgB,oBAAhB;;IAEqBC,M;EACpB,sBAUG;IAAA;;IAAA,IATFC,MASE,QATFA,MASE;IAAA,IARFC,QAQE,QARFA,QAQE;IAAA,IAPFC,SAOE,QAPFA,SAOE;IAAA,IANFC,eAME,QANFA,eAME;IAAA,IALFC,aAKE,QALFA,aAKE;IAAA,IAJFC,YAIE,QAJFA,YAIE;IAAA,IAHFC,cAGE,QAHFA,cAGE;IAAA,IAFFC,aAEE,QAFFA,aAEE;IAAA,IADFC,UACE,QADFA,UACE;;IAAA;;IAAA,mCA4CS,YAAM;MACjB;MACA;MACA;MACA;MACA;MACA,IAAI,CAAC,KAAI,CAACC,QAAV,EAAoB;QACnB;MACA;;MAED,IAAMC,4BAA4B,GAAG,KAAI,CAACC,KAA1C;MACA,IAAMC,6BAA6B,GAAG,KAAI,CAACC,MAA3C;MAEA,KAAI,CAACF,KAAL,GAAa,KAAI,CAACV,QAAL,EAAb;MACA,KAAI,CAACY,MAAL,GAAc,KAAI,CAACX,SAAL,EAAd;;MAEA,IAAI,KAAI,CAACS,KAAL,KAAeD,4BAAnB,EAAiD;QAChD,IAAI,KAAI,CAACG,MAAL,KAAgBD,6BAApB,EAAmD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onResize","previouslyCalculatedLayout","undefined","listHeightMeasurement","reset","itemsCount","newItemsWillBeRendered","count","getState","itemHeights","length","layout","newState","scrollableContainerWidth","scrollableContainer","getWidth","firstShownItemIndex","lastShownItemIndex","beforeItemsHeight","afterItemsHeight","Array","columnsCount","getActualColumnsCountForState","verticalSpacing","newColumnsCount","getActualColumnsCount","newFirstShownItemIndex","Math","floor","newLastShownItemIndex","min","ceil","getVerticalSpacing","getColumnsCount","shouldDiscardBeforeResizeItemHeights","beforeResize","shouldIncludeBeforeResizeValuesInState","snapshotBeforeResizeItemHeights","widthHasChanged","stateUpdate","updateState","prepend","replace"],"sources":["../source/VirtualScroller.resize.js"],"sourcesContent":["import log from './utility/debug.js'\r\n\r\nexport default function() {\r\n\tthis.onResize = () => {\r\n\t\t// Reset \"previously calculated layout\".\r\n\t\t//\r\n\t\t// The \"previously calculated layout\" feature is not currently used.\r\n\t\t//\r\n\t\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t\t// rather than from scratch, which would be an optimization.\r\n\t\t//\r\n\t\tthis.previouslyCalculatedLayout = undefined\r\n\r\n\t\t// Cancel any potential scheduled scroll position restoration.\r\n\t\tthis.listHeightMeasurement.reset()\r\n\r\n\t\t// Get the most recent items count.\r\n\t\t// If there're a \"pending\" `setItems()` call then use the items count from that call\r\n\t\t// instead of using the count of currently shown `items` from `state`.\r\n\t\t// A `setItems()` call is \"pending\" when `updateState()` operation is \"asynchronous\", that is\r\n\t\t// when `updateState()` calls aren't applied immediately, like in React.\r\n\t\tconst itemsCount = this.newItemsWillBeRendered\r\n\t\t\t? this.newItemsWillBeRendered.count\r\n\t\t\t: this.getState().itemHeights.length\r\n\r\n\t\t// If layout values have been calculated as a result of a \"pending\" `setItems()` call,\r\n\t\t// then don't discard those new layout values and use them instead of the ones from `state`.\r\n\t\t//\r\n\t\t// A `setItems()` call is \"pending\" when `updateState()` operation is \"asynchronous\", that is\r\n\t\t// when `updateState()` calls aren't applied immediately, like in React.\r\n\t\t//\r\n\t\tconst layout = this.newItemsWillBeRendered\r\n\t\t\t? this.newItemsWillBeRendered.layout\r\n\t\t\t: this.getState()\r\n\r\n\t\t// Update `VirtualScroller` state.\r\n\t\tconst newState = {\r\n\t\t\tscrollableContainerWidth: this.scrollableContainer.getWidth(),\r\n\r\n\t\t\t// This state update should also overwrite all the `state` properties\r\n\t\t\t// that are also updated in the \"on scroll\" handler (`getShownItemIndexes()`):\r\n\t\t\t//\r\n\t\t\t// * `firstShownItemIndex`\r\n\t\t\t// * `lastShownItemIndex`\r\n\t\t\t// * `beforeItemsHeight`\r\n\t\t\t// * `afterItemsHeight`\r\n\t\t\t//\r\n\t\t\t// That's because this `updateState()` update has a higher priority\r\n\t\t\t// than that of the \"on scroll\" handler, so it should overwrite\r\n\t\t\t// any potential state changes dispatched by the \"on scroll\" handler.\r\n\t\t\t//\r\n\t\t\t// All these properties might have changed, but they're not\r\n\t\t\t// recalculated here becase they'll be recalculated after\r\n\t\t\t// this new state is applied (rendered).\r\n\t\t\t//\r\n\t\t\tfirstShownItemIndex: layout.firstShownItemIndex,\r\n\t\t\tlastShownItemIndex: layout.lastShownItemIndex,\r\n\t\t\tbeforeItemsHeight: layout.beforeItemsHeight,\r\n\t\t\tafterItemsHeight: layout.afterItemsHeight,\r\n\r\n\t\t\t// Reset item heights, because if scrollable container's width (or height)\r\n\t\t\t// has changed, then the list width (or height) most likely also has changed,\r\n\t\t\t// and also some CSS `@media()` rules might have been added or removed.\r\n\t\t\t// So re-render the list entirely.\r\n\t\t\titemHeights: new Array(itemsCount),\r\n\r\n\t\t\tcolumnsCount: this.getActualColumnsCountForState(),\r\n\r\n\t\t\t// Re-measure vertical spacing after render because new CSS styles\r\n\t\t\t// might be applied for the new window width.\r\n\t\t\tverticalSpacing: undefined\r\n\t\t}\r\n\r\n\t\tconst { firstShownItemIndex, lastShownItemIndex } = layout\r\n\r\n\t\t// Get the `columnsCount` for the new window width.\r\n\t\tconst newColumnsCount = this.getActualColumnsCount()\r\n\r\n\t\t// Re-calculate `firstShownItemIndex` and `lastShownItemIndex`\r\n\t\t// based on the new `columnsCount` so that the whole row is visible.\r\n\t\tconst newFirstShownItemIndex = Math.floor(firstShownItemIndex / newColumnsCount) * newColumnsCount\r\n\t\tconst newLastShownItemIndex = Math.min(\r\n\t\t\tMath.ceil((lastShownItemIndex + 1) / newColumnsCount) * newColumnsCount,\r\n\t\t\titemsCount\r\n\t\t) - 1\r\n\r\n\t\t// Potentially update `firstShownItemIndex` if it needs to be adjusted in order to\r\n\t\t// correspond to the new `columnsCount`.\r\n\t\tif (newFirstShownItemIndex !== firstShownItemIndex) {\r\n\t\t\tlog('Columns Count changed from', this.getState().columnsCount || 1, 'to', newColumnsCount)\r\n\t\t\tlog('First Shown Item Index needs to change from', firstShownItemIndex, 'to', newFirstShownItemIndex)\r\n\t\t}\r\n\r\n\t\t// Always rewrite `firstShownItemIndex` and `lastShownItemIndex`\r\n\t\t// as part of the `state` update, even if it hasn't been modified.\r\n\t\t//\r\n\t\t// The reason is that there could be two subsequent `onResize()` calls:\r\n\t\t// the first one could be user resizing the window to half of its width,\r\n\t\t// resulting in an \"asynchronous\" `updateState()` call, and then, before that\r\n\t\t// `updateState()` call is applied, a second resize event happens when the user\r\n\t\t// has resized the window back to its original width, meaning that the\r\n\t\t// `columnsCount` is back to its original value.\r\n\t\t// In that case, the final `newFirstShownItemIndex` will be equal to the\r\n\t\t// original `firstShownItemIndex` that was in `state` before the user\r\n\t\t// has started resizing the window, so, in the end, `state.firstShownItemIndex`\r\n\t\t// property wouldn't have changed, but it still has to be part of the final\r\n\t\t// state update in order to overwrite the previous update of `firstShownItemIndex`\r\n\t\t// property that has been scheduled to be applied in state after the first resize\r\n\t\t// happened.\r\n\t\t//\r\n\t\tnewState.firstShownItemIndex = newFirstShownItemIndex\r\n\t\tnewState.lastShownItemIndex = newLastShownItemIndex\r\n\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\r\n\t\t// `beforeResize` is always overwritten in `state` here.\r\n\t\t// (once it has started being tracked in `state`)\r\n\t\tif (this.shouldDiscardBeforeResizeItemHeights() || newFirstShownItemIndex === 0) {\r\n\t\t\tif (this.beforeResize.shouldIncludeBeforeResizeValuesInState()) {\r\n\t\t\t\tnewState.beforeResize = undefined\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Snapshot \"before resize\" values in order to preserve the currently\r\n\t\t// shown items' vertical position on screen so that there's no \"content jumping\".\r\n\t\telse {\r\n\t\t\t// Keep \"before resize\" values in order to preserve the currently\r\n\t\t\t// shown items' vertical position on screen so that there's no\r\n\t\t\t// \"content jumping\". These \"before resize\" values will be discarded\r\n\t\t\t// when (if) the user scrolls back to the top of the list.\r\n\t\t\tnewState.beforeResize = {\r\n\t\t\t\tverticalSpacing,\r\n\t\t\t\tcolumnsCount,\r\n\t\t\t\titemHeights: this.beforeResize.snapshotBeforeResizeItemHeights({\r\n\t\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\t\tnewFirstShownItemIndex,\r\n\t\t\t\t\tnewColumnsCount\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `this.widthHasChanged` tells `VirtualScroller` that it should\r\n\t\t// temporarily stop other updates (like \"on scroll\" updates) and wait\r\n\t\t// for the new `state` to be applied, after which the `onRender()`\r\n\t\t// function will clear this flag and perform a re-layout.\r\n\t\t//\r\n\t\t// A re-layout is required because the layout parameters calculated above\r\n\t\t// are approximate ones, and the exact item heights aren't known at this point.\r\n\t\t// So the `updateState()` call below is just to re-render the `VirtualScroller`.\r\n\t\t// After it has been re-rendered, it will measure item heights and then calculate\r\n\t\t// correct layout parameters.\r\n\t\t//\r\n\t\tthis.widthHasChanged = {\r\n\t\t\tstateUpdate: newState\r\n\t\t}\r\n\r\n\t\t// Rerender.\r\n\t\tthis.updateState(newState)\r\n\t}\r\n\r\n\t// Returns whether \"before resize\" item heights should be discarded\r\n\t// as a result of calling `setItems()` with a new set of items\r\n\t// when an asynchronous `updateState()` call inside that function\r\n\t// hasn't been applied yet.\r\n\t//\r\n\t// If `setItems()` update was an \"incremental\" one and no items\r\n\t// have been prepended, then `firstShownItemIndex` is preserved,\r\n\t// and all items' heights before it should be kept in order to\r\n\t// preserve the top offset of the first shown item so that there's\r\n\t// no \"content jumping\".\r\n\t//\r\n\t// If `setItems()` update was an \"incremental\" one but there're\r\n\t// some prepended items, then it means that now there're new items\r\n\t// with unknown heights at the top, so the top offset of the first\r\n\t// shown item won't be preserved because there're no \"before resize\"\r\n\t// heights of those items.\r\n\t//\r\n\t// If `setItems()` update was not an \"incremental\" one, then don't\r\n\t// attempt to restore previous item heights after a potential window\r\n\t// width change because all item heights have been reset.\r\n\t//\r\n\tthis.shouldDiscardBeforeResizeItemHeights = () => {\r\n\t\tif (this.newItemsWillBeRendered) {\r\n\t\t\tconst { prepend, replace } = this.newItemsWillBeRendered\r\n\t\t\treturn prepend || replace\r\n\t\t}\r\n\t}\r\n}"],"mappings":"AAAA,OAAOA,GAAP,MAAgB,oBAAhB;AAEA,eAAe,YAAW;EAAA;;EACzB,KAAKC,QAAL,GAAgB,YAAM;IACrB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAI,CAACC,0BAAL,GAAkCC,SAAlC,CATqB,CAWrB;;IACA,KAAI,CAACC,qBAAL,CAA2BC,KAA3B,GAZqB,CAcrB;IACA;IACA;IACA;IACA;;;IACA,IAAMC,UAAU,GAAG,KAAI,CAACC,sBAAL,GAChB,KAAI,CAACA,sBAAL,CAA4BC,KADZ,GAEhB,KAAI,CAACC,QAAL,GAAgBC,WAAhB,CAA4BC,MAF/B,CAnBqB,CAuBrB;IACA;IACA;IACA;IACA;IACA;;IACA,IAAMC,MAAM,GAAG,KAAI,CAACL,sBAAL,GACZ,KAAI,CAACA,sBAAL,CAA4BK,MADhB,GAEZ,KAAI,CAACH,QAAL,EAFH,CA7BqB,CAiCrB;;I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