virtual-scroller 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +65 -13
- package/bundle/virtual-scroller-dom.js +1 -1
- package/bundle/virtual-scroller-dom.js.map +1 -1
- package/bundle/virtual-scroller-react.js +1 -1
- package/bundle/virtual-scroller-react.js.map +1 -1
- package/bundle/virtual-scroller.js +1 -1
- package/bundle/virtual-scroller.js.map +1 -1
- package/commonjs/DOM/ScrollableContainer.js +13 -1
- package/commonjs/DOM/ScrollableContainer.js.map +1 -1
- package/commonjs/Layout.js +65 -10
- package/commonjs/Layout.js.map +1 -1
- package/commonjs/ScrollableContainerNotReadyError.js +51 -0
- package/commonjs/ScrollableContainerNotReadyError.js.map +1 -0
- package/commonjs/VirtualScroller.constructor.js +20 -6
- package/commonjs/VirtualScroller.constructor.js.map +1 -1
- package/commonjs/VirtualScroller.state.js +20 -6
- package/commonjs/VirtualScroller.state.js.map +1 -1
- package/commonjs/react/VirtualScroller.js +13 -2
- package/commonjs/react/VirtualScroller.js.map +1 -1
- package/commonjs/react/useVirtualScroller.js +5 -0
- package/commonjs/react/useVirtualScroller.js.map +1 -1
- package/index.d.ts +2 -1
- package/modules/DOM/ScrollableContainer.js +11 -1
- package/modules/DOM/ScrollableContainer.js.map +1 -1
- package/modules/Layout.js +62 -10
- package/modules/Layout.js.map +1 -1
- package/modules/ScrollableContainerNotReadyError.js +44 -0
- package/modules/ScrollableContainerNotReadyError.js.map +1 -0
- package/modules/VirtualScroller.constructor.js +20 -6
- package/modules/VirtualScroller.constructor.js.map +1 -1
- package/modules/VirtualScroller.state.js +20 -6
- package/modules/VirtualScroller.state.js.map +1 -1
- package/modules/react/VirtualScroller.js +13 -2
- package/modules/react/VirtualScroller.js.map +1 -1
- package/modules/react/useVirtualScroller.js +5 -0
- package/modules/react/useVirtualScroller.js.map +1 -1
- package/package.json +1 -1
- package/source/DOM/ScrollableContainer.js +8 -0
- package/source/Layout.js +57 -9
- package/source/ScrollableContainerNotReadyError.js +5 -0
- package/source/VirtualScroller.constructor.js +17 -5
- package/source/VirtualScroller.state.js +19 -4
- package/source/react/VirtualScroller.js +14 -1
- package/source/react/useVirtualScroller.js +6 -0
|
@@ -7,6 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = exports.ScrollableWindowContainer = void 0;
|
|
9
9
|
|
|
10
|
+
var _ScrollableContainerNotReadyError = _interopRequireDefault(require("../ScrollableContainerNotReadyError.js"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
|
|
10
14
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
11
15
|
|
|
12
16
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
@@ -76,6 +80,10 @@ var ScrollableContainer = /*#__PURE__*/function () {
|
|
|
76
80
|
}, {
|
|
77
81
|
key: "getWidth",
|
|
78
82
|
value: function getWidth() {
|
|
83
|
+
if (!this.getElement()) {
|
|
84
|
+
throw new _ScrollableContainerNotReadyError["default"]();
|
|
85
|
+
}
|
|
86
|
+
|
|
79
87
|
return this.getElement().offsetWidth;
|
|
80
88
|
}
|
|
81
89
|
/**
|
|
@@ -87,9 +95,13 @@ var ScrollableContainer = /*#__PURE__*/function () {
|
|
|
87
95
|
}, {
|
|
88
96
|
key: "getHeight",
|
|
89
97
|
value: function getHeight() {
|
|
90
|
-
|
|
98
|
+
if (!this.getElement()) {
|
|
99
|
+
throw new _ScrollableContainerNotReadyError["default"]();
|
|
100
|
+
} // if (!this.getElement() && !precise) {
|
|
91
101
|
// return getScreenHeight()
|
|
92
102
|
// }
|
|
103
|
+
|
|
104
|
+
|
|
93
105
|
return this.getElement().offsetHeight;
|
|
94
106
|
}
|
|
95
107
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollableContainer.js","names":["ScrollableContainer","getElement","getItemsContainerElement","scrollTop","scrollY","scrollTo","offsetWidth","offsetHeight","scrollableContainerTop","getBoundingClientRect","top","scrollableContainerBorderTopWidth","clientTop","itemsContainerTop","getScrollY","onScrollListener","element","addEventListener","removeEventListener","onResize","unobserve","ResizeObserver","resizeObserver","entries","entry","observe","unlistenGlobalResize","addGlobalResizeListener","itemsContainerElement","ScrollableWindowContainer","window","pageYOffset","innerWidth","innerHeight","borderTopWidth","document","body","onResizeListener","fullscreenElement","contains"],"sources":["../../source/DOM/ScrollableContainer.js"],"sourcesContent":["export default class ScrollableContainer {\r\n\t/**\r\n\t * Constructs a new \"scrollable container\" from an element.\r\n\t * @param {func} getElement — Returns the scrollable container element.\r\n\t * @param {func} getItemsContainerElement — Returns items \"container\" element.\r\n\t */\r\n\tconstructor(getElement, getItemsContainerElement) {\r\n\t\tthis.getElement = getElement\r\n\t\tthis.getItemsContainerElement = getItemsContainerElement\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the current scroll position.\r\n\t * @return {number}\r\n\t */\r\n\tgetScrollY() {\r\n\t\treturn this.getElement().scrollTop\r\n\t}\r\n\r\n\t/**\r\n\t * Scrolls to a specific position.\r\n\t * @param {number} scrollY\r\n\t */\r\n\tscrollToY(scrollY) {\r\n\t\t// IE 11 doesn't seem to have a `.scrollTo()` method.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/10\r\n\t\t// https://stackoverflow.com/questions/39908825/window-scrollto-is-not-working-in-internet-explorer-11\r\n\t\tif (this.getElement().scrollTo) {\r\n\t\t\tthis.getElement().scrollTo(0, scrollY)\r\n\t\t} else {\r\n\t\t\tthis.getElement().scrollTop = scrollY\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns \"scrollable container\" width,\r\n\t * i.e. the available width for its content.\r\n\t * @return {number}\r\n\t */\r\n\tgetWidth() {\r\n\t\treturn this.getElement().offsetWidth\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the height of the \"scrollable container\" itself.\r\n\t * Not to be confused with the height of \"scrollable container\"'s content.\r\n\t * @return {number}\r\n\t */\r\n\tgetHeight() {\r\n\t\t// if (!this.getElement() && !precise) {\r\n\t\t// \treturn getScreenHeight()\r\n\t\t// }\r\n\t\treturn this.getElement().offsetHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a \"top offset\" of an items container element\r\n\t * relative to the \"scrollable container\"'s top edge.\r\n\t * @return {number}\r\n\t */\r\n\tgetItemsContainerTopOffset() {\r\n\t\tconst scrollableContainerTop = this.getElement().getBoundingClientRect().top\r\n\t\tconst scrollableContainerBorderTopWidth = this.getElement().clientTop\r\n\t\tconst itemsContainerTop = this.getItemsContainerElement().getBoundingClientRect().top\r\n\t\treturn (itemsContainerTop - scrollableContainerTop) + this.getScrollY() - scrollableContainerBorderTopWidth\r\n\t}\r\n\r\n\t// isVisible() {\r\n\t// \tconst { top, bottom } = this.getElement().getBoundingClientRect()\r\n\t// \treturn bottom > 0 && top < getScreenHeight()\r\n\t// }\r\n\r\n\t/**\r\n\t * Adds a \"scroll\" event listener to the \"scrollable container\".\r\n\t * @param {onScrollListener} Should be called whenever the scroll position inside the \"scrollable container\" (potentially) changes.\r\n\t * @return {function} Returns a function that stops listening.\r\n\t */\r\n\tonScroll(onScrollListener) {\r\n\t\tconst element = this.getElement()\r\n\t\telement.addEventListener('scroll', onScrollListener)\r\n\t\treturn () => element.removeEventListener('scroll', onScrollListener)\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a \"resize\" event listener to the \"scrollable container\".\r\n\t * @param {onResize} Should be called whenever the \"scrollable container\"'s width or height (potentially) changes.\r\n * @return {function} Returns a function that stops listening.\r\n\t */\r\n\tonResize(onResize) {\r\n\t\t// Watches \"scrollable container\"'s dimensions via a `ResizeObserver`.\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver\r\n\t\t// https://web.dev/resize-observer/\r\n\t\tlet unobserve\r\n\t\tif (typeof ResizeObserver !== 'undefined') {\r\n\t\t\tconst resizeObserver = new ResizeObserver((entries) => {\r\n\t\t\t\t// \"one entry per observed element\".\r\n\t\t\t\t// https://web.dev/resize-observer/\r\n\t\t\t\t// `entry.target === this.getElement()`.\r\n\t\t\t\tconst entry = entries[0]\r\n\t\t\t\t// // If `entry.contentBoxSize` property is supported by the web browser.\r\n\t\t\t\t// if (entry.contentBoxSize) {\r\n\t\t\t\t// \t// https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentBoxSize\r\n\t\t\t\t// \tconst width = entry.contentBoxSize.inlineSize\r\n\t\t\t\t// \tconst height = entry.contentBoxSize.blockSize\r\n\t\t\t\t// }\r\n\t\t\t\tonResize()\r\n\t\t\t})\r\n\t\t\tconst element = this.getElement()\r\n\t\t\tresizeObserver.observe(element)\r\n\t\t\tunobserve = () => resizeObserver.unobserve(element)\r\n\t\t}\r\n\t\t// I guess, if window is resized, `onResize()` will be triggered twice:\r\n\t\t// once for window resize, and once for the scrollable container resize.\r\n\t\t// But `onResize()` also has an internal check: if the container size\r\n\t\t// hasn't changed since the previous time `onResize()` has been called,\r\n\t\t// then `onResize()` doesn't do anything, so, I guess, there shouldn't be\r\n\t\t// any \"performance implications\" of running the listener twice in such case.\r\n\t\tconst unlistenGlobalResize = addGlobalResizeListener(onResize, {\r\n\t\t\titemsContainerElement: this.getItemsContainerElement()\r\n\t\t})\r\n\t\treturn () => {\r\n\t\t\tif (unobserve) {\r\n\t\t\t\tunobserve()\r\n\t\t\t}\r\n\t\t\tunlistenGlobalResize()\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport class ScrollableWindowContainer extends ScrollableContainer {\r\n\t/**\r\n\t * Constructs a new window \"scrollable container\".\r\n\t * @param {func} getItemsContainerElement — Returns items \"container\" element.\r\n\t */\r\n\tconstructor(getItemsContainerElement) {\r\n\t\tsuper(() => window, getItemsContainerElement)\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the current scroll position.\r\n\t * @return {number}\r\n\t */\r\n\tgetScrollY() {\r\n\t\t// `window.scrollY` is not supported by Internet Explorer.\r\n\t\treturn window.pageYOffset\r\n\t}\r\n\r\n\t/**\r\n\t * Returns \"scrollable container\" width,\r\n\t * i.e. the available width for its content.\r\n\t * @return {number}\r\n\t */\r\n\tgetWidth() {\r\n\t\t// https://javascript.info/size-and-scroll-window\r\n\t\t// `<!DOCTYPE html>` may be required in order for this to work correctly.\r\n\t\t// Includes scrollbar (if any).\r\n\t\t// Correctly reflects page zoom in iOS Safari.\r\n\t\t// (scales screen width accordingly).\r\n\t\t// But, includes scrollbar (if any).\r\n\t\treturn window.innerWidth\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the height of the \"scrollable container\" itself.\r\n\t * Not to be confused with the height of \"scrollable container\"'s content.\r\n\t * @return {number}\r\n\t */\r\n\tgetHeight() {\r\n\t\t// https://javascript.info/size-and-scroll-window\r\n\t\t// `<!DOCTYPE html>` is required in order for this to work correctly.\r\n\t\t// Without it, the returned height would be the height of the entire document.\r\n\t\t// Includes scrollbar (if any).\r\n\t\t// Supports iOS Safari's dynamically shown/hidden\r\n\t\t// top URL bar and bottom actions bar.\r\n\t\t// https://codesandbox.io/s/elegant-fog-iddrh\r\n\t\t// Tested in IE 11.\r\n\t\t// It also correctly reflects page zoom in iOS Safari.\r\n\t\t// (scales screen height accordingly).\r\n\t\t// But, includes scrollbar (if any).\r\n\t\treturn window.innerHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a \"top offset\" of an items container element\r\n\t * relative to the \"scrollable container\"'s top edge.\r\n\t * @return {number}\r\n\t */\r\n\tgetItemsContainerTopOffset() {\r\n\t\tconst borderTopWidth = document.clientTop || document.body.clientTop || 0\r\n\t\treturn this.getItemsContainerElement().getBoundingClientRect().top + this.getScrollY() - borderTopWidth\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a \"resize\" event listener to the \"scrollable container\".\r\n\t * @param {onScroll} Should be called whenever the \"scrollable container\"'s width or height (potentially) changes.\r\n\t * @return {function} Returns a function that stops listening.\r\n\t */\r\n\tonResize(onResize) {\r\n\t\treturn addGlobalResizeListener(onResize, {\r\n\t\t\titemsContainerElement: this.getItemsContainerElement()\r\n\t\t})\r\n\t}\r\n\r\n\t// isVisible() {\r\n\t// \treturn true\r\n\t// }\r\n}\r\n\r\n/**\r\n * Adds a \"resize\" event listener to the `window`.\r\n * @param {onResize} Should be called whenever the \"scrollable container\"'s width or height (potentially) changes.\r\n * @param {Element} options.itemsContainerElement — The items \"container\" element, which is not the same as the \"scrollable container\" element. For example, \"scrollable container\" could be resized while the list element retaining its size. One such example is a user entering fullscreen mode on an HTML5 `<video/>` element: in that case, a \"resize\" event is triggered on a window, and window dimensions change to the user's screen size, but such \"resize\" event can be ignored because the list isn't visible until the user exits fullscreen mode.\r\n * @return {function} Returns a function that stops listening.\r\n */\r\nfunction addGlobalResizeListener(onResize, { itemsContainerElement }) {\r\n\tconst onResizeListener = () => {\r\n\t\t// By default, `VirtualScroller` always performs a re-layout\r\n\t\t// on window `resize` event. But browsers (Chrome, Firefox)\r\n\t\t// [trigger](https://developer.mozilla.org/en-US/docs/Web/API/Window/fullScreen#Notes)\r\n\t\t// window `resize` event also when a user switches into fullscreen mode:\r\n\t\t// for example, when a user is watching a video and double-clicks on it\r\n\t\t// to maximize it. And also when the user goes out of the fullscreen mode.\r\n\t\t// Each such fullscreen mode entering/exiting will trigger window `resize`\r\n\t\t// event that will it turn trigger a re-layout of `VirtualScroller`,\r\n\t\t// resulting in bad user experience. To prevent that, such cases are filtered out.\r\n\t\t// Some other workaround:\r\n\t\t// https://stackoverflow.com/questions/23770449/embedded-youtube-video-fullscreen-or-causing-resize\r\n\t\tif (document.fullscreenElement) {\r\n\t\t\t// If the fullscreened element doesn't contain the list\r\n\t\t\t// (and is not the list itself), then the layout hasn't been affected,\r\n\t\t\t// so don't perform a re-layout.\r\n\t\t\t//\r\n\t\t\t// For example, suppose there's a list of items, and some item contains a video.\r\n\t\t\t// If, upon clicking such video, it plays inline, and the user enters\r\n\t\t\t// fullscreen mode while playing such inline video, then the layout won't be\r\n\t\t\t// affected, and so such `resize` event should be ignored: when\r\n\t\t\t// `document.fullscreenElement` is in a separate \"branch\" relative to the\r\n\t\t\t// `container`.\r\n\t\t\t//\r\n\t\t\t// Another scenario: suppose that upon click, the video doesn't play inline,\r\n\t\t\t// but instead a \"Slideshow\" component is open, with the video shown at the\r\n\t\t\t// center of the screen in an overlay. If then the user enters fullscreen mode,\r\n\t\t\t// the layout wouldn't be affected too, so such `resize` event should also be\r\n\t\t\t// ignored: when `document.fullscreenElement` is inside the `container`.\r\n\t\t\t//\r\n\t\t\tif (document.fullscreenElement.contains(itemsContainerElement)) {\r\n\t\t\t\t// The element is either the `container`'s ancestor,\r\n\t\t\t\t// Or is the `container` itself.\r\n\t\t\t\t// (`a.contains(b)` includes the `a === b` case).\r\n\t\t\t\t// So the `resize` event will affect the `container`'s dimensions.\r\n\t\t\t} else {\r\n\t\t\t\t// The element is either inside the `container`,\r\n\t\t\t\t// Or is in a separate tree.\r\n\t\t\t\t// So the `resize` event won't affect the `container`'s dimensions.\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tonResize()\r\n\t}\r\n\twindow.addEventListener('resize', onResizeListener)\r\n\treturn () => window.removeEventListener('resize', onResizeListener)\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAqBA,mB;EACpB;AACD;AACA;AACA;AACA;EACC,6BAAYC,UAAZ,EAAwBC,wBAAxB,EAAkD;IAAA;;IACjD,KAAKD,UAAL,GAAkBA,UAAlB;IACA,KAAKC,wBAAL,G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AAsBuB,QAAQ,CAACC,IAAT,CAAcxB,SAApC,IAAiD,CAAxE;MACA,OAAO,KAAKV,wBAAL,GAAgCO,qBAAhC,GAAwDC,GAAxD,GAA8D,KAAKI,UAAL,EAA9D,GAAkFoB,cAAzF;IACA;IAED;AACD;AACA;AACA;AACA;;;;WACC,kBAASf,UAAT,EAAmB;MAClB,OAAOQ,uBAAuB,CAACR,UAAD,EAAW;QACxCS,qBAAqB,EAAE,KAAK1B,wBAAL;MADiB,CAAX,CAA9B;IAGA,C,CAED;IACA;IACA;;;;;EA5E8CF,mB;AA+E/C;AACA;AACA;AACA;AACA;AACA;;;;;AACA,SAAS2B,uBAAT,CAAiCR,QAAjC,QAAsE;EAAA,IAAzBS,qBAAyB,QAAzBA,qBAAyB;;EACrE,IAAMS,gBAAgB,GAAG,SAAnBA,gBAAmB,GAAM;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAIF,QAAQ,CAACG,iBAAb,EAAgC;MAC/B;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,IAAIH,QAAQ,CAACG,iBAAT,CAA2BC,QAA3B,CAAoCX,qBAApC,CAAJ,EAAgE,CAC/D;QACA;QACA;QACA;MACA,CALD,MAKO;QACN;QACA;QACA;QACA;MACA;IACD;;IACDT,QAAQ;EACR,CA3CD;;EA4CAW,MAAM,CAACb,gBAAP,CAAwB,QAAxB,EAAkCoB,gBAAlC;EACA,OAAO;IAAA,OAAMP,MAAM,CAACZ,mBAAP,CAA2B,QAA3B,EAAqCmB,gBAArC,CAAN;EAAA,CAAP;AACA"}
|
|
1
|
+
{"version":3,"file":"ScrollableContainer.js","names":["ScrollableContainer","getElement","getItemsContainerElement","scrollTop","scrollY","scrollTo","ScrollableContainerNotReadyError","offsetWidth","offsetHeight","scrollableContainerTop","getBoundingClientRect","top","scrollableContainerBorderTopWidth","clientTop","itemsContainerTop","getScrollY","onScrollListener","element","addEventListener","removeEventListener","onResize","unobserve","ResizeObserver","resizeObserver","entries","entry","observe","unlistenGlobalResize","addGlobalResizeListener","itemsContainerElement","ScrollableWindowContainer","window","pageYOffset","innerWidth","innerHeight","borderTopWidth","document","body","onResizeListener","fullscreenElement","contains"],"sources":["../../source/DOM/ScrollableContainer.js"],"sourcesContent":["import ScrollableContainerNotReadyError from '../ScrollableContainerNotReadyError.js'\r\n\r\nexport default class ScrollableContainer {\r\n\t/**\r\n\t * Constructs a new \"scrollable container\" from an element.\r\n\t * @param {func} getElement — Returns the scrollable container element.\r\n\t * @param {func} getItemsContainerElement — Returns items \"container\" element.\r\n\t */\r\n\tconstructor(getElement, getItemsContainerElement) {\r\n\t\tthis.getElement = getElement\r\n\t\tthis.getItemsContainerElement = getItemsContainerElement\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the current scroll position.\r\n\t * @return {number}\r\n\t */\r\n\tgetScrollY() {\r\n\t\treturn this.getElement().scrollTop\r\n\t}\r\n\r\n\t/**\r\n\t * Scrolls to a specific position.\r\n\t * @param {number} scrollY\r\n\t */\r\n\tscrollToY(scrollY) {\r\n\t\t// IE 11 doesn't seem to have a `.scrollTo()` method.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/10\r\n\t\t// https://stackoverflow.com/questions/39908825/window-scrollto-is-not-working-in-internet-explorer-11\r\n\t\tif (this.getElement().scrollTo) {\r\n\t\t\tthis.getElement().scrollTo(0, scrollY)\r\n\t\t} else {\r\n\t\t\tthis.getElement().scrollTop = scrollY\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns \"scrollable container\" width,\r\n\t * i.e. the available width for its content.\r\n\t * @return {number}\r\n\t */\r\n\tgetWidth() {\r\n\t\tif (!this.getElement()) {\r\n\t\t\tthrow new ScrollableContainerNotReadyError()\r\n\t\t}\r\n\t\treturn this.getElement().offsetWidth\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the height of the \"scrollable container\" itself.\r\n\t * Not to be confused with the height of \"scrollable container\"'s content.\r\n\t * @return {number}\r\n\t */\r\n\tgetHeight() {\r\n\t\tif (!this.getElement()) {\r\n\t\t\tthrow new ScrollableContainerNotReadyError()\r\n\t\t}\r\n\t\t// if (!this.getElement() && !precise) {\r\n\t\t// \treturn getScreenHeight()\r\n\t\t// }\r\n\t\treturn this.getElement().offsetHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a \"top offset\" of an items container element\r\n\t * relative to the \"scrollable container\"'s top edge.\r\n\t * @return {number}\r\n\t */\r\n\tgetItemsContainerTopOffset() {\r\n\t\tconst scrollableContainerTop = this.getElement().getBoundingClientRect().top\r\n\t\tconst scrollableContainerBorderTopWidth = this.getElement().clientTop\r\n\t\tconst itemsContainerTop = this.getItemsContainerElement().getBoundingClientRect().top\r\n\t\treturn (itemsContainerTop - scrollableContainerTop) + this.getScrollY() - scrollableContainerBorderTopWidth\r\n\t}\r\n\r\n\t// isVisible() {\r\n\t// \tconst { top, bottom } = this.getElement().getBoundingClientRect()\r\n\t// \treturn bottom > 0 && top < getScreenHeight()\r\n\t// }\r\n\r\n\t/**\r\n\t * Adds a \"scroll\" event listener to the \"scrollable container\".\r\n\t * @param {onScrollListener} Should be called whenever the scroll position inside the \"scrollable container\" (potentially) changes.\r\n\t * @return {function} Returns a function that stops listening.\r\n\t */\r\n\tonScroll(onScrollListener) {\r\n\t\tconst element = this.getElement()\r\n\t\telement.addEventListener('scroll', onScrollListener)\r\n\t\treturn () => element.removeEventListener('scroll', onScrollListener)\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a \"resize\" event listener to the \"scrollable container\".\r\n\t * @param {onResize} Should be called whenever the \"scrollable container\"'s width or height (potentially) changes.\r\n * @return {function} Returns a function that stops listening.\r\n\t */\r\n\tonResize(onResize) {\r\n\t\t// Watches \"scrollable container\"'s dimensions via a `ResizeObserver`.\r\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver\r\n\t\t// https://web.dev/resize-observer/\r\n\t\tlet unobserve\r\n\t\tif (typeof ResizeObserver !== 'undefined') {\r\n\t\t\tconst resizeObserver = new ResizeObserver((entries) => {\r\n\t\t\t\t// \"one entry per observed element\".\r\n\t\t\t\t// https://web.dev/resize-observer/\r\n\t\t\t\t// `entry.target === this.getElement()`.\r\n\t\t\t\tconst entry = entries[0]\r\n\t\t\t\t// // If `entry.contentBoxSize` property is supported by the web browser.\r\n\t\t\t\t// if (entry.contentBoxSize) {\r\n\t\t\t\t// \t// https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentBoxSize\r\n\t\t\t\t// \tconst width = entry.contentBoxSize.inlineSize\r\n\t\t\t\t// \tconst height = entry.contentBoxSize.blockSize\r\n\t\t\t\t// }\r\n\t\t\t\tonResize()\r\n\t\t\t})\r\n\t\t\tconst element = this.getElement()\r\n\t\t\tresizeObserver.observe(element)\r\n\t\t\tunobserve = () => resizeObserver.unobserve(element)\r\n\t\t}\r\n\t\t// I guess, if window is resized, `onResize()` will be triggered twice:\r\n\t\t// once for window resize, and once for the scrollable container resize.\r\n\t\t// But `onResize()` also has an internal check: if the container size\r\n\t\t// hasn't changed since the previous time `onResize()` has been called,\r\n\t\t// then `onResize()` doesn't do anything, so, I guess, there shouldn't be\r\n\t\t// any \"performance implications\" of running the listener twice in such case.\r\n\t\tconst unlistenGlobalResize = addGlobalResizeListener(onResize, {\r\n\t\t\titemsContainerElement: this.getItemsContainerElement()\r\n\t\t})\r\n\t\treturn () => {\r\n\t\t\tif (unobserve) {\r\n\t\t\t\tunobserve()\r\n\t\t\t}\r\n\t\t\tunlistenGlobalResize()\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport class ScrollableWindowContainer extends ScrollableContainer {\r\n\t/**\r\n\t * Constructs a new window \"scrollable container\".\r\n\t * @param {func} getItemsContainerElement — Returns items \"container\" element.\r\n\t */\r\n\tconstructor(getItemsContainerElement) {\r\n\t\tsuper(() => window, getItemsContainerElement)\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the current scroll position.\r\n\t * @return {number}\r\n\t */\r\n\tgetScrollY() {\r\n\t\t// `window.scrollY` is not supported by Internet Explorer.\r\n\t\treturn window.pageYOffset\r\n\t}\r\n\r\n\t/**\r\n\t * Returns \"scrollable container\" width,\r\n\t * i.e. the available width for its content.\r\n\t * @return {number}\r\n\t */\r\n\tgetWidth() {\r\n\t\t// https://javascript.info/size-and-scroll-window\r\n\t\t// `<!DOCTYPE html>` may be required in order for this to work correctly.\r\n\t\t// Includes scrollbar (if any).\r\n\t\t// Correctly reflects page zoom in iOS Safari.\r\n\t\t// (scales screen width accordingly).\r\n\t\t// But, includes scrollbar (if any).\r\n\t\treturn window.innerWidth\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the height of the \"scrollable container\" itself.\r\n\t * Not to be confused with the height of \"scrollable container\"'s content.\r\n\t * @return {number}\r\n\t */\r\n\tgetHeight() {\r\n\t\t// https://javascript.info/size-and-scroll-window\r\n\t\t// `<!DOCTYPE html>` is required in order for this to work correctly.\r\n\t\t// Without it, the returned height would be the height of the entire document.\r\n\t\t// Includes scrollbar (if any).\r\n\t\t// Supports iOS Safari's dynamically shown/hidden\r\n\t\t// top URL bar and bottom actions bar.\r\n\t\t// https://codesandbox.io/s/elegant-fog-iddrh\r\n\t\t// Tested in IE 11.\r\n\t\t// It also correctly reflects page zoom in iOS Safari.\r\n\t\t// (scales screen height accordingly).\r\n\t\t// But, includes scrollbar (if any).\r\n\t\treturn window.innerHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a \"top offset\" of an items container element\r\n\t * relative to the \"scrollable container\"'s top edge.\r\n\t * @return {number}\r\n\t */\r\n\tgetItemsContainerTopOffset() {\r\n\t\tconst borderTopWidth = document.clientTop || document.body.clientTop || 0\r\n\t\treturn this.getItemsContainerElement().getBoundingClientRect().top + this.getScrollY() - borderTopWidth\r\n\t}\r\n\r\n\t/**\r\n\t * Adds a \"resize\" event listener to the \"scrollable container\".\r\n\t * @param {onScroll} Should be called whenever the \"scrollable container\"'s width or height (potentially) changes.\r\n\t * @return {function} Returns a function that stops listening.\r\n\t */\r\n\tonResize(onResize) {\r\n\t\treturn addGlobalResizeListener(onResize, {\r\n\t\t\titemsContainerElement: this.getItemsContainerElement()\r\n\t\t})\r\n\t}\r\n\r\n\t// isVisible() {\r\n\t// \treturn true\r\n\t// }\r\n}\r\n\r\n/**\r\n * Adds a \"resize\" event listener to the `window`.\r\n * @param {onResize} Should be called whenever the \"scrollable container\"'s width or height (potentially) changes.\r\n * @param {Element} options.itemsContainerElement — The items \"container\" element, which is not the same as the \"scrollable container\" element. For example, \"scrollable container\" could be resized while the list element retaining its size. One such example is a user entering fullscreen mode on an HTML5 `<video/>` element: in that case, a \"resize\" event is triggered on a window, and window dimensions change to the user's screen size, but such \"resize\" event can be ignored because the list isn't visible until the user exits fullscreen mode.\r\n * @return {function} Returns a function that stops listening.\r\n */\r\nfunction addGlobalResizeListener(onResize, { itemsContainerElement }) {\r\n\tconst onResizeListener = () => {\r\n\t\t// By default, `VirtualScroller` always performs a re-layout\r\n\t\t// on window `resize` event. But browsers (Chrome, Firefox)\r\n\t\t// [trigger](https://developer.mozilla.org/en-US/docs/Web/API/Window/fullScreen#Notes)\r\n\t\t// window `resize` event also when a user switches into fullscreen mode:\r\n\t\t// for example, when a user is watching a video and double-clicks on it\r\n\t\t// to maximize it. And also when the user goes out of the fullscreen mode.\r\n\t\t// Each such fullscreen mode entering/exiting will trigger window `resize`\r\n\t\t// event that will it turn trigger a re-layout of `VirtualScroller`,\r\n\t\t// resulting in bad user experience. To prevent that, such cases are filtered out.\r\n\t\t// Some other workaround:\r\n\t\t// https://stackoverflow.com/questions/23770449/embedded-youtube-video-fullscreen-or-causing-resize\r\n\t\tif (document.fullscreenElement) {\r\n\t\t\t// If the fullscreened element doesn't contain the list\r\n\t\t\t// (and is not the list itself), then the layout hasn't been affected,\r\n\t\t\t// so don't perform a re-layout.\r\n\t\t\t//\r\n\t\t\t// For example, suppose there's a list of items, and some item contains a video.\r\n\t\t\t// If, upon clicking such video, it plays inline, and the user enters\r\n\t\t\t// fullscreen mode while playing such inline video, then the layout won't be\r\n\t\t\t// affected, and so such `resize` event should be ignored: when\r\n\t\t\t// `document.fullscreenElement` is in a separate \"branch\" relative to the\r\n\t\t\t// `container`.\r\n\t\t\t//\r\n\t\t\t// Another scenario: suppose that upon click, the video doesn't play inline,\r\n\t\t\t// but instead a \"Slideshow\" component is open, with the video shown at the\r\n\t\t\t// center of the screen in an overlay. If then the user enters fullscreen mode,\r\n\t\t\t// the layout wouldn't be affected too, so such `resize` event should also be\r\n\t\t\t// ignored: when `document.fullscreenElement` is inside the `container`.\r\n\t\t\t//\r\n\t\t\tif (document.fullscreenElement.contains(itemsContainerElement)) {\r\n\t\t\t\t// The element is either the `container`'s ancestor,\r\n\t\t\t\t// Or is the `container` itself.\r\n\t\t\t\t// (`a.contains(b)` includes the `a === b` case).\r\n\t\t\t\t// So the `resize` event will affect the `container`'s dimensions.\r\n\t\t\t} else {\r\n\t\t\t\t// The element is either inside the `container`,\r\n\t\t\t\t// Or is in a separate tree.\r\n\t\t\t\t// So the `resize` event won't affect the `container`'s dimensions.\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tonResize()\r\n\t}\r\n\twindow.addEventListener('resize', onResizeListener)\r\n\treturn () => window.removeEventListener('resize', onResizeListener)\r\n}"],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;IAEqBA,mB;EACpB;AACD;AACA;AACA;AACA;EACC,6BAAYC,UAAZ,EAAwBC,wBAAxB,EAAkD;IAAA;;IACjD,KAAKD,UAAL,GAAkBA,UAAlB;IACA,KAAKC,wBAAL,GAAgCA,wBAAhC;EACA;EAED;AACD;AACA;AACA;;;;;WACC,sBAAa;MACZ,OAAO,KAAKD,UAAL,GAAkBE,SAAzB;IACA;IAED;AACD;AACA;AACA;;;;WACC,mBAAUC,OAAV,EAAmB;MAClB;MACA;MACA;MACA,IAAI,KAAKH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B,QAAQ,CAACC,IAAT,CAAcxB,SAApC,IAAiD,CAAxE;MACA,OAAO,KAAKX,wBAAL,GAAgCQ,qBAAhC,GAAwDC,GAAxD,GAA8D,KAAKI,UAAL,EAA9D,GAAkFoB,cAAzF;IACA;IAED;AACD;AACA;AACA;AACA;;;;WACC,kBAASf,UAAT,EAAmB;MAClB,OAAOQ,uBAAuB,CAACR,UAAD,EAAW;QACxCS,qBAAqB,EAAE,KAAK3B,wBAAL;MADiB,CAAX,CAA9B;IAGA,C,CAED;IACA;IACA;;;;;EA5E8CF,mB;AA+E/C;AACA;AACA;AACA;AACA;AACA;;;;;AACA,SAAS4B,uBAAT,CAAiCR,QAAjC,QAAsE;EAAA,IAAzBS,qBAAyB,QAAzBA,qBAAyB;;EACrE,IAAMS,gBAAgB,GAAG,SAAnBA,gBAAmB,GAAM;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAIF,QAAQ,CAACG,iBAAb,EAAgC;MAC/B;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,IAAIH,QAAQ,CAACG,iBAAT,CAA2BC,QAA3B,CAAoCX,qBAApC,CAAJ,EAAgE,CAC/D;QACA;QACA;QACA;MACA,CALD,MAKO;QACN;QACA;QACA;QACA;MACA;IACD;;IACDT,QAAQ;EACR,CA3CD;;EA4CAW,MAAM,CAACb,gBAAP,CAAwB,QAAxB,EAAkCoB,gBAAlC;EACA,OAAO;IAAA,OAAMP,MAAM,CAACZ,mBAAP,CAA2B,QAA3B,EAAqCmB,gBAArC,CAAN;EAAA,CAAP;AACA"}
|
package/commonjs/Layout.js
CHANGED
|
@@ -9,6 +9,10 @@ exports["default"] = exports.LAYOUT_REASON = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _debug = _interopRequireWildcard(require("./utility/debug.js"));
|
|
11
11
|
|
|
12
|
+
var _ScrollableContainerNotReadyError = _interopRequireDefault(require("./ScrollableContainerNotReadyError.js"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
|
|
12
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
17
|
|
|
14
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -28,7 +32,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
28
32
|
var Layout = /*#__PURE__*/function () {
|
|
29
33
|
function Layout(_ref) {
|
|
30
34
|
var bypass = _ref.bypass,
|
|
31
|
-
|
|
35
|
+
getInitialEstimatedItemHeight = _ref.getInitialEstimatedItemHeight,
|
|
36
|
+
getInitialEstimatedVisibleItemRowsCount = _ref.getInitialEstimatedVisibleItemRowsCount,
|
|
32
37
|
measureItemsBatchSize = _ref.measureItemsBatchSize,
|
|
33
38
|
getPrerenderMargin = _ref.getPrerenderMargin,
|
|
34
39
|
getVerticalSpacing = _ref.getVerticalSpacing,
|
|
@@ -45,7 +50,8 @@ var Layout = /*#__PURE__*/function () {
|
|
|
45
50
|
_classCallCheck(this, Layout);
|
|
46
51
|
|
|
47
52
|
this.bypass = bypass;
|
|
48
|
-
this.
|
|
53
|
+
this.getInitialEstimatedItemHeight = getInitialEstimatedItemHeight;
|
|
54
|
+
this.getInitialEstimatedVisibleItemRowsCount = getInitialEstimatedVisibleItemRowsCount;
|
|
49
55
|
this.measureItemsBatchSize = measureItemsBatchSize;
|
|
50
56
|
this.getPrerenderMargin = getPrerenderMargin;
|
|
51
57
|
this.getVerticalSpacing = getVerticalSpacing;
|
|
@@ -65,23 +71,50 @@ var Layout = /*#__PURE__*/function () {
|
|
|
65
71
|
//
|
|
66
72
|
|
|
67
73
|
this.getPreviouslyCalculatedLayout = getPreviouslyCalculatedLayout;
|
|
68
|
-
}
|
|
74
|
+
} // React `<VirtualScroller/>` component attempts to create the initial state
|
|
75
|
+
// before the component tree has mounted. This could result in an inability to
|
|
76
|
+
// calculate some initial layout values like `columnsCount` or `lastShownItemIndex`.
|
|
77
|
+
// Such errors aren't considered critical because layout will be re-calculated
|
|
78
|
+
// after the component mounts. The workaround is to use some sane default values
|
|
79
|
+
// until the scrollable container has mounted.
|
|
80
|
+
|
|
69
81
|
|
|
70
82
|
_createClass(Layout, [{
|
|
83
|
+
key: "getInitialLayoutValueWithFallback",
|
|
84
|
+
value: function getInitialLayoutValueWithFallback(name, getValue, defaultValue) {
|
|
85
|
+
try {
|
|
86
|
+
return getValue();
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error instanceof _ScrollableContainerNotReadyError["default"]) {
|
|
89
|
+
(0, _debug["default"])('Couldn\'t calculate', name, 'before scrollable container is ready. Default to', defaultValue);
|
|
90
|
+
return defaultValue;
|
|
91
|
+
} else {
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
71
97
|
key: "getInitialLayoutValues",
|
|
72
98
|
value: function getInitialLayoutValues(_ref2) {
|
|
99
|
+
var _this = this;
|
|
100
|
+
|
|
73
101
|
var itemsCount = _ref2.itemsCount,
|
|
74
|
-
columnsCount = _ref2.columnsCount
|
|
102
|
+
columnsCount = _ref2.columnsCount,
|
|
103
|
+
beforeStart = _ref2.beforeStart;
|
|
75
104
|
var firstShownItemIndex;
|
|
76
105
|
var lastShownItemIndex; // If there're no items then `firstShownItemIndex` stays `undefined`.
|
|
77
106
|
|
|
78
107
|
if (itemsCount > 0) {
|
|
108
|
+
var getLastShownItemIndex = function getLastShownItemIndex() {
|
|
109
|
+
return _this.getInitialLastShownItemIndex({
|
|
110
|
+
itemsCount: itemsCount,
|
|
111
|
+
columnsCount: columnsCount,
|
|
112
|
+
firstShownItemIndex: firstShownItemIndex
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
79
116
|
firstShownItemIndex = 0;
|
|
80
|
-
lastShownItemIndex = this.
|
|
81
|
-
itemsCount: itemsCount,
|
|
82
|
-
columnsCount: columnsCount,
|
|
83
|
-
firstShownItemIndex: firstShownItemIndex
|
|
84
|
-
});
|
|
117
|
+
lastShownItemIndex = beforeStart ? this.getInitialLayoutValueWithFallback('lastShownItemIndex', getLastShownItemIndex, 0) : getLastShownItemIndex();
|
|
85
118
|
}
|
|
86
119
|
|
|
87
120
|
return {
|
|
@@ -109,6 +142,12 @@ var Layout = /*#__PURE__*/function () {
|
|
|
109
142
|
|
|
110
143
|
if (this.getMaxVisibleAreaHeight()) {
|
|
111
144
|
estimatedRowsCount = this.getEstimatedRowsCountForHeight(this.getMaxVisibleAreaHeight() + this.getPrerenderMargin());
|
|
145
|
+
} else if (this.getInitialEstimatedVisibleItemRowsCount) {
|
|
146
|
+
estimatedRowsCount = this.getInitialEstimatedVisibleItemRowsCount();
|
|
147
|
+
|
|
148
|
+
if (isNaN(estimatedRowsCount)) {
|
|
149
|
+
throw new Error('[virtual-scroller] `getEstimatedVisibleItemRowsCount()` must return a number');
|
|
150
|
+
}
|
|
112
151
|
}
|
|
113
152
|
|
|
114
153
|
return Math.min(firstShownItemIndex + (estimatedRowsCount * columnsCount - 1), itemsCount - 1);
|
|
@@ -136,7 +175,23 @@ var Layout = /*#__PURE__*/function () {
|
|
|
136
175
|
}, {
|
|
137
176
|
key: "getEstimatedItemHeight",
|
|
138
177
|
value: function getEstimatedItemHeight() {
|
|
139
|
-
|
|
178
|
+
var averageItemHeight = this.getAverageItemHeight();
|
|
179
|
+
|
|
180
|
+
if (averageItemHeight) {
|
|
181
|
+
return averageItemHeight;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (this.getInitialEstimatedItemHeight) {
|
|
185
|
+
var estimatedItemHeight = this.getInitialEstimatedItemHeight();
|
|
186
|
+
|
|
187
|
+
if (isNaN(estimatedItemHeight)) {
|
|
188
|
+
throw new Error('[virtual-scroller] `getInitialEstimatedItemHeight()` must return a number');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return estimatedItemHeight;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return 0;
|
|
140
195
|
}
|
|
141
196
|
}, {
|
|
142
197
|
key: "getLayoutUpdateForItemsDiff",
|
package/commonjs/Layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.js","names":["Layout","bypass","estimatedItemHeight","measureItemsBatchSize","getPrerenderMargin","getVerticalSpacing","getVerticalSpacingBeforeResize","getColumnsCount","getColumnsCountBeforeResize","getItemHeight","getItemHeightBeforeResize","getBeforeResizeItemsCount","getAverageItemHeight","getMaxVisibleAreaHeight","getPreviouslyCalculatedLayout","itemsCount","columnsCount","firstShownItemIndex","lastShownItemIndex","getInitialLastShownItemIndex","beforeItemsHeight","afterItemsHeight","estimatedRowsCount","getEstimatedRowsCountForHeight","Math","min","height","getEstimatedItemHeight","verticalSpacing","ceil","prependedItemsCount","appendedItemsCount","shouldRestoreScrollPosition","onResetGridLayout","averageItemHeight","appendedRowsCount","addedHeightAfter","prependedRowsCount","addedHeightBefore","warn","shownItemsCountBeforeItemsUpdate","afterItemsCount","i","nonMeasuredAreaHeight","indexOfTheFirstItemInTheRow","log","itemsCountToRenderForMeasurement","Infinity","undefined","firstNonMeasuredItemIndex","visibleAreaTop","visibleAreaBottom","indexes","_getShownItemIndex","fromIndex","findFirstShownItemIndex","getNonVisibleListShownItemIndexes","findLastShownItemIndex","parameters","beforeResize","Error","beforeResizeItemsCount","notFound","beforeResizeItemsHeight","floor","currentRowFirstItemIndex","hasMoreRows","verticalSpacingAfterCurrentRow","currentRowHeight","columnIndex","itemHeight","getItemNotMeasuredIndexes","max","itemsHeightFromFirstRowToThisRow","rowStepsIntoVisibleAreaTop","rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder","layout","beforeItemsCount","getBeforeItemsHeight","rowHeight","lastShownRowIndex","topOffsetInsideScrollableContainer","beforeResizeRowsCount","maxBeforeResizeRowsCount","beforeResizeRowIndex","itemRowIndex","rowIndex","LAYOUT_REASON","SCROLL","STOPPED_SCROLLING","MANUAL","STARTED","NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED","VIEWPORT_WIDTH_CHANGED","VIEWPORT_HEIGHT_CHANGED","VIEWPORT_SIZE_UNCHANGED","ITEM_HEIGHT_CHANGED","ITEMS_CHANGED","TOP_OFFSET_CHANGED"],"sources":["../source/Layout.js"],"sourcesContent":["import log, { warn } from './utility/debug.js'\r\n\r\nexport default class Layout {\r\n\tconstructor({\r\n\t\tbypass,\r\n\t\testimatedItemHeight,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tgetPrerenderMargin,\r\n\t\tgetVerticalSpacing,\r\n\t\tgetVerticalSpacingBeforeResize,\r\n\t\tgetColumnsCount,\r\n\t\tgetColumnsCountBeforeResize,\r\n\t\tgetItemHeight,\r\n\t\tgetItemHeightBeforeResize,\r\n\t\tgetBeforeResizeItemsCount,\r\n\t\tgetAverageItemHeight,\r\n\t\tgetMaxVisibleAreaHeight,\r\n\t\tgetPreviouslyCalculatedLayout\r\n\t}) {\r\n\t\tthis.bypass = bypass\r\n\t\tthis.estimatedItemHeight = estimatedItemHeight\r\n\t\tthis.measureItemsBatchSize = measureItemsBatchSize\r\n\t\tthis.getPrerenderMargin = getPrerenderMargin\r\n\t\tthis.getVerticalSpacing = getVerticalSpacing\r\n\t\tthis.getVerticalSpacingBeforeResize = getVerticalSpacingBeforeResize\r\n\t\tthis.getColumnsCount = getColumnsCount\r\n\t\tthis.getColumnsCountBeforeResize = getColumnsCountBeforeResize\r\n\t\tthis.getItemHeight = getItemHeight\r\n\t\tthis.getItemHeightBeforeResize = getItemHeightBeforeResize\r\n\t\tthis.getBeforeResizeItemsCount = getBeforeResizeItemsCount\r\n\t\tthis.getAverageItemHeight = getAverageItemHeight\r\n\t\tthis.getMaxVisibleAreaHeight = getMaxVisibleAreaHeight\r\n\t\t//\r\n\t\t// The \"previously calculated layout\" feature is not currently used.\r\n\t\t//\r\n\t\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t\t// rather than from scratch, which would be an optimization.\r\n\t\t//\r\n\t\tthis.getPreviouslyCalculatedLayout = getPreviouslyCalculatedLayout\r\n\t}\r\n\r\n\tgetInitialLayoutValues({\r\n\t\titemsCount,\r\n\t\tcolumnsCount\r\n\t}) {\r\n\t\tlet firstShownItemIndex\r\n\t\tlet lastShownItemIndex\r\n\t\t// If there're no items then `firstShownItemIndex` stays `undefined`.\r\n\t\tif (itemsCount > 0) {\r\n\t\t\tfirstShownItemIndex = 0\r\n\t\t\tlastShownItemIndex = this.getInitialLastShownItemIndex({\r\n\t\t\t\titemsCount,\r\n\t\t\t\tcolumnsCount,\r\n\t\t\t\tfirstShownItemIndex\r\n\t\t\t})\r\n\t\t}\r\n\t\treturn {\r\n\t\t\tbeforeItemsHeight: 0,\r\n\t\t\tafterItemsHeight: 0,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\tgetInitialLastShownItemIndex({\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tfirstShownItemIndex\r\n\t}) {\r\n\t\tif (this.bypass) {\r\n\t\t\treturn itemsCount - 1\r\n\t\t}\r\n\t\t// On server side, at initialization time,\r\n\t\t// `scrollableContainer` is `undefined`,\r\n\t\t// so default to `1` estimated rows count.\r\n\t\tlet estimatedRowsCount = 1\r\n\t\tif (this.getMaxVisibleAreaHeight()) {\r\n\t\t\testimatedRowsCount = this.getEstimatedRowsCountForHeight(this.getMaxVisibleAreaHeight() + this.getPrerenderMargin())\r\n\t\t}\r\n\t\treturn Math.min(\r\n\t\t\tfirstShownItemIndex + (estimatedRowsCount * columnsCount - 1),\r\n\t\t\titemsCount - 1\r\n\t\t)\r\n\t}\r\n\r\n\tgetEstimatedRowsCountForHeight(height) {\r\n\t\tconst estimatedItemHeight = this.getEstimatedItemHeight()\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\t\tif (estimatedItemHeight) {\r\n\t\t\treturn Math.ceil((height + verticalSpacing) / (estimatedItemHeight + verticalSpacing))\r\n\t\t} else {\r\n\t\t\t// If no items have been rendered yet, and no `estimatedItemHeight` option\r\n\t\t\t// has been passed, then default to `1` estimated rows count in any `height`.\r\n\t\t\treturn 1\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns estimated list item height.\r\n\t * (depends on which items have been previously rendered and measured).\r\n\t * @return {number}\r\n\t */\r\n\tgetEstimatedItemHeight() {\r\n\t\treturn this.getAverageItemHeight() || this.estimatedItemHeight || 0\r\n\t}\r\n\r\n\tgetLayoutUpdateForItemsDiff({\r\n\t\tfirstShownItemIndex,\r\n\t\tlastShownItemIndex,\r\n\t\tbeforeItemsHeight,\r\n\t\tafterItemsHeight\r\n\t}, {\r\n\t\tprependedItemsCount,\r\n\t\tappendedItemsCount\r\n\t}, {\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tshouldRestoreScrollPosition,\r\n\t\tonResetGridLayout\r\n\t}) {\r\n\t\t// const layoutUpdate = {}\r\n\r\n\t\t// If the layout stays the same, then simply increase\r\n\t\t// the top and bottom margins proportionally to the amount\r\n\t\t// of the items added.\r\n\t\tconst averageItemHeight = this.getAverageItemHeight()\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\r\n\t\tif (appendedItemsCount > 0) {\r\n\t\t\tconst appendedRowsCount = Math.ceil(appendedItemsCount / columnsCount)\r\n\t\t\tconst addedHeightAfter = appendedRowsCount * (verticalSpacing + averageItemHeight)\r\n\r\n\t\t\tafterItemsHeight += addedHeightAfter\r\n\r\n\t\t\t// layoutUpdate = {\r\n\t\t\t// \t...layoutUpdate,\r\n\t\t\t// \tafterItemsHeight\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\tif (prependedItemsCount > 0) {\r\n\t\t\tconst prependedRowsCount = Math.ceil(prependedItemsCount / columnsCount)\r\n\t\t\tconst addedHeightBefore = prependedRowsCount * (averageItemHeight + verticalSpacing)\r\n\r\n\t\t\tfirstShownItemIndex += prependedItemsCount\r\n\t\t\tlastShownItemIndex += prependedItemsCount\r\n\t\t\tbeforeItemsHeight += addedHeightBefore\r\n\r\n\t\t\t// If the currently shown items position on screen should be preserved\r\n\t\t\t// when prepending new items, then it means that:\r\n\t\t\t// * The current scroll position should be snapshotted.\r\n\t\t\t// * The current list height should be snapshotted.\r\n\t\t\t// * All prepended items should be shown so that their height could be\r\n\t\t\t// measured after they're rendered. Based on the prepended items' height,\r\n\t\t\t// the scroll position will be restored so that there's no \"jump of content\".\r\n\t\t\tif (shouldRestoreScrollPosition) {\r\n\t\t\t\tfirstShownItemIndex = 0\r\n\t\t\t\tbeforeItemsHeight = 0\r\n\t\t\t}\r\n\r\n\t\t\tif (prependedItemsCount % columnsCount > 0) {\r\n\t\t\t\t// Rows will be rebalanced as a result of prepending new items,\r\n\t\t\t\t// and row heights can change as a result, so re-layout items\r\n\t\t\t\t// after they've been measured (after the upcoming re-render).\r\n\t\t\t\t//\r\n\t\t\t\t// For example, consider a web page where item rows are `display: flex`.\r\n\t\t\t\t// Suppose there're 3 columns and it shows items from 4 to 6.\r\n\t\t\t\t//\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Apples are | Bananas | Cranberries |\r\n\t\t\t\t// | green | | |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Dates | Elderberry | Figs are |\r\n\t\t\t\t// | | | tasty |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t//\r\n\t\t\t\t// Now, 1 item gets prepended. As a result, all existing rows will have\r\n\t\t\t\t// a different set of items, which means that the row heights will change.\r\n\t\t\t\t//\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Zucchini | Apples are | Bananas |\r\n\t\t\t\t// | | green | |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Cranberries | Dates | Elderberry |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Figs |\r\n\t\t\t\t// | are tasty |\r\n\t\t\t\t// ---------------\r\n\t\t\t\t//\r\n\t\t\t\t// As it can be seen above, the second row's height has changed from 2 to 1.\r\n\t\t\t\t// Not only that, but `itemHeights` have changed as well, so if you thought\r\n\t\t\t\t// that the library could easily recalculate row heights using `Math.max()` — \r\n\t\t\t\t// turns out it's not always the case.\r\n\t\t\t\t//\r\n\t\t\t\t// There could be an explicit opt-in option for automatically recalculating\r\n\t\t\t\t// row heights, but I don't want to write code for such an extremely rare\r\n\t\t\t\t// use case. Instead, use the `getColumnsCount()` parameter function when\r\n\t\t\t\t// fetching previous items.\r\n\r\n\t\t\t\tonResetGridLayout()\r\n\r\n\t\t\t\twarn('~ Prepended items count', prependedItemsCount, 'is not divisible by Columns Count', columnsCount, '~')\r\n\t\t\t\twarn('Layout reset required')\r\n\r\n\t\t\t\tconst shownItemsCountBeforeItemsUpdate = lastShownItemIndex - firstShownItemIndex + 1\r\n\r\n\t\t\t\tfirstShownItemIndex = 0\r\n\t\t\t\tbeforeItemsHeight = 0\r\n\r\n\t\t\t\tif (!shouldRestoreScrollPosition) {\r\n\t\t\t\t\t// Limit shown items count if too many items have been prepended.\r\n\t\t\t\t\tif (prependedItemsCount > shownItemsCountBeforeItemsUpdate) {\r\n\t\t\t\t\t\tlastShownItemIndex = this.getInitialLastShownItemIndex({\r\n\t\t\t\t\t\t\titemsCount,\r\n\t\t\t\t\t\t\tcolumnsCount,\r\n\t\t\t\t\t\t\tfirstShownItemIndex\r\n\t\t\t\t\t\t})\r\n\r\n\t\t\t\t\t\t// Approximate `afterItemsHeight` calculation.\r\n\t\t\t\t\t\tconst afterItemsCount = itemsCount - (lastShownItemIndex + 1)\r\n\t\t\t\t\t\tafterItemsHeight = Math.ceil(afterItemsCount / columnsCount) * (verticalSpacing + averageItemHeight)\r\n\r\n\t\t\t\t\t\t// layoutUpdate = {\r\n\t\t\t\t\t\t// \t...layoutUpdate,\r\n\t\t\t\t\t\t// \tafterItemsHeight\r\n\t\t\t\t\t\t// }\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// layoutUpdate = {\r\n\t\t\t// \t...layoutUpdate,\r\n\t\t\t// \tbeforeItemsHeight,\r\n\t\t\t// \tfirstShownItemIndex,\r\n\t\t\t// \tlastShownItemIndex\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\t// return layoutUpdate\r\n\r\n\t\t// Overwrite all four props in all scenarios.\r\n\t\t// The reason is that only this way subsequent `setItems()` calls\r\n\t\t// will be truly \"stateless\" when a chain of `setItems()` calls\r\n\t\t// could be replaced with just the last one in a scenario when\r\n\t\t// `updateState()` calls are \"asynchronous\" (delayed execution).\r\n\t\t//\r\n\t\t// So, for example, the user calls `setItems()` with one set of items.\r\n\t\t// A `updateState()` call has been dispatched but the `state` hasn't been updated yet.\r\n\t\t// Then the user calls `setItems()` with another set of items.\r\n\t\t// If this function only returned a minimal set of properties that actually change,\r\n\t\t// the other layout properties of the second `setItems()` call wouldn't overwrite the ones\r\n\t\t// scheduled for update during the first `setItems()` call, resulting in an inconsistent `state`.\r\n\t\t//\r\n\t\t// For example, the first `setItems()` call does a `updateState()` call where it updates\r\n\t\t// `afterItemsHeight`, and then the second `setItems()` call only updates `beforeItemsHeight`\r\n\t\t// and `firstShownItemIndex` and `lastShownItemIndex`. If the second `setItems()` call was to\r\n\t\t// overwrite any effects of the pending-but-not-yet-applied first `setItems()` call, it would\r\n\t\t// have to call `updateState()` with an `afterItemsHeight` property too, even though it hasn't change.\r\n\t\t// That would be just to revert the change to `afterItemsHeight` state property already scheduled\r\n\t\t// by the first `setItems()` call.\r\n\t\t//\r\n\t\treturn {\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t// If an item that hasn't been shown (and measured) yet is encountered\r\n\t// then show such item and then retry after it has been measured.\r\n\tgetItemNotMeasuredIndexes(i, {\r\n\t\titemsCount,\r\n\t\tfirstShownItemIndex,\r\n\t\tnonMeasuredAreaHeight,\r\n\t\tindexOfTheFirstItemInTheRow\r\n\t}) {\r\n\t\tlog('Item index', i, 'height is required for calculations but hasn\\'t been measured yet. Mark the item as \"shown\", rerender the list, measure the item\\'s height and redo the layout.')\r\n\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\r\n\t\tconst itemsCountToRenderForMeasurement = Math.min(\r\n\t\t\tthis.getEstimatedRowsCountForHeight(nonMeasuredAreaHeight) * columnsCount,\r\n\t\t\tthis.measureItemsBatchSize || Infinity,\r\n\t\t)\r\n\r\n\t\tif (firstShownItemIndex === undefined) {\r\n\t\t\tfirstShownItemIndex = indexOfTheFirstItemInTheRow\r\n\t\t}\r\n\r\n\t\tconst lastShownItemIndex = Math.min(\r\n\t\t\tindexOfTheFirstItemInTheRow + itemsCountToRenderForMeasurement - 1,\r\n\t\t\t// Guard against index overflow.\r\n\t\t\titemsCount - 1\r\n\t\t)\r\n\r\n\t\treturn {\r\n\t\t\tfirstNonMeasuredItemIndex: i,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Finds the indexes of the currently visible items.\r\n\t * @return {object} `{ firstShownItemIndex: number, lastShownItemIndex: number, firstNonMeasuredItemIndex: number? }`\r\n\t */\r\n\tgetShownItemIndexes({\r\n\t\titemsCount,\r\n\t\tvisibleAreaTop,\r\n\t\tvisibleAreaBottom\r\n\t}) {\r\n\t\tlet indexes = this._getShownItemIndex({\r\n\t\t\titemsCount,\r\n\t\t\tfromIndex: 0,\r\n\t\t\tvisibleAreaTop,\r\n\t\t\tvisibleAreaBottom,\r\n\t\t\tfindFirstShownItemIndex: true\r\n\t\t})\r\n\r\n\t\tif (indexes === null) {\r\n\t\t\treturn this.getNonVisibleListShownItemIndexes()\r\n\t\t}\r\n\r\n\t\tif (indexes.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\treturn indexes\r\n\t\t}\r\n\r\n\t\tconst { firstShownItemIndex, beforeItemsHeight } = indexes\r\n\r\n\t\tindexes = this._getShownItemIndex({\r\n\t\t\titemsCount,\r\n\t\t\tfromIndex: firstShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tvisibleAreaTop,\r\n\t\t\tvisibleAreaBottom,\r\n\t\t\tfindLastShownItemIndex: true\r\n\t\t})\r\n\r\n\t\tif (indexes === null) {\r\n\t\t\treturn this.getNonVisibleListShownItemIndexes()\r\n\t\t}\r\n\r\n\t\tif (indexes.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\treturn indexes\r\n\t\t}\r\n\r\n\t\tconst { lastShownItemIndex } = indexes\r\n\r\n\t\treturn {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t_getShownItemIndex(parameters) {\r\n\t\tconst {\r\n\t\t\tbeforeResize,\r\n\t\t\titemsCount,\r\n\t\t\tvisibleAreaTop,\r\n\t\t\tvisibleAreaBottom,\r\n\t\t\tfindFirstShownItemIndex,\r\n\t\t\tfindLastShownItemIndex,\r\n\t\t\t// backwards\r\n\t\t} = parameters\r\n\r\n\t\tlet {\r\n\t\t\tfromIndex,\r\n\t\t\tbeforeItemsHeight\r\n\t\t} = parameters\r\n\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\t\t//\r\n\t\t// If someone would attempt to use a \"previously calculated layout\" here\r\n\t\t// then `shownItemsHeight` would also have to be returned from this function:\r\n\t\t// the total height of all shown items including vertical spacing between them.\r\n\t\t//\r\n\t\t// If \"previously calculated layout\" would be used then it would first find\r\n\t\t// `firstShownItemIndex` and then find `lastShownItemIndex` as part of two\r\n\t\t// separate calls of this function, each with or without `backwards` flag,\r\n\t\t// depending on whether `visibleAreaTop` and `visibleAreBottom` have shifted up or down.\r\n\r\n\t\tlet firstShownItemIndex\r\n\t\tlet lastShownItemIndex\r\n\r\n\t\t// It's not always required to pass `beforeItemsHeight` parameter:\r\n\t\t// when `fromIndex` is `0`, it's also assumed to be `0`.\r\n\t\tif (fromIndex === 0) {\r\n\t\t\tbeforeItemsHeight = 0\r\n\t\t}\r\n\r\n\t\tif (beforeItemsHeight === undefined) {\r\n\t\t\tthrow new Error('[virtual-scroller] `beforeItemsHeight` not passed to `Layout.getShownItemIndexes()` when starting from index ' + fromIndex);\r\n\t\t}\r\n\r\n\t\t// const backwards = false\r\n\t\t// while (backwards ? i >= 0 : i < itemsCount) {}\r\n\r\n\t\tif (!beforeResize) {\r\n\t\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\t\t\tif (beforeResizeItemsCount > fromIndex) {\r\n\t\t\t\t// First search for the item in \"before resize\" items.\r\n\t\t\t\tconst {\r\n\t\t\t\t\tnotFound,\r\n\t\t\t\t\tbeforeItemsHeight: beforeResizeItemsHeight,\r\n\t\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\t\tlastShownItemIndex\r\n\t\t\t\t} = this._getShownItemIndex({\r\n\t\t\t\t\t...parameters,\r\n\t\t\t\t\tbeforeResize: true,\r\n\t\t\t\t\titemsCount: beforeResizeItemsCount\r\n\t\t\t\t})\r\n\r\n\t\t\t\t// If the item was not found in \"before resize\" items\r\n\t\t\t\t// then search in regular items skipping \"before resize\" ones.\r\n\t\t\t\tif (notFound) {\r\n\t\t\t\t\tbeforeItemsHeight = beforeResizeItemsHeight\r\n\t\t\t\t\tfromIndex += beforeResizeItemsCount\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// If the item was found in \"before resize\" items\r\n\t\t\t\t\t// then return the result.\r\n\t\t\t\t\t// Rebalance first / last shown item indexes based on\r\n\t\t\t\t\t// the current columns count, if required.\r\n\t\t\t\t\tconst columnsCount = this.getColumnsCount()\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tfirstShownItemIndex: firstShownItemIndex === undefined\r\n\t\t\t\t\t\t\t? undefined\r\n\t\t\t\t\t\t\t: Math.floor(firstShownItemIndex / columnsCount) * columnsCount,\r\n\t\t\t\t\t\tlastShownItemIndex: lastShownItemIndex === undefined\r\n\t\t\t\t\t\t\t? undefined\r\n\t\t\t\t\t\t\t: Math.floor(lastShownItemIndex / columnsCount) * columnsCount,\r\n\t\t\t\t\t\tbeforeItemsHeight: beforeResizeItemsHeight\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst columnsCount = beforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\tconst verticalSpacing = beforeResize ? this.getVerticalSpacingBeforeResize() : this.getVerticalSpacing()\r\n\r\n\t\tlet i = fromIndex\r\n\t\twhile (i < itemsCount) {\r\n\t\t\tconst currentRowFirstItemIndex = i\r\n\r\n\t\t\tconst hasMoreRows = itemsCount > currentRowFirstItemIndex + columnsCount\r\n\t\t\tconst verticalSpacingAfterCurrentRow = hasMoreRows ? verticalSpacing : 0\r\n\r\n\t\t\tlet currentRowHeight = 0\r\n\r\n\t\t\t// Calculate current row height.\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < columnsCount && i < itemsCount) {\r\n\t\t\t\tconst itemHeight = beforeResize ? this.getItemHeightBeforeResize(i) : this.getItemHeight(i)\r\n\r\n\t\t\t\t// If this item hasn't been measured yet (or re-measured after a resize)\r\n\t\t\t\t// then mark it as the first non-measured one.\r\n\t\t\t\t//\r\n\t\t\t\t// Can't happen by definition when `beforeResize` parameter is `true`.\r\n\t\t\t\t//\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\treturn this.getItemNotMeasuredIndexes(i, {\r\n\t\t\t\t\t\titemsCount,\r\n\t\t\t\t\t\tfirstShownItemIndex: findLastShownItemIndex ? fromIndex : undefined,\r\n\t\t\t\t\t\tindexOfTheFirstItemInTheRow: currentRowFirstItemIndex,\r\n\t\t\t\t\t\tnonMeasuredAreaHeight: (visibleAreaBottom + this.getPrerenderMargin()) - beforeItemsHeight\r\n\t\t\t\t\t})\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcurrentRowHeight = Math.max(currentRowHeight, itemHeight)\r\n\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t\ti++\r\n\t\t\t}\r\n\r\n\t\t\tconst itemsHeightFromFirstRowToThisRow = beforeItemsHeight + currentRowHeight\r\n\r\n\t\t\tconst rowStepsIntoVisibleAreaTop = itemsHeightFromFirstRowToThisRow > visibleAreaTop - this.getPrerenderMargin()\r\n\t\t\tconst rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder = itemsHeightFromFirstRowToThisRow + verticalSpacingAfterCurrentRow >= visibleAreaBottom + this.getPrerenderMargin()\r\n\r\n\t\t\t// if (backwards) {\r\n\t\t\t// \tif (findFirstShownItemIndex) {\r\n\t\t\t// \t\tif (rowStepsOutOfVisibleAreaTop) {\r\n\t\t\t// \t\t\treturn {\r\n\t\t\t// \t\t\t\tfirstShownItemIndex: currentRowFirstItemIndex + columnsCount\r\n\t\t\t// \t\t\t}\r\n\t\t\t// \t\t}\r\n\t\t\t// \t} else if (findLastShownItemIndex) {\r\n\t\t\t// \t\tif (rowStepsIntoVisibleAreaBottom) {\r\n\t\t\t// \t\t\treturn {\r\n\t\t\t// \t\t\t\tlastShownItemIndex: currentRowFirstItemIndex + columnsCount - 1\r\n\t\t\t// \t\t\t}\r\n\t\t\t// \t\t}\r\n\t\t\t// \t}\r\n\t\t\t// }\r\n\r\n\t\t\tif (findFirstShownItemIndex) {\r\n\t\t\t\tif (rowStepsIntoVisibleAreaTop) {\r\n\t\t\t\t\t// If item is the first one visible in the viewport\r\n\t\t\t\t\t// then start showing items from this row.\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tfirstShownItemIndex: currentRowFirstItemIndex,\r\n\t\t\t\t\t\tbeforeItemsHeight\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else if (findLastShownItemIndex) {\r\n\t\t\t\tif (rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder) {\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tlastShownItemIndex: Math.min(\r\n\t\t\t\t\t\t\t// The index of the last item in the current row.\r\n\t\t\t\t\t\t\tcurrentRowFirstItemIndex + columnsCount - 1,\r\n\t\t\t\t\t\t\t// Guards against index overflow.\r\n\t\t\t\t\t\t\titemsCount - 1\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbeforeItemsHeight += currentRowHeight + verticalSpacingAfterCurrentRow\r\n\r\n\t\t\t// if (backwards) {\r\n\t\t\t// \t// Set `i` to be the first item of the current row.\r\n\t\t\t// \ti -= columnsCount\r\n\t\t\t// \tconst prevoiusRowIsBeforeResize = i - 1 < this.getBeforeResizeItemsCount()\r\n\t\t\t// \tconst previousRowColumnsCount = prevoiusRowIsBeforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\t\t// \t// Set `i` to be the first item of the previous row.\r\n\t\t\t// \ti -= previousRowColumnsCount\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\t// if (backwards) {\r\n\t\t// \tif (findFirstShownItemIndex) {\r\n\t\t// \t\twarn('The list is supposed to be visible but no visible item has been found (while traversing backwards)')\r\n\t\t// \t\treturn null\r\n\t\t// \t} else if (findLastShownItemIndex) {\r\n\t\t// \t\treturn {\r\n\t\t// \t\t\tfirstShownItemIndex: 0\r\n\t\t// \t\t}\r\n\t\t// \t}\r\n\t\t// }\r\n\r\n\t\tif (beforeResize) {\r\n\t\t\treturn {\r\n\t\t\t\tnotFound: true,\r\n\t\t\t\tbeforeItemsHeight\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// This case isn't supposed to happen but it could hypothetically happen\r\n\t\t// because the list height is measured from the user's screen and\r\n\t\t// not necessarily can be trusted.\r\n\t\tif (findFirstShownItemIndex) {\r\n\t\t\twarn('The list is supposed to be visible but no visible item has been found')\r\n\t\t\treturn null\r\n\t\t} else if (findLastShownItemIndex) {\r\n\t\t\treturn {\r\n\t\t\t\tlastShownItemIndex: itemsCount - 1\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetNonVisibleListShownItemIndexes() {\r\n\t\tconst layout = {\r\n\t\t\tfirstShownItemIndex: 0,\r\n\t\t\tlastShownItemIndex: 0\r\n\t\t}\r\n\t\tif (this.getItemHeight(0) === undefined) {\r\n\t\t\tlayout.firstNonMeasuredItemIndex = 0\r\n\t\t}\r\n\t\treturn layout\r\n\t}\r\n\r\n\t/**\r\n\t * Measures \"before\" items height.\r\n\t * @param {number} beforeItemsCount — Basically, first shown item index.\r\n\t * @return {number}\r\n\t */\r\n\tgetBeforeItemsHeight(\r\n\t\tbeforeItemsCount,\r\n\t\t{ beforeResize } = {}\r\n\t) {\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\r\n\t\tlet beforeItemsHeight = 0\r\n\t\tlet i = 0\r\n\r\n\t\tif (!beforeResize) {\r\n\t\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\r\n\t\t\tif (beforeResizeItemsCount > 0) {\r\n\t\t\t\t// First add all \"before resize\" item heights.\r\n\t\t\t\tbeforeItemsHeight = this.getBeforeItemsHeight(\r\n\t\t\t\t\t// `firstShownItemIndex` (called `beforeItemsCount`) could be greater than\r\n\t\t\t\t\t// `beforeResizeItemsCount` when the user scrolls down.\r\n\t\t\t\t\t// `firstShownItemIndex` (called `beforeItemsCount`) could be less than\r\n\t\t\t\t\t// `beforeResizeItemsCount` when the user scrolls up.\r\n\t\t\t\t\tMath.min(beforeItemsCount, beforeResizeItemsCount),\r\n\t\t\t\t\t{ beforeResize: true }\r\n\t\t\t\t)\r\n\t\t\t\ti = beforeResizeItemsCount\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst columnsCount = beforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\tconst verticalSpacing = beforeResize ? this.getVerticalSpacingBeforeResize() : this.getVerticalSpacing()\r\n\r\n\t\twhile (i < beforeItemsCount) {\r\n\t\t\tconst currentRowFirstItemIndex = i\r\n\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\t// Not checking for `itemsCount` overflow here because `i = beforeItemsCount`\r\n\t\t\t// can only start at the start of a row, meaning that when calculating\r\n\t\t\t// \"before items height\" it's not supposed to add item heights from the\r\n\t\t\t// last row of items because in that case it would have to iterate from\r\n\t\t\t// `i === beforeItemsCount` and that condition is already checked above.\r\n\t\t\t// while (i < itemsCount) {\r\n\t\t\twhile (columnIndex < columnsCount) {\r\n\t\t\t\tlet itemHeight = beforeResize ? this.getItemHeightBeforeResize(i) : this.getItemHeight(i)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\t// `itemHeight` can only be `undefined` when not `beforeResize`.\r\n\t\t\t\t\t// Use the current \"average item height\" as a substitute.\r\n\t\t\t\t\titemHeight = this.getAverageItemHeight()\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\ti++\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\tbeforeItemsHeight += rowHeight\r\n\t\t\tbeforeItemsHeight += verticalSpacing\r\n\t\t}\r\n\r\n\t\treturn beforeItemsHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Measures \"after\" items height.\r\n\t * @param {number} lastShownItemIndex — Last shown item index.\r\n\t * @param {number} itemsCount — Items count.\r\n\t * @return {number}\r\n\t */\r\n\tgetAfterItemsHeight(\r\n\t\tlastShownItemIndex,\r\n\t\titemsCount\r\n\t) {\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\t\tconst lastShownRowIndex = Math.floor(lastShownItemIndex / columnsCount)\r\n\r\n\t\tlet afterItemsHeight = 0\r\n\r\n\t\tlet i = lastShownItemIndex + 1\r\n\t\twhile (i < itemsCount) {\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < columnsCount && i < itemsCount) {\r\n\t\t\t\tlet itemHeight = this.getItemHeight(i)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\titemHeight = this.getAverageItemHeight()\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\ti++\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\t// Add all \"after\" items height.\r\n\t\t\tafterItemsHeight += this.getVerticalSpacing()\r\n\t\t\tafterItemsHeight += rowHeight\r\n\t\t}\r\n\r\n\t\treturn afterItemsHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the items's top offset relative to the top edge of the first item.\r\n\t * @param {number} i — Item index\r\n\t * @return {[number]} Returns `undefined` if any of the previous items haven't been rendered yet.\r\n\t */\r\n\tgetItemTopOffset(i) {\r\n\t\tlet topOffsetInsideScrollableContainer = 0\r\n\r\n\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\t\tconst beforeResizeRowsCount = beforeResizeItemsCount === 0\r\n\t\t\t? 0\r\n\t\t\t: Math.ceil(beforeResizeItemsCount / this.getColumnsCountBeforeResize())\r\n\r\n\t\tconst maxBeforeResizeRowsCount = i < beforeResizeItemsCount\r\n\t\t\t? Math.floor(i / this.getColumnsCountBeforeResize())\r\n\t\t\t: beforeResizeRowsCount\r\n\r\n\t\tlet beforeResizeRowIndex = 0\r\n\t\twhile (beforeResizeRowIndex < maxBeforeResizeRowsCount) {\r\n\t\t\tconst rowHeight = this.getItemHeightBeforeResize(\r\n\t\t\t\tbeforeResizeRowIndex * this.getColumnsCountBeforeResize()\r\n\t\t\t)\r\n\r\n\t\t\ttopOffsetInsideScrollableContainer += rowHeight\r\n\t\t\ttopOffsetInsideScrollableContainer += this.getVerticalSpacingBeforeResize()\r\n\r\n\t\t\tbeforeResizeRowIndex++\r\n\t\t}\r\n\r\n\t\tconst itemRowIndex = Math.floor((i - beforeResizeItemsCount) / this.getColumnsCount())\r\n\r\n\t\tlet rowIndex = 0\r\n\t\twhile (rowIndex < itemRowIndex) {\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < this.getColumnsCount()) {\r\n\t\t\t\tconst itemHeight = this.getItemHeight(\r\n\t\t\t\t\tbeforeResizeItemsCount + rowIndex * this.getColumnsCount() + columnIndex\r\n\t\t\t\t)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\ttopOffsetInsideScrollableContainer += rowHeight\r\n\t\t\ttopOffsetInsideScrollableContainer += this.getVerticalSpacing()\r\n\r\n\t\t\trowIndex++\r\n\t\t}\r\n\r\n\t\treturn topOffsetInsideScrollableContainer\r\n\t}\r\n}\r\n\r\nexport const LAYOUT_REASON = {\r\n\tSCROLL: 'scroll',\r\n\tSTOPPED_SCROLLING: 'stopped scrolling',\r\n\tMANUAL: 'manual',\r\n\tSTARTED: 'started',\r\n\tNON_MEASURED_ITEMS_HAVE_BEEN_MEASURED: 'non-measured item heights have been measured',\r\n\tVIEWPORT_WIDTH_CHANGED: 'viewport width changed',\r\n\tVIEWPORT_HEIGHT_CHANGED: 'viewport height changed',\r\n\tVIEWPORT_SIZE_UNCHANGED: 'viewport size unchanged',\r\n\tITEM_HEIGHT_CHANGED: 'item height changed',\r\n\tITEMS_CHANGED: 'items changed',\r\n\tTOP_OFFSET_CHANGED: 'list top offset changed'\r\n}"],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;IAEqBA,M;EACpB,sBAeG;IAAA,IAdFC,MAcE,QAdFA,MAcE;IAAA,IAbFC,mBAaE,QAbFA,mBAaE;IAAA,IAZFC,qBAYE,QAZFA,qBAYE;IAAA,IAXFC,kBAWE,QAXFA,kBAWE;IAAA,IAVFC,kBAUE,QAVFA,kBAUE;IAAA,IATFC,8BASE,QATFA,8BASE;IAAA,IARFC,eAQE,QARFA,eAQE;IAAA,IAPFC,2BAOE,QAPFA,2BAOE;IAAA,IANFC,aAME,QANFA,aAME;IAAA,IALFC,yBAKE,QALFA,yBAKE;IAAA,IAJFC,yBAIE,QAJFA,yBAIE;IAAA,IAHFC,oBAGE,QAHFA,oBAGE;IAAA,IAFFC,uBAEE,QAFFA,uBAEE;IAAA,IADFC,6BACE,QADFA,6BACE;;IAAA;;IACF,KAAKb,MAAL,GAAcA,MAAd;IACA,KAAKC,mBAAL,GAA2BA,mBAA3B;IACA,KAAKC,qBAAL,GAA6BA,qBAA7B;IACA,KAAKC,kBAAL,GAA0BA,kBAA1B;IACA,KAAKC,kBAAL,GAA0BA,kBAA1B;IACA,KAAKC,8BAAL,GAAsCA,8BAAtC;IACA,KAAKC,eAAL,GAAuBA,eAAvB;IACA,KAAKC,2BAAL,GAAmCA,2BAAnC;IACA,KAAKC,aAAL,GAAqBA,aAArB;IACA,KAAKC,yBAAL,GAAiCA,yBAAjC;IACA,KAAKC,yBAAL,GAAiCA,yBAAjC;IACA,KAAKC,oBAAL,GAA4BA,oBAA5B;IACA,KAAKC,uBAAL,GAA+BA,uBAA/B,CAbE,CAcF;IACA;IACA;IACA;IACA;IACA;IACA;;IACA,KAAKC,6BAAL,GAAqCA,6BAArC;EACA;;;;WAED,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AnB,EAA8B;YAC7B;UACA;;UACD+B,UAAS,GAAGvD,IAAI,CAACgD,GAAL,CAASO,UAAT,EAAoBT,UAApB,CAAZ;UACAD,WAAW;QACX;;QAEDY,kCAAkC,IAAIF,UAAtC;QACAE,kCAAkC,IAAI,KAAK5E,kBAAL,EAAtC;QAEAiF,QAAQ;MACR;;MAED,OAAOL,kCAAP;IACA;;;;;;;AAGK,IAAMM,aAAa,GAAG;EAC5BC,MAAM,EAAE,QADoB;EAE5BC,iBAAiB,EAAE,mBAFS;EAG5BC,MAAM,EAAE,QAHoB;EAI5BC,OAAO,EAAE,SAJmB;EAK5BC,qCAAqC,EAAE,8CALX;EAM5BC,sBAAsB,EAAE,wBANI;EAO5BC,uBAAuB,EAAE,yBAPG;EAQ5BC,uBAAuB,EAAE,yBARG;EAS5BC,mBAAmB,EAAE,qBATO;EAU5BC,aAAa,EAAE,eAVa;EAW5BC,kBAAkB,EAAE;AAXQ,CAAtB"}
|
|
1
|
+
{"version":3,"file":"Layout.js","names":["Layout","bypass","getInitialEstimatedItemHeight","getInitialEstimatedVisibleItemRowsCount","measureItemsBatchSize","getPrerenderMargin","getVerticalSpacing","getVerticalSpacingBeforeResize","getColumnsCount","getColumnsCountBeforeResize","getItemHeight","getItemHeightBeforeResize","getBeforeResizeItemsCount","getAverageItemHeight","getMaxVisibleAreaHeight","getPreviouslyCalculatedLayout","name","getValue","defaultValue","error","ScrollableContainerNotReadyError","log","itemsCount","columnsCount","beforeStart","firstShownItemIndex","lastShownItemIndex","getLastShownItemIndex","getInitialLastShownItemIndex","getInitialLayoutValueWithFallback","beforeItemsHeight","afterItemsHeight","estimatedRowsCount","getEstimatedRowsCountForHeight","isNaN","Error","Math","min","height","estimatedItemHeight","getEstimatedItemHeight","verticalSpacing","ceil","averageItemHeight","prependedItemsCount","appendedItemsCount","shouldRestoreScrollPosition","onResetGridLayout","appendedRowsCount","addedHeightAfter","prependedRowsCount","addedHeightBefore","warn","shownItemsCountBeforeItemsUpdate","afterItemsCount","i","nonMeasuredAreaHeight","indexOfTheFirstItemInTheRow","itemsCountToRenderForMeasurement","Infinity","undefined","firstNonMeasuredItemIndex","visibleAreaTop","visibleAreaBottom","indexes","_getShownItemIndex","fromIndex","findFirstShownItemIndex","getNonVisibleListShownItemIndexes","findLastShownItemIndex","parameters","beforeResize","beforeResizeItemsCount","notFound","beforeResizeItemsHeight","floor","currentRowFirstItemIndex","hasMoreRows","verticalSpacingAfterCurrentRow","currentRowHeight","columnIndex","itemHeight","getItemNotMeasuredIndexes","max","itemsHeightFromFirstRowToThisRow","rowStepsIntoVisibleAreaTop","rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder","layout","beforeItemsCount","getBeforeItemsHeight","rowHeight","lastShownRowIndex","topOffsetInsideScrollableContainer","beforeResizeRowsCount","maxBeforeResizeRowsCount","beforeResizeRowIndex","itemRowIndex","rowIndex","LAYOUT_REASON","SCROLL","STOPPED_SCROLLING","MANUAL","STARTED","NON_MEASURED_ITEMS_HAVE_BEEN_MEASURED","VIEWPORT_WIDTH_CHANGED","VIEWPORT_HEIGHT_CHANGED","VIEWPORT_SIZE_UNCHANGED","ITEM_HEIGHT_CHANGED","ITEMS_CHANGED","TOP_OFFSET_CHANGED"],"sources":["../source/Layout.js"],"sourcesContent":["import log, { warn } from './utility/debug.js'\r\nimport ScrollableContainerNotReadyError from './ScrollableContainerNotReadyError.js'\r\n\r\nexport default class Layout {\r\n\tconstructor({\r\n\t\tbypass,\r\n\t\tgetInitialEstimatedItemHeight,\r\n\t\tgetInitialEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tgetPrerenderMargin,\r\n\t\tgetVerticalSpacing,\r\n\t\tgetVerticalSpacingBeforeResize,\r\n\t\tgetColumnsCount,\r\n\t\tgetColumnsCountBeforeResize,\r\n\t\tgetItemHeight,\r\n\t\tgetItemHeightBeforeResize,\r\n\t\tgetBeforeResizeItemsCount,\r\n\t\tgetAverageItemHeight,\r\n\t\tgetMaxVisibleAreaHeight,\r\n\t\tgetPreviouslyCalculatedLayout\r\n\t}) {\r\n\t\tthis.bypass = bypass\r\n\t\tthis.getInitialEstimatedItemHeight = getInitialEstimatedItemHeight\r\n\t\tthis.getInitialEstimatedVisibleItemRowsCount = getInitialEstimatedVisibleItemRowsCount\r\n\t\tthis.measureItemsBatchSize = measureItemsBatchSize\r\n\t\tthis.getPrerenderMargin = getPrerenderMargin\r\n\t\tthis.getVerticalSpacing = getVerticalSpacing\r\n\t\tthis.getVerticalSpacingBeforeResize = getVerticalSpacingBeforeResize\r\n\t\tthis.getColumnsCount = getColumnsCount\r\n\t\tthis.getColumnsCountBeforeResize = getColumnsCountBeforeResize\r\n\t\tthis.getItemHeight = getItemHeight\r\n\t\tthis.getItemHeightBeforeResize = getItemHeightBeforeResize\r\n\t\tthis.getBeforeResizeItemsCount = getBeforeResizeItemsCount\r\n\t\tthis.getAverageItemHeight = getAverageItemHeight\r\n\t\tthis.getMaxVisibleAreaHeight = getMaxVisibleAreaHeight\r\n\t\t//\r\n\t\t// The \"previously calculated layout\" feature is not currently used.\r\n\t\t//\r\n\t\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t\t// rather than from scratch, which would be an optimization.\r\n\t\t//\r\n\t\tthis.getPreviouslyCalculatedLayout = getPreviouslyCalculatedLayout\r\n\t}\r\n\r\n\t// React `<VirtualScroller/>` component attempts to create the initial state\r\n\t// before the component tree has mounted. This could result in an inability to\r\n\t// calculate some initial layout values like `columnsCount` or `lastShownItemIndex`.\r\n\t// Such errors aren't considered critical because layout will be re-calculated\r\n\t// after the component mounts. The workaround is to use some sane default values\r\n\t// until the scrollable container has mounted.\r\n\tgetInitialLayoutValueWithFallback(name, getValue, defaultValue) {\r\n\t\ttry {\r\n\t\t\treturn getValue()\r\n\t\t} catch (error) {\r\n\t\t\tif (error instanceof ScrollableContainerNotReadyError) {\r\n\t\t\t\tlog('Couldn\\'t calculate', name, 'before scrollable container is ready. Default to', defaultValue);\r\n\t\t\t\treturn defaultValue\r\n\t\t\t} else {\r\n\t\t\t\tthrow error\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetInitialLayoutValues({\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tbeforeStart\r\n\t}) {\r\n\t\tlet firstShownItemIndex\r\n\t\tlet lastShownItemIndex\r\n\t\t// If there're no items then `firstShownItemIndex` stays `undefined`.\r\n\t\tif (itemsCount > 0) {\r\n\t\t\tconst getLastShownItemIndex = () => {\r\n\t\t\t\treturn this.getInitialLastShownItemIndex({\r\n\t\t\t\t\titemsCount,\r\n\t\t\t\t\tcolumnsCount,\r\n\t\t\t\t\tfirstShownItemIndex\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t\tfirstShownItemIndex = 0\r\n\t\t\tlastShownItemIndex = beforeStart\r\n\t\t\t\t? this.getInitialLayoutValueWithFallback(\r\n\t\t\t\t\t'lastShownItemIndex',\r\n\t\t\t\t\tgetLastShownItemIndex,\r\n\t\t\t\t\t0\r\n\t\t\t\t)\r\n\t\t\t\t: getLastShownItemIndex()\r\n\t\t}\r\n\t\treturn {\r\n\t\t\tbeforeItemsHeight: 0,\r\n\t\t\tafterItemsHeight: 0,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\tgetInitialLastShownItemIndex({\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tfirstShownItemIndex\r\n\t}) {\r\n\t\tif (this.bypass) {\r\n\t\t\treturn itemsCount - 1\r\n\t\t}\r\n\t\t// On server side, at initialization time,\r\n\t\t// `scrollableContainer` is `undefined`,\r\n\t\t// so default to `1` estimated rows count.\r\n\t\tlet estimatedRowsCount = 1\r\n\t\tif (this.getMaxVisibleAreaHeight()) {\r\n\t\t\testimatedRowsCount = this.getEstimatedRowsCountForHeight(this.getMaxVisibleAreaHeight() + this.getPrerenderMargin())\r\n\t\t} else if (this.getInitialEstimatedVisibleItemRowsCount) {\r\n\t\t\testimatedRowsCount = this.getInitialEstimatedVisibleItemRowsCount()\r\n\t\t\tif (isNaN(estimatedRowsCount)) {\r\n\t\t\t\tthrow new Error('[virtual-scroller] `getEstimatedVisibleItemRowsCount()` must return a number')\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn Math.min(\r\n\t\t\tfirstShownItemIndex + (estimatedRowsCount * columnsCount - 1),\r\n\t\t\titemsCount - 1\r\n\t\t)\r\n\t}\r\n\r\n\tgetEstimatedRowsCountForHeight(height) {\r\n\t\tconst estimatedItemHeight = this.getEstimatedItemHeight()\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\t\tif (estimatedItemHeight) {\r\n\t\t\treturn Math.ceil((height + verticalSpacing) / (estimatedItemHeight + verticalSpacing))\r\n\t\t} else {\r\n\t\t\t// If no items have been rendered yet, and no `estimatedItemHeight` option\r\n\t\t\t// has been passed, then default to `1` estimated rows count in any `height`.\r\n\t\t\treturn 1\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Returns estimated list item height.\r\n\t * (depends on which items have been previously rendered and measured).\r\n\t * @return {number}\r\n\t */\r\n\tgetEstimatedItemHeight() {\r\n\t\tconst averageItemHeight = this.getAverageItemHeight()\r\n\t\tif (averageItemHeight) {\r\n\t\t\treturn averageItemHeight\r\n\t\t}\r\n\t\tif (this.getInitialEstimatedItemHeight) {\r\n\t\t\tconst estimatedItemHeight = this.getInitialEstimatedItemHeight()\r\n\t\t\tif (isNaN(estimatedItemHeight)) {\r\n\t\t\t\tthrow new Error('[virtual-scroller] `getInitialEstimatedItemHeight()` must return a number')\r\n\t\t\t}\r\n\t\t\treturn estimatedItemHeight\r\n\t\t}\r\n\t\treturn 0\r\n\t}\r\n\r\n\tgetLayoutUpdateForItemsDiff({\r\n\t\tfirstShownItemIndex,\r\n\t\tlastShownItemIndex,\r\n\t\tbeforeItemsHeight,\r\n\t\tafterItemsHeight\r\n\t}, {\r\n\t\tprependedItemsCount,\r\n\t\tappendedItemsCount\r\n\t}, {\r\n\t\titemsCount,\r\n\t\tcolumnsCount,\r\n\t\tshouldRestoreScrollPosition,\r\n\t\tonResetGridLayout\r\n\t}) {\r\n\t\t// const layoutUpdate = {}\r\n\r\n\t\t// If the layout stays the same, then simply increase\r\n\t\t// the top and bottom margins proportionally to the amount\r\n\t\t// of the items added.\r\n\t\tconst averageItemHeight = this.getAverageItemHeight()\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\r\n\t\tif (appendedItemsCount > 0) {\r\n\t\t\tconst appendedRowsCount = Math.ceil(appendedItemsCount / columnsCount)\r\n\t\t\tconst addedHeightAfter = appendedRowsCount * (verticalSpacing + averageItemHeight)\r\n\r\n\t\t\tafterItemsHeight += addedHeightAfter\r\n\r\n\t\t\t// layoutUpdate = {\r\n\t\t\t// \t...layoutUpdate,\r\n\t\t\t// \tafterItemsHeight\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\tif (prependedItemsCount > 0) {\r\n\t\t\tconst prependedRowsCount = Math.ceil(prependedItemsCount / columnsCount)\r\n\t\t\tconst addedHeightBefore = prependedRowsCount * (averageItemHeight + verticalSpacing)\r\n\r\n\t\t\tfirstShownItemIndex += prependedItemsCount\r\n\t\t\tlastShownItemIndex += prependedItemsCount\r\n\t\t\tbeforeItemsHeight += addedHeightBefore\r\n\r\n\t\t\t// If the currently shown items position on screen should be preserved\r\n\t\t\t// when prepending new items, then it means that:\r\n\t\t\t// * The current scroll position should be snapshotted.\r\n\t\t\t// * The current list height should be snapshotted.\r\n\t\t\t// * All prepended items should be shown so that their height could be\r\n\t\t\t// measured after they're rendered. Based on the prepended items' height,\r\n\t\t\t// the scroll position will be restored so that there's no \"jump of content\".\r\n\t\t\tif (shouldRestoreScrollPosition) {\r\n\t\t\t\tfirstShownItemIndex = 0\r\n\t\t\t\tbeforeItemsHeight = 0\r\n\t\t\t}\r\n\r\n\t\t\tif (prependedItemsCount % columnsCount > 0) {\r\n\t\t\t\t// Rows will be rebalanced as a result of prepending new items,\r\n\t\t\t\t// and row heights can change as a result, so re-layout items\r\n\t\t\t\t// after they've been measured (after the upcoming re-render).\r\n\t\t\t\t//\r\n\t\t\t\t// For example, consider a web page where item rows are `display: flex`.\r\n\t\t\t\t// Suppose there're 3 columns and it shows items from 4 to 6.\r\n\t\t\t\t//\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Apples are | Bananas | Cranberries |\r\n\t\t\t\t// | green | | |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Dates | Elderberry | Figs are |\r\n\t\t\t\t// | | | tasty |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t//\r\n\t\t\t\t// Now, 1 item gets prepended. As a result, all existing rows will have\r\n\t\t\t\t// a different set of items, which means that the row heights will change.\r\n\t\t\t\t//\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Zucchini | Apples are | Bananas |\r\n\t\t\t\t// | | green | |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Cranberries | Dates | Elderberry |\r\n\t\t\t\t// ------------------------------------------\r\n\t\t\t\t// | Figs |\r\n\t\t\t\t// | are tasty |\r\n\t\t\t\t// ---------------\r\n\t\t\t\t//\r\n\t\t\t\t// As it can be seen above, the second row's height has changed from 2 to 1.\r\n\t\t\t\t// Not only that, but `itemHeights` have changed as well, so if you thought\r\n\t\t\t\t// that the library could easily recalculate row heights using `Math.max()` — \r\n\t\t\t\t// turns out it's not always the case.\r\n\t\t\t\t//\r\n\t\t\t\t// There could be an explicit opt-in option for automatically recalculating\r\n\t\t\t\t// row heights, but I don't want to write code for such an extremely rare\r\n\t\t\t\t// use case. Instead, use the `getColumnsCount()` parameter function when\r\n\t\t\t\t// fetching previous items.\r\n\r\n\t\t\t\tonResetGridLayout()\r\n\r\n\t\t\t\twarn('~ Prepended items count', prependedItemsCount, 'is not divisible by Columns Count', columnsCount, '~')\r\n\t\t\t\twarn('Layout reset required')\r\n\r\n\t\t\t\tconst shownItemsCountBeforeItemsUpdate = lastShownItemIndex - firstShownItemIndex + 1\r\n\r\n\t\t\t\tfirstShownItemIndex = 0\r\n\t\t\t\tbeforeItemsHeight = 0\r\n\r\n\t\t\t\tif (!shouldRestoreScrollPosition) {\r\n\t\t\t\t\t// Limit shown items count if too many items have been prepended.\r\n\t\t\t\t\tif (prependedItemsCount > shownItemsCountBeforeItemsUpdate) {\r\n\t\t\t\t\t\tlastShownItemIndex = this.getInitialLastShownItemIndex({\r\n\t\t\t\t\t\t\titemsCount,\r\n\t\t\t\t\t\t\tcolumnsCount,\r\n\t\t\t\t\t\t\tfirstShownItemIndex\r\n\t\t\t\t\t\t})\r\n\r\n\t\t\t\t\t\t// Approximate `afterItemsHeight` calculation.\r\n\t\t\t\t\t\tconst afterItemsCount = itemsCount - (lastShownItemIndex + 1)\r\n\t\t\t\t\t\tafterItemsHeight = Math.ceil(afterItemsCount / columnsCount) * (verticalSpacing + averageItemHeight)\r\n\r\n\t\t\t\t\t\t// layoutUpdate = {\r\n\t\t\t\t\t\t// \t...layoutUpdate,\r\n\t\t\t\t\t\t// \tafterItemsHeight\r\n\t\t\t\t\t\t// }\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// layoutUpdate = {\r\n\t\t\t// \t...layoutUpdate,\r\n\t\t\t// \tbeforeItemsHeight,\r\n\t\t\t// \tfirstShownItemIndex,\r\n\t\t\t// \tlastShownItemIndex\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\t// return layoutUpdate\r\n\r\n\t\t// Overwrite all four props in all scenarios.\r\n\t\t// The reason is that only this way subsequent `setItems()` calls\r\n\t\t// will be truly \"stateless\" when a chain of `setItems()` calls\r\n\t\t// could be replaced with just the last one in a scenario when\r\n\t\t// `updateState()` calls are \"asynchronous\" (delayed execution).\r\n\t\t//\r\n\t\t// So, for example, the user calls `setItems()` with one set of items.\r\n\t\t// A `updateState()` call has been dispatched but the `state` hasn't been updated yet.\r\n\t\t// Then the user calls `setItems()` with another set of items.\r\n\t\t// If this function only returned a minimal set of properties that actually change,\r\n\t\t// the other layout properties of the second `setItems()` call wouldn't overwrite the ones\r\n\t\t// scheduled for update during the first `setItems()` call, resulting in an inconsistent `state`.\r\n\t\t//\r\n\t\t// For example, the first `setItems()` call does a `updateState()` call where it updates\r\n\t\t// `afterItemsHeight`, and then the second `setItems()` call only updates `beforeItemsHeight`\r\n\t\t// and `firstShownItemIndex` and `lastShownItemIndex`. If the second `setItems()` call was to\r\n\t\t// overwrite any effects of the pending-but-not-yet-applied first `setItems()` call, it would\r\n\t\t// have to call `updateState()` with an `afterItemsHeight` property too, even though it hasn't change.\r\n\t\t// That would be just to revert the change to `afterItemsHeight` state property already scheduled\r\n\t\t// by the first `setItems()` call.\r\n\t\t//\r\n\t\treturn {\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tafterItemsHeight,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t// If an item that hasn't been shown (and measured) yet is encountered\r\n\t// then show such item and then retry after it has been measured.\r\n\tgetItemNotMeasuredIndexes(i, {\r\n\t\titemsCount,\r\n\t\tfirstShownItemIndex,\r\n\t\tnonMeasuredAreaHeight,\r\n\t\tindexOfTheFirstItemInTheRow\r\n\t}) {\r\n\t\tlog('Item index', i, 'height is required for calculations but hasn\\'t been measured yet. Mark the item as \"shown\", rerender the list, measure the item\\'s height and redo the layout.')\r\n\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\r\n\t\tconst itemsCountToRenderForMeasurement = Math.min(\r\n\t\t\tthis.getEstimatedRowsCountForHeight(nonMeasuredAreaHeight) * columnsCount,\r\n\t\t\tthis.measureItemsBatchSize || Infinity,\r\n\t\t)\r\n\r\n\t\tif (firstShownItemIndex === undefined) {\r\n\t\t\tfirstShownItemIndex = indexOfTheFirstItemInTheRow\r\n\t\t}\r\n\r\n\t\tconst lastShownItemIndex = Math.min(\r\n\t\t\tindexOfTheFirstItemInTheRow + itemsCountToRenderForMeasurement - 1,\r\n\t\t\t// Guard against index overflow.\r\n\t\t\titemsCount - 1\r\n\t\t)\r\n\r\n\t\treturn {\r\n\t\t\tfirstNonMeasuredItemIndex: i,\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Finds the indexes of the currently visible items.\r\n\t * @return {object} `{ firstShownItemIndex: number, lastShownItemIndex: number, firstNonMeasuredItemIndex: number? }`\r\n\t */\r\n\tgetShownItemIndexes({\r\n\t\titemsCount,\r\n\t\tvisibleAreaTop,\r\n\t\tvisibleAreaBottom\r\n\t}) {\r\n\t\tlet indexes = this._getShownItemIndex({\r\n\t\t\titemsCount,\r\n\t\t\tfromIndex: 0,\r\n\t\t\tvisibleAreaTop,\r\n\t\t\tvisibleAreaBottom,\r\n\t\t\tfindFirstShownItemIndex: true\r\n\t\t})\r\n\r\n\t\tif (indexes === null) {\r\n\t\t\treturn this.getNonVisibleListShownItemIndexes()\r\n\t\t}\r\n\r\n\t\tif (indexes.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\treturn indexes\r\n\t\t}\r\n\r\n\t\tconst { firstShownItemIndex, beforeItemsHeight } = indexes\r\n\r\n\t\tindexes = this._getShownItemIndex({\r\n\t\t\titemsCount,\r\n\t\t\tfromIndex: firstShownItemIndex,\r\n\t\t\tbeforeItemsHeight,\r\n\t\t\tvisibleAreaTop,\r\n\t\t\tvisibleAreaBottom,\r\n\t\t\tfindLastShownItemIndex: true\r\n\t\t})\r\n\r\n\t\tif (indexes === null) {\r\n\t\t\treturn this.getNonVisibleListShownItemIndexes()\r\n\t\t}\r\n\r\n\t\tif (indexes.firstNonMeasuredItemIndex !== undefined) {\r\n\t\t\treturn indexes\r\n\t\t}\r\n\r\n\t\tconst { lastShownItemIndex } = indexes\r\n\r\n\t\treturn {\r\n\t\t\tfirstShownItemIndex,\r\n\t\t\tlastShownItemIndex\r\n\t\t}\r\n\t}\r\n\r\n\t_getShownItemIndex(parameters) {\r\n\t\tconst {\r\n\t\t\tbeforeResize,\r\n\t\t\titemsCount,\r\n\t\t\tvisibleAreaTop,\r\n\t\t\tvisibleAreaBottom,\r\n\t\t\tfindFirstShownItemIndex,\r\n\t\t\tfindLastShownItemIndex,\r\n\t\t\t// backwards\r\n\t\t} = parameters\r\n\r\n\t\tlet {\r\n\t\t\tfromIndex,\r\n\t\t\tbeforeItemsHeight\r\n\t\t} = parameters\r\n\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\t\t//\r\n\t\t// If someone would attempt to use a \"previously calculated layout\" here\r\n\t\t// then `shownItemsHeight` would also have to be returned from this function:\r\n\t\t// the total height of all shown items including vertical spacing between them.\r\n\t\t//\r\n\t\t// If \"previously calculated layout\" would be used then it would first find\r\n\t\t// `firstShownItemIndex` and then find `lastShownItemIndex` as part of two\r\n\t\t// separate calls of this function, each with or without `backwards` flag,\r\n\t\t// depending on whether `visibleAreaTop` and `visibleAreBottom` have shifted up or down.\r\n\r\n\t\tlet firstShownItemIndex\r\n\t\tlet lastShownItemIndex\r\n\r\n\t\t// It's not always required to pass `beforeItemsHeight` parameter:\r\n\t\t// when `fromIndex` is `0`, it's also assumed to be `0`.\r\n\t\tif (fromIndex === 0) {\r\n\t\t\tbeforeItemsHeight = 0\r\n\t\t}\r\n\r\n\t\tif (beforeItemsHeight === undefined) {\r\n\t\t\tthrow new Error('[virtual-scroller] `beforeItemsHeight` not passed to `Layout.getShownItemIndexes()` when starting from index ' + fromIndex);\r\n\t\t}\r\n\r\n\t\t// const backwards = false\r\n\t\t// while (backwards ? i >= 0 : i < itemsCount) {}\r\n\r\n\t\tif (!beforeResize) {\r\n\t\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\t\t\tif (beforeResizeItemsCount > fromIndex) {\r\n\t\t\t\t// First search for the item in \"before resize\" items.\r\n\t\t\t\tconst {\r\n\t\t\t\t\tnotFound,\r\n\t\t\t\t\tbeforeItemsHeight: beforeResizeItemsHeight,\r\n\t\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\t\tlastShownItemIndex\r\n\t\t\t\t} = this._getShownItemIndex({\r\n\t\t\t\t\t...parameters,\r\n\t\t\t\t\tbeforeResize: true,\r\n\t\t\t\t\titemsCount: beforeResizeItemsCount\r\n\t\t\t\t})\r\n\r\n\t\t\t\t// If the item was not found in \"before resize\" items\r\n\t\t\t\t// then search in regular items skipping \"before resize\" ones.\r\n\t\t\t\tif (notFound) {\r\n\t\t\t\t\tbeforeItemsHeight = beforeResizeItemsHeight\r\n\t\t\t\t\tfromIndex += beforeResizeItemsCount\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// If the item was found in \"before resize\" items\r\n\t\t\t\t\t// then return the result.\r\n\t\t\t\t\t// Rebalance first / last shown item indexes based on\r\n\t\t\t\t\t// the current columns count, if required.\r\n\t\t\t\t\tconst columnsCount = this.getColumnsCount()\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tfirstShownItemIndex: firstShownItemIndex === undefined\r\n\t\t\t\t\t\t\t? undefined\r\n\t\t\t\t\t\t\t: Math.floor(firstShownItemIndex / columnsCount) * columnsCount,\r\n\t\t\t\t\t\tlastShownItemIndex: lastShownItemIndex === undefined\r\n\t\t\t\t\t\t\t? undefined\r\n\t\t\t\t\t\t\t: Math.floor(lastShownItemIndex / columnsCount) * columnsCount,\r\n\t\t\t\t\t\tbeforeItemsHeight: beforeResizeItemsHeight\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst columnsCount = beforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\tconst verticalSpacing = beforeResize ? this.getVerticalSpacingBeforeResize() : this.getVerticalSpacing()\r\n\r\n\t\tlet i = fromIndex\r\n\t\twhile (i < itemsCount) {\r\n\t\t\tconst currentRowFirstItemIndex = i\r\n\r\n\t\t\tconst hasMoreRows = itemsCount > currentRowFirstItemIndex + columnsCount\r\n\t\t\tconst verticalSpacingAfterCurrentRow = hasMoreRows ? verticalSpacing : 0\r\n\r\n\t\t\tlet currentRowHeight = 0\r\n\r\n\t\t\t// Calculate current row height.\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < columnsCount && i < itemsCount) {\r\n\t\t\t\tconst itemHeight = beforeResize ? this.getItemHeightBeforeResize(i) : this.getItemHeight(i)\r\n\r\n\t\t\t\t// If this item hasn't been measured yet (or re-measured after a resize)\r\n\t\t\t\t// then mark it as the first non-measured one.\r\n\t\t\t\t//\r\n\t\t\t\t// Can't happen by definition when `beforeResize` parameter is `true`.\r\n\t\t\t\t//\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\treturn this.getItemNotMeasuredIndexes(i, {\r\n\t\t\t\t\t\titemsCount,\r\n\t\t\t\t\t\tfirstShownItemIndex: findLastShownItemIndex ? fromIndex : undefined,\r\n\t\t\t\t\t\tindexOfTheFirstItemInTheRow: currentRowFirstItemIndex,\r\n\t\t\t\t\t\tnonMeasuredAreaHeight: (visibleAreaBottom + this.getPrerenderMargin()) - beforeItemsHeight\r\n\t\t\t\t\t})\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcurrentRowHeight = Math.max(currentRowHeight, itemHeight)\r\n\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t\ti++\r\n\t\t\t}\r\n\r\n\t\t\tconst itemsHeightFromFirstRowToThisRow = beforeItemsHeight + currentRowHeight\r\n\r\n\t\t\tconst rowStepsIntoVisibleAreaTop = itemsHeightFromFirstRowToThisRow > visibleAreaTop - this.getPrerenderMargin()\r\n\t\t\tconst rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder = itemsHeightFromFirstRowToThisRow + verticalSpacingAfterCurrentRow >= visibleAreaBottom + this.getPrerenderMargin()\r\n\r\n\t\t\t// if (backwards) {\r\n\t\t\t// \tif (findFirstShownItemIndex) {\r\n\t\t\t// \t\tif (rowStepsOutOfVisibleAreaTop) {\r\n\t\t\t// \t\t\treturn {\r\n\t\t\t// \t\t\t\tfirstShownItemIndex: currentRowFirstItemIndex + columnsCount\r\n\t\t\t// \t\t\t}\r\n\t\t\t// \t\t}\r\n\t\t\t// \t} else if (findLastShownItemIndex) {\r\n\t\t\t// \t\tif (rowStepsIntoVisibleAreaBottom) {\r\n\t\t\t// \t\t\treturn {\r\n\t\t\t// \t\t\t\tlastShownItemIndex: currentRowFirstItemIndex + columnsCount - 1\r\n\t\t\t// \t\t\t}\r\n\t\t\t// \t\t}\r\n\t\t\t// \t}\r\n\t\t\t// }\r\n\r\n\t\t\tif (findFirstShownItemIndex) {\r\n\t\t\t\tif (rowStepsIntoVisibleAreaTop) {\r\n\t\t\t\t\t// If item is the first one visible in the viewport\r\n\t\t\t\t\t// then start showing items from this row.\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tfirstShownItemIndex: currentRowFirstItemIndex,\r\n\t\t\t\t\t\tbeforeItemsHeight\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else if (findLastShownItemIndex) {\r\n\t\t\t\tif (rowStepsOutOfVisibleAreaBottomOrIsAtTheBorder) {\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tlastShownItemIndex: Math.min(\r\n\t\t\t\t\t\t\t// The index of the last item in the current row.\r\n\t\t\t\t\t\t\tcurrentRowFirstItemIndex + columnsCount - 1,\r\n\t\t\t\t\t\t\t// Guards against index overflow.\r\n\t\t\t\t\t\t\titemsCount - 1\r\n\t\t\t\t\t\t)\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tbeforeItemsHeight += currentRowHeight + verticalSpacingAfterCurrentRow\r\n\r\n\t\t\t// if (backwards) {\r\n\t\t\t// \t// Set `i` to be the first item of the current row.\r\n\t\t\t// \ti -= columnsCount\r\n\t\t\t// \tconst prevoiusRowIsBeforeResize = i - 1 < this.getBeforeResizeItemsCount()\r\n\t\t\t// \tconst previousRowColumnsCount = prevoiusRowIsBeforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\t\t// \t// Set `i` to be the first item of the previous row.\r\n\t\t\t// \ti -= previousRowColumnsCount\r\n\t\t\t// }\r\n\t\t}\r\n\r\n\t\t// if (backwards) {\r\n\t\t// \tif (findFirstShownItemIndex) {\r\n\t\t// \t\twarn('The list is supposed to be visible but no visible item has been found (while traversing backwards)')\r\n\t\t// \t\treturn null\r\n\t\t// \t} else if (findLastShownItemIndex) {\r\n\t\t// \t\treturn {\r\n\t\t// \t\t\tfirstShownItemIndex: 0\r\n\t\t// \t\t}\r\n\t\t// \t}\r\n\t\t// }\r\n\r\n\t\tif (beforeResize) {\r\n\t\t\treturn {\r\n\t\t\t\tnotFound: true,\r\n\t\t\t\tbeforeItemsHeight\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// This case isn't supposed to happen but it could hypothetically happen\r\n\t\t// because the list height is measured from the user's screen and\r\n\t\t// not necessarily can be trusted.\r\n\t\tif (findFirstShownItemIndex) {\r\n\t\t\twarn('The list is supposed to be visible but no visible item has been found')\r\n\t\t\treturn null\r\n\t\t} else if (findLastShownItemIndex) {\r\n\t\t\treturn {\r\n\t\t\t\tlastShownItemIndex: itemsCount - 1\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetNonVisibleListShownItemIndexes() {\r\n\t\tconst layout = {\r\n\t\t\tfirstShownItemIndex: 0,\r\n\t\t\tlastShownItemIndex: 0\r\n\t\t}\r\n\t\tif (this.getItemHeight(0) === undefined) {\r\n\t\t\tlayout.firstNonMeasuredItemIndex = 0\r\n\t\t}\r\n\t\treturn layout\r\n\t}\r\n\r\n\t/**\r\n\t * Measures \"before\" items height.\r\n\t * @param {number} beforeItemsCount — Basically, first shown item index.\r\n\t * @return {number}\r\n\t */\r\n\tgetBeforeItemsHeight(\r\n\t\tbeforeItemsCount,\r\n\t\t{ beforeResize } = {}\r\n\t) {\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\r\n\t\tlet beforeItemsHeight = 0\r\n\t\tlet i = 0\r\n\r\n\t\tif (!beforeResize) {\r\n\t\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\r\n\t\t\tif (beforeResizeItemsCount > 0) {\r\n\t\t\t\t// First add all \"before resize\" item heights.\r\n\t\t\t\tbeforeItemsHeight = this.getBeforeItemsHeight(\r\n\t\t\t\t\t// `firstShownItemIndex` (called `beforeItemsCount`) could be greater than\r\n\t\t\t\t\t// `beforeResizeItemsCount` when the user scrolls down.\r\n\t\t\t\t\t// `firstShownItemIndex` (called `beforeItemsCount`) could be less than\r\n\t\t\t\t\t// `beforeResizeItemsCount` when the user scrolls up.\r\n\t\t\t\t\tMath.min(beforeItemsCount, beforeResizeItemsCount),\r\n\t\t\t\t\t{ beforeResize: true }\r\n\t\t\t\t)\r\n\t\t\t\ti = beforeResizeItemsCount\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst columnsCount = beforeResize ? this.getColumnsCountBeforeResize() : this.getColumnsCount()\r\n\t\tconst verticalSpacing = beforeResize ? this.getVerticalSpacingBeforeResize() : this.getVerticalSpacing()\r\n\r\n\t\twhile (i < beforeItemsCount) {\r\n\t\t\tconst currentRowFirstItemIndex = i\r\n\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\t// Not checking for `itemsCount` overflow here because `i = beforeItemsCount`\r\n\t\t\t// can only start at the start of a row, meaning that when calculating\r\n\t\t\t// \"before items height\" it's not supposed to add item heights from the\r\n\t\t\t// last row of items because in that case it would have to iterate from\r\n\t\t\t// `i === beforeItemsCount` and that condition is already checked above.\r\n\t\t\t// while (i < itemsCount) {\r\n\t\t\twhile (columnIndex < columnsCount) {\r\n\t\t\t\tlet itemHeight = beforeResize ? this.getItemHeightBeforeResize(i) : this.getItemHeight(i)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\t// `itemHeight` can only be `undefined` when not `beforeResize`.\r\n\t\t\t\t\t// Use the current \"average item height\" as a substitute.\r\n\t\t\t\t\titemHeight = this.getAverageItemHeight()\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\ti++\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\tbeforeItemsHeight += rowHeight\r\n\t\t\tbeforeItemsHeight += verticalSpacing\r\n\t\t}\r\n\r\n\t\treturn beforeItemsHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Measures \"after\" items height.\r\n\t * @param {number} lastShownItemIndex — Last shown item index.\r\n\t * @param {number} itemsCount — Items count.\r\n\t * @return {number}\r\n\t */\r\n\tgetAfterItemsHeight(\r\n\t\tlastShownItemIndex,\r\n\t\titemsCount\r\n\t) {\r\n\t\t// This function could potentially also use `this.getPreviouslyCalculatedLayout()`\r\n\t\t// in order to skip calculating visible item indexes from scratch\r\n\t\t// and instead just calculate the difference from a \"previously calculated layout\".\r\n\t\t//\r\n\t\t// I did a simple test in a web browser and found out that running the following\r\n\t\t// piece of code is less than 10 milliseconds:\r\n\t\t//\r\n\t\t// var startedAt = Date.now()\r\n\t\t// var i = 0\r\n\t\t// while (i < 1000000) {\r\n\t\t// i++\r\n\t\t// }\r\n\t\t// console.log(Date.now() - startedAt)\r\n\t\t//\r\n\t\t// Which becomes negligible in my project's use case (a couple thousands items max).\r\n\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\t\tconst lastShownRowIndex = Math.floor(lastShownItemIndex / columnsCount)\r\n\r\n\t\tlet afterItemsHeight = 0\r\n\r\n\t\tlet i = lastShownItemIndex + 1\r\n\t\twhile (i < itemsCount) {\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < columnsCount && i < itemsCount) {\r\n\t\t\t\tlet itemHeight = this.getItemHeight(i)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\titemHeight = this.getAverageItemHeight()\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\ti++\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\t// Add all \"after\" items height.\r\n\t\t\tafterItemsHeight += this.getVerticalSpacing()\r\n\t\t\tafterItemsHeight += rowHeight\r\n\t\t}\r\n\r\n\t\treturn afterItemsHeight\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the items's top offset relative to the top edge of the first item.\r\n\t * @param {number} i — Item index\r\n\t * @return {[number]} Returns `undefined` if any of the previous items haven't been rendered yet.\r\n\t */\r\n\tgetItemTopOffset(i) {\r\n\t\tlet topOffsetInsideScrollableContainer = 0\r\n\r\n\t\tconst beforeResizeItemsCount = this.getBeforeResizeItemsCount()\r\n\t\tconst beforeResizeRowsCount = beforeResizeItemsCount === 0\r\n\t\t\t? 0\r\n\t\t\t: Math.ceil(beforeResizeItemsCount / this.getColumnsCountBeforeResize())\r\n\r\n\t\tconst maxBeforeResizeRowsCount = i < beforeResizeItemsCount\r\n\t\t\t? Math.floor(i / this.getColumnsCountBeforeResize())\r\n\t\t\t: beforeResizeRowsCount\r\n\r\n\t\tlet beforeResizeRowIndex = 0\r\n\t\twhile (beforeResizeRowIndex < maxBeforeResizeRowsCount) {\r\n\t\t\tconst rowHeight = this.getItemHeightBeforeResize(\r\n\t\t\t\tbeforeResizeRowIndex * this.getColumnsCountBeforeResize()\r\n\t\t\t)\r\n\r\n\t\t\ttopOffsetInsideScrollableContainer += rowHeight\r\n\t\t\ttopOffsetInsideScrollableContainer += this.getVerticalSpacingBeforeResize()\r\n\r\n\t\t\tbeforeResizeRowIndex++\r\n\t\t}\r\n\r\n\t\tconst itemRowIndex = Math.floor((i - beforeResizeItemsCount) / this.getColumnsCount())\r\n\r\n\t\tlet rowIndex = 0\r\n\t\twhile (rowIndex < itemRowIndex) {\r\n\t\t\tlet rowHeight = 0\r\n\t\t\tlet columnIndex = 0\r\n\t\t\twhile (columnIndex < this.getColumnsCount()) {\r\n\t\t\t\tconst itemHeight = this.getItemHeight(\r\n\t\t\t\t\tbeforeResizeItemsCount + rowIndex * this.getColumnsCount() + columnIndex\r\n\t\t\t\t)\r\n\t\t\t\tif (itemHeight === undefined) {\r\n\t\t\t\t\treturn\r\n\t\t\t\t}\r\n\t\t\t\trowHeight = Math.max(rowHeight, itemHeight)\r\n\t\t\t\tcolumnIndex++\r\n\t\t\t}\r\n\r\n\t\t\ttopOffsetInsideScrollableContainer += rowHeight\r\n\t\t\ttopOffsetInsideScrollableContainer += this.getVerticalSpacing()\r\n\r\n\t\t\trowIndex++\r\n\t\t}\r\n\r\n\t\treturn topOffsetInsideScrollableContainer\r\n\t}\r\n}\r\n\r\nexport const LAYOUT_REASON = {\r\n\tSCROLL: 'scroll',\r\n\tSTOPPED_SCROLLING: 'stopped scrolling',\r\n\tMANUAL: 'manual',\r\n\tSTARTED: 'started',\r\n\tNON_MEASURED_ITEMS_HAVE_BEEN_MEASURED: 'non-measured item heights have been measured',\r\n\tVIEWPORT_WIDTH_CHANGED: 'viewport width changed',\r\n\tVIEWPORT_HEIGHT_CHANGED: 'viewport height changed',\r\n\tVIEWPORT_SIZE_UNCHANGED: 'viewport size unchanged',\r\n\tITEM_HEIGHT_CHANGED: 'item height changed',\r\n\tITEMS_CHANGED: 'items changed',\r\n\tTOP_OFFSET_CHANGED: 'list top offset changed'\r\n}"],"mappings":";;;;;;;;;AAAA;;AACA;;;;;;;;;;;;;;;;;;;;IAEqBA,M;EACpB,sBAgBG;IAAA,IAfFC,MAeE,QAfFA,MAeE;IAAA,IAdFC,6BAcE,QAdFA,6BAcE;IAAA,IAbFC,uCAaE,QAbFA,uCAaE;IAAA,IAZFC,qBAYE,QAZFA,qBAYE;IAAA,IAXFC,kBAWE,QAXFA,kBAWE;IAAA,IAVFC,kBAUE,QAVFA,kBAUE;IAAA,IATFC,8BASE,QATFA,8BASE;IAAA,IARFC,eAQE,QARFA,eAQE;IAAA,IAPFC,2BAOE,QAPFA,2BAOE;IAAA,IANFC,aAME,QANFA,aAME;IAAA,IALFC,yBAKE,QALFA,yBAKE;IAAA,IAJFC,yBAIE,QAJFA,yBAIE;IAAA,IAHFC,oBAGE,QAHFA,oBAGE;IAAA,IAFFC,uBAEE,QAFFA,uBAEE;IAAA,IADFC,6BACE,QADFA,6BACE;;IAAA;;IACF,KAAKd,MAAL,GAAcA,MAAd;IACA,KAAKC,6BAAL,GAAqCA,6BAArC;IACA,KAAKC,uCAAL,GAA+CA,uCAA/C;IACA,KAAKC,qBAAL,GAA6BA,qBAA7B;IACA,KAAKC,kBAAL,GAA0BA,kBAA1B;IACA,KAAKC,kBAAL,GAA0BA,kBAA1B;IACA,KAAKC,8BAAL,GAAsCA,8BAAtC;IACA,KAAKC,eAAL,GAAuBA,eAAvB;IACA,KAAKC,2BAAL,GAAmCA,2BAAnC;IACA,KAAKC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AAG,KAAKzF,eAAL,EAApC,GAA6DwE,WAD3C,CAAnB;;UAGA,IAAIC,UAAU,KAAKrB,SAAnB,EAA8B;YAC7B;UACA;;UACD8B,UAAS,GAAGtD,IAAI,CAAC+C,GAAL,CAASO,UAAT,EAAoBT,UAApB,CAAZ;UACAD,WAAW;QACX;;QAEDY,kCAAkC,IAAIF,UAAtC;QACAE,kCAAkC,IAAI,KAAKtF,kBAAL,EAAtC;QAEA2F,QAAQ;MACR;;MAED,OAAOL,kCAAP;IACA;;;;;;;AAGK,IAAMM,aAAa,GAAG;EAC5BC,MAAM,EAAE,QADoB;EAE5BC,iBAAiB,EAAE,mBAFS;EAG5BC,MAAM,EAAE,QAHoB;EAI5BC,OAAO,EAAE,SAJmB;EAK5BC,qCAAqC,EAAE,8CALX;EAM5BC,sBAAsB,EAAE,wBANI;EAO5BC,uBAAuB,EAAE,yBAPG;EAQ5BC,uBAAuB,EAAE,yBARG;EAS5BC,mBAAmB,EAAE,qBATO;EAU5BC,aAAa,EAAE,eAVa;EAW5BC,kBAAkB,EAAE;AAXQ,CAAtB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
+
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
|
|
14
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
+
|
|
16
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
+
|
|
18
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
19
|
+
|
|
20
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
21
|
+
|
|
22
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
|
+
|
|
24
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
25
|
+
|
|
26
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
27
|
+
|
|
28
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
29
|
+
|
|
30
|
+
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
31
|
+
|
|
32
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
33
|
+
|
|
34
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
+
|
|
36
|
+
var ScrollableContainerNotReadyError = /*#__PURE__*/function (_Error) {
|
|
37
|
+
_inherits(ScrollableContainerNotReadyError, _Error);
|
|
38
|
+
|
|
39
|
+
var _super = _createSuper(ScrollableContainerNotReadyError);
|
|
40
|
+
|
|
41
|
+
function ScrollableContainerNotReadyError() {
|
|
42
|
+
_classCallCheck(this, ScrollableContainerNotReadyError);
|
|
43
|
+
|
|
44
|
+
return _super.call(this, '[virtual-scroller] Scrollable container not found');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return _createClass(ScrollableContainerNotReadyError);
|
|
48
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
49
|
+
|
|
50
|
+
exports["default"] = ScrollableContainerNotReadyError;
|
|
51
|
+
//# sourceMappingURL=ScrollableContainerNotReadyError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScrollableContainerNotReadyError.js","names":["ScrollableContainerNotReadyError","Error"],"sources":["../source/ScrollableContainerNotReadyError.js"],"sourcesContent":["export default class ScrollableContainerNotReadyError extends Error {\r\n\tconstructor() {\r\n\t\tsuper('[virtual-scroller] Scrollable container not found');\r\n\t}\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAqBA,gC;;;;;EACpB,4CAAc;IAAA;;IAAA,yBACP,mDADO;EAEb;;;iCAH4DC,K"}
|