virtual-scroller 1.16.2 → 1.16.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +75 -35
  3. package/bundle/virtual-scroller-dom.js +1 -1
  4. package/bundle/virtual-scroller-dom.js.map +1 -1
  5. package/bundle/virtual-scroller-react.js +1 -1
  6. package/bundle/virtual-scroller-react.js.map +1 -1
  7. package/bundle/virtual-scroller.js +1 -1
  8. package/bundle/virtual-scroller.js.map +1 -1
  9. package/commonjs/DOM/ListTopOffsetWatcher.js +2 -4
  10. package/commonjs/DOM/ListTopOffsetWatcher.js.map +1 -1
  11. package/commonjs/Layout.test.js +26 -24
  12. package/commonjs/Layout.test.js.map +1 -1
  13. package/commonjs/Scroll.js +8 -11
  14. package/commonjs/Scroll.js.map +1 -1
  15. package/commonjs/VirtualScroller.constructor.js +7 -8
  16. package/commonjs/VirtualScroller.constructor.js.map +1 -1
  17. package/commonjs/VirtualScroller.js +10 -1
  18. package/commonjs/VirtualScroller.js.map +1 -1
  19. package/commonjs/VirtualScroller.layout.js +62 -20
  20. package/commonjs/VirtualScroller.layout.js.map +1 -1
  21. package/commonjs/VirtualScroller.onRender.js +25 -2
  22. package/commonjs/VirtualScroller.onRender.js.map +1 -1
  23. package/commonjs/VirtualScroller.state.js +39 -0
  24. package/commonjs/VirtualScroller.state.js.map +1 -1
  25. package/commonjs/react/useCreateVirtualScroller.js +1 -1
  26. package/commonjs/react/useCreateVirtualScroller.js.map +1 -1
  27. package/commonjs/test/VirtualScroller.js +8 -3
  28. package/commonjs/test/VirtualScroller.js.map +1 -1
  29. package/commonjs/utility/px.test.js +9 -5
  30. package/commonjs/utility/px.test.js.map +1 -1
  31. package/commonjs/utility/scheduleOnNextTick.js +25 -0
  32. package/commonjs/utility/scheduleOnNextTick.js.map +1 -0
  33. package/index.d.ts +4 -0
  34. package/modules/DOM/ListTopOffsetWatcher.js +1 -6
  35. package/modules/DOM/ListTopOffsetWatcher.js.map +1 -1
  36. package/modules/Layout.test.js +20 -19
  37. package/modules/Layout.test.js.map +1 -1
  38. package/modules/Scroll.js +8 -11
  39. package/modules/Scroll.js.map +1 -1
  40. package/modules/VirtualScroller.constructor.js +7 -8
  41. package/modules/VirtualScroller.constructor.js.map +1 -1
  42. package/modules/VirtualScroller.js +9 -1
  43. package/modules/VirtualScroller.js.map +1 -1
  44. package/modules/VirtualScroller.layout.js +61 -23
  45. package/modules/VirtualScroller.layout.js.map +1 -1
  46. package/modules/VirtualScroller.onRender.js +24 -2
  47. package/modules/VirtualScroller.onRender.js.map +1 -1
  48. package/modules/VirtualScroller.state.js +39 -1
  49. package/modules/VirtualScroller.state.js.map +1 -1
  50. package/modules/react/useCreateVirtualScroller.js +1 -1
  51. package/modules/react/useCreateVirtualScroller.js.map +1 -1
  52. package/modules/test/VirtualScroller.js +5 -2
  53. package/modules/test/VirtualScroller.js.map +1 -1
  54. package/modules/utility/px.test.js +5 -3
  55. package/modules/utility/px.test.js.map +1 -1
  56. package/modules/utility/scheduleOnNextTick.js +15 -0
  57. package/modules/utility/scheduleOnNextTick.js.map +1 -0
  58. package/package.json +6 -5
  59. package/source/DOM/ListTopOffsetWatcher.js +0 -6
  60. package/source/Layout.test.js +21 -20
  61. package/source/Scroll.js +7 -9
  62. package/source/VirtualScroller.constructor.js +7 -7
  63. package/source/VirtualScroller.js +8 -0
  64. package/source/VirtualScroller.layout.js +61 -25
  65. package/source/VirtualScroller.onRender.js +29 -3
  66. package/source/VirtualScroller.state.js +38 -0
  67. package/source/react/useCreateVirtualScroller.js +1 -1
  68. package/source/test/VirtualScroller.js +6 -2
  69. package/source/utility/px.test.js +6 -3
  70. package/source/utility/scheduleOnNextTick.js +16 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ListTopOffsetWatcher.js","names":["setTimeout","clearTimeout","WATCH_LIST_TOP_OFFSET_INTERVAL","WATCH_LIST_TOP_OFFSET_MAX_DURATION","ListTopOffsetWatcher","getListTopOffset","onListTopOffsetChange","listTopOffset","listTopOffsetInsideScrollableContainer","undefined","start","_isActive","watchListTopOffset","watchListTopOffsetTimer","startedAt","Date","now","check"],"sources":["../../source/DOM/ListTopOffsetWatcher.js"],"sourcesContent":["// For some weird reason, in Chrome, `setTimeout()` would lag up to a second (or more) behind.\r\n// Turns out, Chrome developers have deprecated `setTimeout()` API entirely without asking anyone.\r\n// Replacing `setTimeout()` with `requestAnimationFrame()` can work around that Chrome bug.\r\n// https://github.com/bvaughn/react-virtualized/issues/722\r\nimport { setTimeout, clearTimeout } from 'request-animation-frame-timeout'\r\n\r\n// Refreshing two times every seconds seems reasonable.\r\nconst WATCH_LIST_TOP_OFFSET_INTERVAL = 500\r\n\r\n// Refreshing for 3 seconds after the initial page load seems reasonable.\r\nconst WATCH_LIST_TOP_OFFSET_MAX_DURATION = 3000\r\n\r\n// `VirtualScroller` calls `this.layout.layOut()` on mount,\r\n// but if the page styles are applied after `VirtualScroller` mounts\r\n// (for example, if styles are applied via javascript, like Webpack does)\r\n// then the list might not render correctly and it will only show the first item.\r\n// The reason is that in that case calling `.getListTopOffset()` on mount\r\n// returns \"incorrect\" `top` position because the styles haven't been applied yet.\r\n//\r\n// For example, consider a page:\r\n//\r\n// <div class=\"page\">\r\n// <nav class=\"sidebar\">...</nav>\r\n// <main>...</main>\r\n// </div>\r\n//\r\n// The sidebar is styled as `position: fixed`, but, until\r\n// the page styles have been applied, it's gonna be a regular `<div/>`\r\n// meaning that `<main/>` will be rendered below the sidebar\r\n// and will appear offscreen, and so it will only render the first item.\r\n//\r\n// Then, the page styles are loaded and applied, and the sidebar\r\n// is now `position: fixed`, so `<main/>` is now rendered at the top of the page,\r\n// but `VirtualScroller`'s `.render()` has already been called\r\n// and it won't re-render until the user scrolls or the window is resized.\r\n//\r\n// This type of a bug doesn't seem to occur in production, but it can appear\r\n// in development mode when using Webpack. The workaround `VirtualScroller`\r\n// implements for such cases is calling `.getListTopOffset()`\r\n// on the list container DOM element periodically (every second) to check\r\n// if the `top` coordinate has changed as a result of CSS being applied:\r\n// if it has then it recalculates the shown item indexes.\r\n//\r\n// Maybe this bug could occur in production when using Webpack chunks.\r\n// That depends on how a style of a chunk is added to the page:\r\n// if it's added via `javascript` after the page has been rendered\r\n// then this workaround will also work for that case.\r\n//\r\n// Another example would be a page having a really tall expanded \"accordion\"\r\n// section, below which a `VirtualScroller` list resides. If the user un-expands\r\n// such expanded \"accordion\" section, the list would become visible but\r\n// it wouldn't get re-rendered because no `scroll` event has occured,\r\n// and the list only re-renders automatically on `scroll` events.\r\n// To work around such cases, call `virtualScroller.updateLayout()` method manually.\r\n// The workaround below could be extended to refresh the list's top coordinate\r\n// indefinitely and at higher intervals, but why waste CPU time on that.\r\n// There doesn't seem to be any DOM API for tracking an element's top position.\r\n// There is `IntersectionObserver` API but it doesn't exactly do that.\r\n//\r\nexport default class ListTopOffsetWatcher {\r\n\tconstructor({\r\n\t\tgetListTopOffset,\r\n\t\tonListTopOffsetChange\r\n\t}) {\r\n\t\tthis.getListTopOffset = getListTopOffset\r\n\t\tthis.onListTopOffsetChange = onListTopOffsetChange\r\n\t}\r\n\r\n\tonListTopOffset(listTopOffset) {\r\n\t\tif (this.listTopOffsetInsideScrollableContainer === undefined) {\r\n\t\t\t// Start periodical checks of the list's top offset\r\n\t\t\t// in order to perform a re-layout in case it changes.\r\n\t\t\t// See the comments in `ListTopOffsetWatcher.js` file\r\n\t\t\t// on why can the list's top offset change, and in which circumstances.\r\n\t\t\tthis.start()\r\n\t\t}\r\n\t\tthis.listTopOffsetInsideScrollableContainer = listTopOffset\r\n\t}\r\n\r\n\tstart() {\r\n\t\tthis._isActive = true\r\n\t\tthis.watchListTopOffset()\r\n\t}\r\n\r\n\tisStarted() {\r\n\t\treturn this._isActive\r\n\t}\r\n\r\n\tstop() {\r\n\t\tthis._isActive = false\r\n\r\n\t\tif (this.watchListTopOffsetTimer) {\r\n\t\t\tclearTimeout(this.watchListTopOffsetTimer)\r\n\t\t\tthis.watchListTopOffsetTimer = undefined\r\n\t\t}\r\n\t}\r\n\r\n\twatchListTopOffset() {\r\n\t\tconst startedAt = Date.now()\r\n\t\tconst check = () => {\r\n\t\t\t// If `VirtualScroller` has been unmounted\r\n\t\t\t// while `setTimeout()` was waiting, then exit.\r\n\t\t\tif (!this._isActive) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\t// Skip comparing `top` coordinate of the list\r\n\t\t\t// when this function is called for the first time.\r\n\t\t\tif (this.listTopOffsetInsideScrollableContainer !== undefined) {\r\n\t\t\t\t// Calling `this.getListTopOffset()` on an element\r\n\t\t\t\t// runs about 0.003 milliseconds on a modern desktop CPU,\r\n\t\t\t\t// so I guess it's fine calling it twice a second.\r\n\t\t\t\tif (this.getListTopOffset() !== this.listTopOffsetInsideScrollableContainer) {\r\n\t\t\t\t\tthis.onListTopOffsetChange()\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// Compare `top` coordinate of the list twice a second\r\n\t\t\t// to find out if it has changed as a result of loading CSS styles.\r\n\t\t\t// The total duration of 3 seconds would be enough for any styles to load, I guess.\r\n\t\t\t// There could be other cases changing the `top` coordinate\r\n\t\t\t// of the list (like collapsing an \"accordeon\" panel above the list\r\n\t\t\t// without scrolling the page), but those cases should be handled\r\n\t\t\t// by manually calling `.updateLayout()` instance method on `VirtualScroller` instance.\r\n\t\t\tif (Date.now() - startedAt < WATCH_LIST_TOP_OFFSET_MAX_DURATION) {\r\n\t\t\t\tthis.watchListTopOffsetTimer = setTimeout(check, WATCH_LIST_TOP_OFFSET_INTERVAL)\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Run the cycle.\r\n\t\tcheck()\r\n\t}\r\n}"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,YAArB,QAAyC,iCAAzC,C,CAEA;;AACA,IAAMC,8BAA8B,GAAG,GAAvC,C,CAEA;;AACA,IAAMC,kCAAkC,GAAG,IAA3C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,CAfkB,CAgBnB;QACA;QACA;QACA;QACA;QACA;QACA;;;QACA,IAAIS,IAAI,CAACC,GAAL,KAAaF,SAAb,GAAyBX,kCAA7B,EAAiE;UAChE,KAAI,CAACU,uBAAL,GAA+Bb,UAAU,CAACiB,KAAD,EAAQf,8BAAR,CAAzC;QACA;MACD,CA1BD,CAFoB,CA6BpB;;;MACAe,KAAK;IACL;;;;;;SArEmBb,oB"}
1
+ {"version":3,"file":"ListTopOffsetWatcher.js","names":["WATCH_LIST_TOP_OFFSET_INTERVAL","WATCH_LIST_TOP_OFFSET_MAX_DURATION","ListTopOffsetWatcher","getListTopOffset","onListTopOffsetChange","listTopOffset","listTopOffsetInsideScrollableContainer","undefined","start","_isActive","watchListTopOffset","watchListTopOffsetTimer","clearTimeout","startedAt","Date","now","check","setTimeout"],"sources":["../../source/DOM/ListTopOffsetWatcher.js"],"sourcesContent":["// Refreshing two times every seconds seems reasonable.\r\nconst WATCH_LIST_TOP_OFFSET_INTERVAL = 500\r\n\r\n// Refreshing for 3 seconds after the initial page load seems reasonable.\r\nconst WATCH_LIST_TOP_OFFSET_MAX_DURATION = 3000\r\n\r\n// `VirtualScroller` calls `this.layout.layOut()` on mount,\r\n// but if the page styles are applied after `VirtualScroller` mounts\r\n// (for example, if styles are applied via javascript, like Webpack does)\r\n// then the list might not render correctly and it will only show the first item.\r\n// The reason is that in that case calling `.getListTopOffset()` on mount\r\n// returns \"incorrect\" `top` position because the styles haven't been applied yet.\r\n//\r\n// For example, consider a page:\r\n//\r\n// <div class=\"page\">\r\n// <nav class=\"sidebar\">...</nav>\r\n// <main>...</main>\r\n// </div>\r\n//\r\n// The sidebar is styled as `position: fixed`, but, until\r\n// the page styles have been applied, it's gonna be a regular `<div/>`\r\n// meaning that `<main/>` will be rendered below the sidebar\r\n// and will appear offscreen, and so it will only render the first item.\r\n//\r\n// Then, the page styles are loaded and applied, and the sidebar\r\n// is now `position: fixed`, so `<main/>` is now rendered at the top of the page,\r\n// but `VirtualScroller`'s `.render()` has already been called\r\n// and it won't re-render until the user scrolls or the window is resized.\r\n//\r\n// This type of a bug doesn't seem to occur in production, but it can appear\r\n// in development mode when using Webpack. The workaround `VirtualScroller`\r\n// implements for such cases is calling `.getListTopOffset()`\r\n// on the list container DOM element periodically (every second) to check\r\n// if the `top` coordinate has changed as a result of CSS being applied:\r\n// if it has then it recalculates the shown item indexes.\r\n//\r\n// Maybe this bug could occur in production when using Webpack chunks.\r\n// That depends on how a style of a chunk is added to the page:\r\n// if it's added via `javascript` after the page has been rendered\r\n// then this workaround will also work for that case.\r\n//\r\n// Another example would be a page having a really tall expanded \"accordion\"\r\n// section, below which a `VirtualScroller` list resides. If the user un-expands\r\n// such expanded \"accordion\" section, the list would become visible but\r\n// it wouldn't get re-rendered because no `scroll` event has occured,\r\n// and the list only re-renders automatically on `scroll` events.\r\n// To work around such cases, call `virtualScroller.updateLayout()` method manually.\r\n// The workaround below could be extended to refresh the list's top coordinate\r\n// indefinitely and at higher intervals, but why waste CPU time on that.\r\n// There doesn't seem to be any DOM API for tracking an element's top position.\r\n// There is `IntersectionObserver` API but it doesn't exactly do that.\r\n//\r\nexport default class ListTopOffsetWatcher {\r\n\tconstructor({\r\n\t\tgetListTopOffset,\r\n\t\tonListTopOffsetChange\r\n\t}) {\r\n\t\tthis.getListTopOffset = getListTopOffset\r\n\t\tthis.onListTopOffsetChange = onListTopOffsetChange\r\n\t}\r\n\r\n\tonListTopOffset(listTopOffset) {\r\n\t\tif (this.listTopOffsetInsideScrollableContainer === undefined) {\r\n\t\t\t// Start periodical checks of the list's top offset\r\n\t\t\t// in order to perform a re-layout in case it changes.\r\n\t\t\t// See the comments in `ListTopOffsetWatcher.js` file\r\n\t\t\t// on why can the list's top offset change, and in which circumstances.\r\n\t\t\tthis.start()\r\n\t\t}\r\n\t\tthis.listTopOffsetInsideScrollableContainer = listTopOffset\r\n\t}\r\n\r\n\tstart() {\r\n\t\tthis._isActive = true\r\n\t\tthis.watchListTopOffset()\r\n\t}\r\n\r\n\tisStarted() {\r\n\t\treturn this._isActive\r\n\t}\r\n\r\n\tstop() {\r\n\t\tthis._isActive = false\r\n\r\n\t\tif (this.watchListTopOffsetTimer) {\r\n\t\t\tclearTimeout(this.watchListTopOffsetTimer)\r\n\t\t\tthis.watchListTopOffsetTimer = undefined\r\n\t\t}\r\n\t}\r\n\r\n\twatchListTopOffset() {\r\n\t\tconst startedAt = Date.now()\r\n\t\tconst check = () => {\r\n\t\t\t// If `VirtualScroller` has been unmounted\r\n\t\t\t// while `setTimeout()` was waiting, then exit.\r\n\t\t\tif (!this._isActive) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\t// Skip comparing `top` coordinate of the list\r\n\t\t\t// when this function is called for the first time.\r\n\t\t\tif (this.listTopOffsetInsideScrollableContainer !== undefined) {\r\n\t\t\t\t// Calling `this.getListTopOffset()` on an element\r\n\t\t\t\t// runs about 0.003 milliseconds on a modern desktop CPU,\r\n\t\t\t\t// so I guess it's fine calling it twice a second.\r\n\t\t\t\tif (this.getListTopOffset() !== this.listTopOffsetInsideScrollableContainer) {\r\n\t\t\t\t\tthis.onListTopOffsetChange()\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// Compare `top` coordinate of the list twice a second\r\n\t\t\t// to find out if it has changed as a result of loading CSS styles.\r\n\t\t\t// The total duration of 3 seconds would be enough for any styles to load, I guess.\r\n\t\t\t// There could be other cases changing the `top` coordinate\r\n\t\t\t// of the list (like collapsing an \"accordeon\" panel above the list\r\n\t\t\t// without scrolling the page), but those cases should be handled\r\n\t\t\t// by manually calling `.updateLayout()` instance method on `VirtualScroller` instance.\r\n\t\t\tif (Date.now() - startedAt < WATCH_LIST_TOP_OFFSET_MAX_DURATION) {\r\n\t\t\t\tthis.watchListTopOffsetTimer = setTimeout(check, WATCH_LIST_TOP_OFFSET_INTERVAL)\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Run the cycle.\r\n\t\tcheck()\r\n\t}\r\n}"],"mappings":";;;;;;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ACJ,gBAAL,OAA4B,KAAI,CAACG,sCAArC,EAA6E;YAC5E,KAAI,CAACF,qBAAL;UACA;QACD,CAfkB,CAgBnB;QACA;QACA;QACA;QACA;QACA;QACA;;;QACA,IAAIU,IAAI,CAACC,GAAL,KAAaF,SAAb,GAAyBZ,kCAA7B,EAAiE;UAChE,KAAI,CAACU,uBAAL,GAA+BM,UAAU,CAACD,KAAD,EAAQhB,8BAAR,CAAzC;QACA;MACD,CA1BD,CAFoB,CA6BpB;;;MACAgB,KAAK;IACL;;;;;;SArEmBd,oB"}
@@ -1,5 +1,6 @@
1
+ import { describe, it } from 'mocha';
2
+ import { expect } from 'chai';
1
3
  import Layout from './Layout.js';
2
- import Engine from './test/Engine.js';
3
4
  describe('Layout', function () {
4
5
  it('should work', function () {
5
6
  var SCREEN_HEIGHT = 400;
@@ -35,57 +36,57 @@ describe('Layout', function () {
35
36
  }
36
37
  }); // Initial render.
37
38
 
38
- layout.getShownItemIndexes({
39
+ expect(layout.getShownItemIndexes({
39
40
  itemsCount: items.length,
40
41
  visibleAreaInsideTheList: {
41
42
  top: 0,
42
43
  bottom: SCREEN_HEIGHT
43
44
  }
44
- }).should.deep.equal({
45
+ })).to.deep.equal({
45
46
  firstShownItemIndex: 0,
46
47
  lastShownItemIndex: 2
47
48
  }); // The first item is almost hidden.
48
49
 
49
- layout.getShownItemIndexes({
50
+ expect(layout.getShownItemIndexes({
50
51
  itemsCount: items.length,
51
52
  visibleAreaInsideTheList: {
52
53
  top: SCREEN_HEIGHT + ITEM_HEIGHT - 1,
53
54
  bottom: SCREEN_HEIGHT + ITEM_HEIGHT - 1 + SCREEN_HEIGHT
54
55
  }
55
- }).should.deep.equal({
56
+ })).to.deep.equal({
56
57
  firstShownItemIndex: 0,
57
58
  lastShownItemIndex: 4
58
59
  }); // The first item is hidden.
59
60
 
60
- layout.getShownItemIndexes({
61
+ expect(layout.getShownItemIndexes({
61
62
  itemsCount: items.length,
62
63
  visibleAreaInsideTheList: {
63
64
  top: SCREEN_HEIGHT + ITEM_HEIGHT,
64
65
  bottom: SCREEN_HEIGHT + ITEM_HEIGHT + SCREEN_HEIGHT
65
66
  }
66
- }).should.deep.equal({
67
+ })).to.deep.equal({
67
68
  firstShownItemIndex: 1,
68
69
  lastShownItemIndex: 4
69
70
  }); // A new item at the bottom is almost visible.
70
71
 
71
- layout.getShownItemIndexes({
72
+ expect(layout.getShownItemIndexes({
72
73
  itemsCount: items.length,
73
74
  visibleAreaInsideTheList: {
74
75
  top: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 - SCREEN_HEIGHT * 2,
75
76
  bottom: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 - SCREEN_HEIGHT
76
77
  }
77
- }).should.deep.equal({
78
+ })).to.deep.equal({
78
79
  firstShownItemIndex: 1,
79
80
  lastShownItemIndex: 4
80
81
  }); // A new item at the bottom is visible.
81
82
 
82
- layout.getShownItemIndexes({
83
+ expect(layout.getShownItemIndexes({
83
84
  itemsCount: items.length,
84
85
  visibleAreaInsideTheList: {
85
86
  top: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 + 1 - SCREEN_HEIGHT * 2,
86
87
  bottom: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 + 1 - SCREEN_HEIGHT
87
88
  }
88
- }).should.deep.equal({
89
+ })).to.deep.equal({
89
90
  firstShownItemIndex: 1,
90
91
  lastShownItemIndex: 5
91
92
  });
@@ -122,7 +123,7 @@ describe('Layout', function () {
122
123
  return scrollableContainer.height;
123
124
  }
124
125
  });
125
- layout.getLayoutUpdateForItemsDiff({
126
+ expect(layout.getLayoutUpdateForItemsDiff({
126
127
  firstShownItemIndex: 3,
127
128
  lastShownItemIndex: 5,
128
129
  beforeItemsHeight: 3 * (ITEM_HEIGHT + VERTICAL_SPACING),
@@ -133,7 +134,7 @@ describe('Layout', function () {
133
134
  }, {
134
135
  itemsCount: 5 + 5 + items.length,
135
136
  columnsCount: 1
136
- }).should.deep.equal({
137
+ })).to.deep.equal({
137
138
  firstShownItemIndex: 5 + 3,
138
139
  lastShownItemIndex: 5 + 5,
139
140
  beforeItemsHeight: (5 + 3) * (ITEM_HEIGHT + VERTICAL_SPACING),
@@ -180,7 +181,7 @@ describe('Layout', function () {
180
181
  errors.push(error);
181
182
  };
182
183
 
183
- layout.getLayoutUpdateForItemsDiff({
184
+ expect(layout.getLayoutUpdateForItemsDiff({
184
185
  firstShownItemIndex: 3,
185
186
  lastShownItemIndex: 5,
186
187
  beforeItemsHeight: 3 * (ITEM_HEIGHT + VERTICAL_SPACING),
@@ -195,7 +196,7 @@ describe('Layout', function () {
195
196
  onResetGridLayout: function onResetGridLayout() {
196
197
  return shouldResetGridLayout = true;
197
198
  }
198
- }).should.deep.equal({
199
+ })).to.deep.equal({
199
200
  firstShownItemIndex: 0,
200
201
  lastShownItemIndex: 5 + 5,
201
202
  beforeItemsHeight: 0,
@@ -205,10 +206,10 @@ describe('Layout', function () {
205
206
 
206
207
  global.VirtualScrollerCatchError = undefined; // Verify the errors that have been `throw`-n.
207
208
 
208
- errors.length.should.equal(2);
209
- errors[0].message.should.equal('[virtual-scroller] ~ Prepended items count 5 is not divisible by Columns Count 4 ~');
210
- errors[1].message.should.equal('[virtual-scroller] Layout reset required');
211
- shouldResetGridLayout.should.equal(true);
209
+ expect(errors.length).to.equal(2);
210
+ expect(errors[0].message).to.equal('[virtual-scroller] ~ Prepended items count 5 is not divisible by Columns Count 4 ~');
211
+ expect(errors[1].message).to.equal('[virtual-scroller] Layout reset required');
212
+ expect(shouldResetGridLayout).to.equal(true);
212
213
  });
213
214
  });
214
215
  //# sourceMappingURL=Layout.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Layout.test.js","names":["Layout","Engine","describe","it","SCREEN_HEIGHT","scrollableContainer","width","height","ITEM_WIDTH","ITEM_HEIGHT","VERTICAL_SPACING","items","Array","fill","layout","getPrerenderMargin","getVerticalSpacing","getColumnsCount","getItemHeight","i","getBeforeResizeItemsCount","getAverageItemHeight","getScrollableContainerHeight","getShownItemIndexes","itemsCount","length","visibleAreaInsideTheList","top","bottom","should","deep","equal","firstShownItemIndex","lastShownItemIndex","getLayoutUpdateForItemsDiff","beforeItemsHeight","afterItemsHeight","prependedItemsCount","appendedItemsCount","columnsCount","shouldResetGridLayout","errors","global","VirtualScrollerCatchError","error","push","shouldRestoreScrollPosition","onResetGridLayout","undefined","message"],"sources":["../source/Layout.test.js"],"sourcesContent":["import Layout from './Layout.js'\r\n\r\nimport Engine from './test/Engine.js'\r\n\r\ndescribe('Layout', function() {\r\n\tit('should work', function() {\r\n\t\tconst SCREEN_HEIGHT = 400\r\n\r\n\t\tconst scrollableContainer = {\r\n\t\t\twidth: 800,\r\n\t\t\theight: SCREEN_HEIGHT\r\n\t\t}\r\n\r\n\t\tconst ITEM_WIDTH = scrollableContainer.width\r\n\t\tconst ITEM_HEIGHT = 200\r\n\r\n\t\tconst VERTICAL_SPACING = 100\r\n\r\n\t\tconst items = new Array(9).fill(ITEM_WIDTH * ITEM_HEIGHT)\r\n\r\n\t\tconst layout = new Layout({\r\n\t\t\tgetPrerenderMargin: () => SCREEN_HEIGHT,\r\n\t\t\tgetVerticalSpacing: () => VERTICAL_SPACING,\r\n\t\t\tgetColumnsCount: () => 1,\r\n\t\t\tgetItemHeight: (i) => items[i] / scrollableContainer.width,\r\n\t\t\tgetBeforeResizeItemsCount: () => 0,\r\n\t\t\tgetAverageItemHeight: () => ITEM_HEIGHT,\r\n\t\t\tgetScrollableContainerHeight: () => scrollableContainer.height\r\n\t\t})\r\n\r\n\t\t// Initial render.\r\n\t\tlayout.getShownItemIndexes({\r\n\t\t\titemsCount: items.length,\r\n\t\t\tvisibleAreaInsideTheList: {\r\n\t\t\t\ttop: 0,\r\n\t\t\t\tbottom: SCREEN_HEIGHT\r\n\t\t\t}\r\n\t\t}).should.deep.equal({\r\n\t\t\tfirstShownItemIndex: 0,\r\n\t\t\tlastShownItemIndex: 2\r\n\t\t})\r\n\r\n\t\t// The first item is almost hidden.\r\n\t\tlayout.getShownItemIndexes({\r\n\t\t\titemsCount: items.length,\r\n\t\t\tvisibleAreaInsideTheList: {\r\n\t\t\t\ttop: SCREEN_HEIGHT + ITEM_HEIGHT - 1,\r\n\t\t\t\tbottom: (SCREEN_HEIGHT + ITEM_HEIGHT - 1) + SCREEN_HEIGHT\r\n\t\t\t}\r\n\t\t}).should.deep.equal({\r\n\t\t\tfirstShownItemIndex: 0,\r\n\t\t\tlastShownItemIndex: 4\r\n\t\t})\r\n\r\n\t\t// The first item is hidden.\r\n\t\tlayout.getShownItemIndexes({\r\n\t\t\titemsCount: items.length,\r\n\t\t\tvisibleAreaInsideTheList: {\r\n\t\t\t\ttop: SCREEN_HEIGHT + ITEM_HEIGHT,\r\n\t\t\t\tbottom: (SCREEN_HEIGHT + ITEM_HEIGHT) + SCREEN_HEIGHT\r\n\t\t\t}\r\n\t\t}).should.deep.equal({\r\n\t\t\tfirstShownItemIndex: 1,\r\n\t\t\tlastShownItemIndex: 4\r\n\t\t})\r\n\r\n\t\t// A new item at the bottom is almost visible.\r\n\t\tlayout.getShownItemIndexes({\r\n\t\t\titemsCount: items.length,\r\n\t\t\tvisibleAreaInsideTheList: {\r\n\t\t\t\ttop: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 - SCREEN_HEIGHT * 2,\r\n\t\t\t\tbottom: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 - SCREEN_HEIGHT\r\n\t\t\t}\r\n\t\t}).should.deep.equal({\r\n\t\t\tfirstShownItemIndex: 1,\r\n\t\t\tlastShownItemIndex: 4\r\n\t\t})\r\n\r\n\t\t// A new item at the bottom is visible.\r\n\t\tlayout.getShownItemIndexes({\r\n\t\t\titemsCount: items.length,\r\n\t\t\tvisibleAreaInsideTheList: {\r\n\t\t\t\ttop: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 + 1 - SCREEN_HEIGHT * 2,\r\n\t\t\t\tbottom: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 + 1 - SCREEN_HEIGHT\r\n\t\t\t}\r\n\t\t}).should.deep.equal({\r\n\t\t\tfirstShownItemIndex: 1,\r\n\t\t\tlastShownItemIndex: 5\r\n\t\t})\r\n\t})\r\n\r\n\tit('should update layout for items incremental change', function() {\r\n\t\tconst scrollableContainer = {\r\n\t\t\twidth: 800,\r\n\t\t\theight: 400\r\n\t\t}\r\n\r\n\t\tconst ITEM_WIDTH = scrollableContainer.width\r\n\t\tconst ITEM_HEIGHT = 200\r\n\r\n\t\tconst items = new Array(9).fill(ITEM_WIDTH * ITEM_HEIGHT)\r\n\r\n\t\tconst VERTICAL_SPACING = 100\r\n\r\n\t\tconst layout = new Layout({\r\n\t\t\tgetPrerenderMargin: () => scrollableContainer.height,\r\n\t\t\tgetVerticalSpacing: () => VERTICAL_SPACING,\r\n\t\t\tgetColumnsCount: () => 1,\r\n\t\t\tgetItemHeight: (i) => ITEM_HEIGHT,\r\n\t\t\tgetBeforeResizeItemsCount: () => 0,\r\n\t\t\tgetAverageItemHeight: () => ITEM_HEIGHT,\r\n\t\t\tgetScrollableContainerHeight: () => scrollableContainer.height\r\n\t\t})\r\n\r\n\t\tlayout.getLayoutUpdateForItemsDiff(\r\n\t\t\t{\r\n\t\t\t\tfirstShownItemIndex: 3,\r\n\t\t\t\tlastShownItemIndex: 5,\r\n\t\t\t\tbeforeItemsHeight: 3 * (ITEM_HEIGHT + VERTICAL_SPACING),\r\n\t\t\t\tafterItemsHeight: 3 * (ITEM_HEIGHT + VERTICAL_SPACING)\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tprependedItemsCount: 5,\r\n\t\t\t\tappendedItemsCount: 5\r\n\t\t\t}, {\r\n\t\t\t\titemsCount: 5 + 5 + items.length,\r\n\t\t\t\tcolumnsCount: 1\r\n\t\t\t}\r\n\t\t).should.deep.equal({\r\n\t\t\tfirstShownItemIndex: 5 + 3,\r\n\t\t\tlastShownItemIndex: 5 + 5,\r\n\t\t\tbeforeItemsHeight: (5 + 3) * (ITEM_HEIGHT + VERTICAL_SPACING),\r\n\t\t\tafterItemsHeight: (3 + 5) * (ITEM_HEIGHT + VERTICAL_SPACING)\r\n\t\t})\r\n\t})\r\n\r\n\tit('should update layout for items incremental change (rows get rebalanced)', function() {\r\n\t\tconst scrollableContainer = {\r\n\t\t\twidth: 800,\r\n\t\t\theight: 400\r\n\t\t}\r\n\t\tconst ITEM_WIDTH = scrollableContainer.width\r\n\t\tconst ITEM_HEIGHT = 400\r\n\r\n\t\tconst items = new Array(9).fill(ITEM_WIDTH * ITEM_HEIGHT)\r\n\r\n\t\tconst VERTICAL_SPACING = 100\r\n\r\n\t\tconst layout = new Layout({\r\n\t\t\tgetPrerenderMargin: () => scrollableContainer.height,\r\n\t\t\tgetVerticalSpacing: () => VERTICAL_SPACING,\r\n\t\t\tgetColumnsCount: () => 4,\r\n\t\t\tgetItemHeight: () => ITEM_HEIGHT,\r\n\t\t\tgetBeforeResizeItemsCount: () => 0,\r\n\t\t\tgetAverageItemHeight: () => ITEM_HEIGHT,\r\n\t\t\tgetScrollableContainerHeight: () => scrollableContainer.height\r\n\t\t})\r\n\r\n\t\tlet shouldResetGridLayout\r\n\r\n\t\t// Don't `throw` `VirtualScroller` errors but rather collect them in an array.\r\n\t\tconst errors = []\r\n\t\tglobal.VirtualScrollerCatchError = (error) => {\r\n\t\t\terrors.push(error)\r\n\t\t}\r\n\r\n\t\tlayout.getLayoutUpdateForItemsDiff(\r\n\t\t\t{\r\n\t\t\t\tfirstShownItemIndex: 3,\r\n\t\t\t\tlastShownItemIndex: 5,\r\n\t\t\t\tbeforeItemsHeight: 3 * (ITEM_HEIGHT + VERTICAL_SPACING),\r\n\t\t\t\tafterItemsHeight: 3 * (ITEM_HEIGHT + VERTICAL_SPACING)\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tprependedItemsCount: 5,\r\n\t\t\t\tappendedItemsCount: 5\r\n\t\t\t}, {\r\n\t\t\t\titemsCount: 5 + 5 + items.length,\r\n\t\t\t\tcolumnsCount: 4,\r\n\t\t\t\tshouldRestoreScrollPosition: true,\r\n\t\t\t\tonResetGridLayout: () => shouldResetGridLayout = true\r\n\t\t\t}\r\n\t\t).should.deep.equal({\r\n\t\t\tfirstShownItemIndex: 0,\r\n\t\t\tlastShownItemIndex: 5 + 5,\r\n\t\t\tbeforeItemsHeight: 0,\r\n\t\t\tafterItemsHeight: 5 * (ITEM_HEIGHT + VERTICAL_SPACING)\r\n\t\t})\r\n\r\n\t\t// Stop collecting `VirtualScroller` errors in the `errors` array.\r\n\t\t// Use the default behavior of just `throw`-ing such errors.\r\n\t\tglobal.VirtualScrollerCatchError = undefined\r\n\t\t// Verify the errors that have been `throw`-n.\r\n\t\terrors.length.should.equal(2)\r\n\t\terrors[0].message.should.equal('[virtual-scroller] ~ Prepended items count 5 is not divisible by Columns Count 4 ~')\r\n\t\terrors[1].message.should.equal('[virtual-scroller] Layout reset required')\r\n\r\n\t\tshouldResetGridLayout.should.equal(true)\r\n\t})\r\n})"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,aAAnB;AAEA,OAAOC,MAAP,MAAmB,kBAAnB;AAEAC,QAAQ,CAAC,QAAD,EAAW,YAAW;EAC7BC,EAAE,CAAC,aAAD,EAAgB,YAAW;IAC5B,IAAMC,aAAa,GAAG,GAAtB;IAEA,IAAMC,mBAAmB,GAAG;MAC3BC,KAAK,EAAE,GADoB;MAE3BC,MAAM,EAAEH;IAFmB,CAA5B;IAKA,IAAMI,UAAU,GAAGH,mBAAmB,CAACC,KAAvC;IACA,IAAMG,WAAW,GAAG,GAApB;IAEA,IAAMC,gBAAgB,GAAG,GAAzB;IAEA,IAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAU,CAAV,EAAaC,IAAb,CAAkBL,UAAU,GAAGC,WAA/B,CAAd;IAEA,IAAMK,MAAM,GAAG,IAAId,MAAJ,CAAW;MACzBe,kBAAkB,EAAE;QAAA,OAAMX,aAAN;MAAA,CADK;MAEzBY,kBAAkB,EAAE;QAAA,OAAMN,gBAAN;MAAA,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UI;MACFd,UAAU,EAAE,IAAI,CAAJ,GAAQb,KAAK,CAACc,MADxB;MAEFc,YAAY,EAAE,CAFZ;MAGFO,2BAA2B,EAAE,IAH3B;MAIFC,iBAAiB,EAAE;QAAA,OAAMP,qBAAqB,GAAG,IAA9B;MAAA;IAJjB,CAVJ,EAgBEX,MAhBF,CAgBSC,IAhBT,CAgBcC,KAhBd,CAgBoB;MACnBC,mBAAmB,EAAE,CADF;MAEnBC,kBAAkB,EAAE,IAAI,CAFL;MAGnBE,iBAAiB,EAAE,CAHA;MAInBC,gBAAgB,EAAE,KAAK3B,WAAW,GAAGC,gBAAnB;IAJC,CAhBpB,EA9BwF,CAqDxF;IACA;;IACAgC,MAAM,CAACC,yBAAP,GAAmCK,SAAnC,CAvDwF,CAwDxF;;IACAP,MAAM,CAAChB,MAAP,CAAcI,MAAd,CAAqBE,KAArB,CAA2B,CAA3B;IACAU,MAAM,CAAC,CAAD,CAAN,CAAUQ,OAAV,CAAkBpB,MAAlB,CAAyBE,KAAzB,CAA+B,oFAA/B;IACAU,MAAM,CAAC,CAAD,CAAN,CAAUQ,OAAV,CAAkBpB,MAAlB,CAAyBE,KAAzB,CAA+B,0CAA/B;IAEAS,qBAAqB,CAACX,MAAtB,CAA6BE,KAA7B,CAAmC,IAAnC;EACA,CA9DC,CAAF;AA+DA,CAnMO,CAAR"}
1
+ {"version":3,"file":"Layout.test.js","names":["describe","it","expect","Layout","SCREEN_HEIGHT","scrollableContainer","width","height","ITEM_WIDTH","ITEM_HEIGHT","VERTICAL_SPACING","items","Array","fill","layout","getPrerenderMargin","getVerticalSpacing","getColumnsCount","getItemHeight","i","getBeforeResizeItemsCount","getAverageItemHeight","getScrollableContainerHeight","getShownItemIndexes","itemsCount","length","visibleAreaInsideTheList","top","bottom","to","deep","equal","firstShownItemIndex","lastShownItemIndex","getLayoutUpdateForItemsDiff","beforeItemsHeight","afterItemsHeight","prependedItemsCount","appendedItemsCount","columnsCount","shouldResetGridLayout","errors","global","VirtualScrollerCatchError","error","push","shouldRestoreScrollPosition","onResetGridLayout","undefined","message"],"sources":["../source/Layout.test.js"],"sourcesContent":["import { describe, it } from 'mocha'\r\nimport { expect } from 'chai'\r\n\r\nimport Layout from './Layout.js'\r\n\r\ndescribe('Layout', function() {\r\n\tit('should work', function() {\r\n\t\tconst SCREEN_HEIGHT = 400\r\n\r\n\t\tconst scrollableContainer = {\r\n\t\t\twidth: 800,\r\n\t\t\theight: SCREEN_HEIGHT\r\n\t\t}\r\n\r\n\t\tconst ITEM_WIDTH = scrollableContainer.width\r\n\t\tconst ITEM_HEIGHT = 200\r\n\r\n\t\tconst VERTICAL_SPACING = 100\r\n\r\n\t\tconst items = new Array(9).fill(ITEM_WIDTH * ITEM_HEIGHT)\r\n\r\n\t\tconst layout = new Layout({\r\n\t\t\tgetPrerenderMargin: () => SCREEN_HEIGHT,\r\n\t\t\tgetVerticalSpacing: () => VERTICAL_SPACING,\r\n\t\t\tgetColumnsCount: () => 1,\r\n\t\t\tgetItemHeight: (i) => items[i] / scrollableContainer.width,\r\n\t\t\tgetBeforeResizeItemsCount: () => 0,\r\n\t\t\tgetAverageItemHeight: () => ITEM_HEIGHT,\r\n\t\t\tgetScrollableContainerHeight: () => scrollableContainer.height\r\n\t\t})\r\n\r\n\t\t// Initial render.\r\n\t\texpect(layout.getShownItemIndexes({\r\n\t\t\titemsCount: items.length,\r\n\t\t\tvisibleAreaInsideTheList: {\r\n\t\t\t\ttop: 0,\r\n\t\t\t\tbottom: SCREEN_HEIGHT\r\n\t\t\t}\r\n\t\t})).to.deep.equal({\r\n\t\t\tfirstShownItemIndex: 0,\r\n\t\t\tlastShownItemIndex: 2\r\n\t\t})\r\n\r\n\t\t// The first item is almost hidden.\r\n\t\texpect(layout.getShownItemIndexes({\r\n\t\t\titemsCount: items.length,\r\n\t\t\tvisibleAreaInsideTheList: {\r\n\t\t\t\ttop: SCREEN_HEIGHT + ITEM_HEIGHT - 1,\r\n\t\t\t\tbottom: (SCREEN_HEIGHT + ITEM_HEIGHT - 1) + SCREEN_HEIGHT\r\n\t\t\t}\r\n\t\t})).to.deep.equal({\r\n\t\t\tfirstShownItemIndex: 0,\r\n\t\t\tlastShownItemIndex: 4\r\n\t\t})\r\n\r\n\t\t// The first item is hidden.\r\n\t\texpect(layout.getShownItemIndexes({\r\n\t\t\titemsCount: items.length,\r\n\t\t\tvisibleAreaInsideTheList: {\r\n\t\t\t\ttop: SCREEN_HEIGHT + ITEM_HEIGHT,\r\n\t\t\t\tbottom: (SCREEN_HEIGHT + ITEM_HEIGHT) + SCREEN_HEIGHT\r\n\t\t\t}\r\n\t\t})).to.deep.equal({\r\n\t\t\tfirstShownItemIndex: 1,\r\n\t\t\tlastShownItemIndex: 4\r\n\t\t})\r\n\r\n\t\t// A new item at the bottom is almost visible.\r\n\t\texpect(layout.getShownItemIndexes({\r\n\t\t\titemsCount: items.length,\r\n\t\t\tvisibleAreaInsideTheList: {\r\n\t\t\t\ttop: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 - SCREEN_HEIGHT * 2,\r\n\t\t\t\tbottom: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 - SCREEN_HEIGHT\r\n\t\t\t}\r\n\t\t})).to.deep.equal({\r\n\t\t\tfirstShownItemIndex: 1,\r\n\t\t\tlastShownItemIndex: 4\r\n\t\t})\r\n\r\n\t\t// A new item at the bottom is visible.\r\n\t\texpect(layout.getShownItemIndexes({\r\n\t\t\titemsCount: items.length,\r\n\t\t\tvisibleAreaInsideTheList: {\r\n\t\t\t\ttop: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 + 1 - SCREEN_HEIGHT * 2,\r\n\t\t\t\tbottom: (ITEM_HEIGHT + VERTICAL_SPACING) * 5 + 1 - SCREEN_HEIGHT\r\n\t\t\t}\r\n\t\t})).to.deep.equal({\r\n\t\t\tfirstShownItemIndex: 1,\r\n\t\t\tlastShownItemIndex: 5\r\n\t\t})\r\n\t})\r\n\r\n\tit('should update layout for items incremental change', function() {\r\n\t\tconst scrollableContainer = {\r\n\t\t\twidth: 800,\r\n\t\t\theight: 400\r\n\t\t}\r\n\r\n\t\tconst ITEM_WIDTH = scrollableContainer.width\r\n\t\tconst ITEM_HEIGHT = 200\r\n\r\n\t\tconst items = new Array(9).fill(ITEM_WIDTH * ITEM_HEIGHT)\r\n\r\n\t\tconst VERTICAL_SPACING = 100\r\n\r\n\t\tconst layout = new Layout({\r\n\t\t\tgetPrerenderMargin: () => scrollableContainer.height,\r\n\t\t\tgetVerticalSpacing: () => VERTICAL_SPACING,\r\n\t\t\tgetColumnsCount: () => 1,\r\n\t\t\tgetItemHeight: (i) => ITEM_HEIGHT,\r\n\t\t\tgetBeforeResizeItemsCount: () => 0,\r\n\t\t\tgetAverageItemHeight: () => ITEM_HEIGHT,\r\n\t\t\tgetScrollableContainerHeight: () => scrollableContainer.height\r\n\t\t})\r\n\r\n\t\texpect(layout.getLayoutUpdateForItemsDiff(\r\n\t\t\t{\r\n\t\t\t\tfirstShownItemIndex: 3,\r\n\t\t\t\tlastShownItemIndex: 5,\r\n\t\t\t\tbeforeItemsHeight: 3 * (ITEM_HEIGHT + VERTICAL_SPACING),\r\n\t\t\t\tafterItemsHeight: 3 * (ITEM_HEIGHT + VERTICAL_SPACING)\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tprependedItemsCount: 5,\r\n\t\t\t\tappendedItemsCount: 5\r\n\t\t\t}, {\r\n\t\t\t\titemsCount: 5 + 5 + items.length,\r\n\t\t\t\tcolumnsCount: 1\r\n\t\t\t}\r\n\t\t)).to.deep.equal({\r\n\t\t\tfirstShownItemIndex: 5 + 3,\r\n\t\t\tlastShownItemIndex: 5 + 5,\r\n\t\t\tbeforeItemsHeight: (5 + 3) * (ITEM_HEIGHT + VERTICAL_SPACING),\r\n\t\t\tafterItemsHeight: (3 + 5) * (ITEM_HEIGHT + VERTICAL_SPACING)\r\n\t\t})\r\n\t})\r\n\r\n\tit('should update layout for items incremental change (rows get rebalanced)', function() {\r\n\t\tconst scrollableContainer = {\r\n\t\t\twidth: 800,\r\n\t\t\theight: 400\r\n\t\t}\r\n\t\tconst ITEM_WIDTH = scrollableContainer.width\r\n\t\tconst ITEM_HEIGHT = 400\r\n\r\n\t\tconst items = new Array(9).fill(ITEM_WIDTH * ITEM_HEIGHT)\r\n\r\n\t\tconst VERTICAL_SPACING = 100\r\n\r\n\t\tconst layout = new Layout({\r\n\t\t\tgetPrerenderMargin: () => scrollableContainer.height,\r\n\t\t\tgetVerticalSpacing: () => VERTICAL_SPACING,\r\n\t\t\tgetColumnsCount: () => 4,\r\n\t\t\tgetItemHeight: () => ITEM_HEIGHT,\r\n\t\t\tgetBeforeResizeItemsCount: () => 0,\r\n\t\t\tgetAverageItemHeight: () => ITEM_HEIGHT,\r\n\t\t\tgetScrollableContainerHeight: () => scrollableContainer.height\r\n\t\t})\r\n\r\n\t\tlet shouldResetGridLayout\r\n\r\n\t\t// Don't `throw` `VirtualScroller` errors but rather collect them in an array.\r\n\t\tconst errors = []\r\n\t\tglobal.VirtualScrollerCatchError = (error) => {\r\n\t\t\terrors.push(error)\r\n\t\t}\r\n\r\n\t\texpect(layout.getLayoutUpdateForItemsDiff(\r\n\t\t\t{\r\n\t\t\t\tfirstShownItemIndex: 3,\r\n\t\t\t\tlastShownItemIndex: 5,\r\n\t\t\t\tbeforeItemsHeight: 3 * (ITEM_HEIGHT + VERTICAL_SPACING),\r\n\t\t\t\tafterItemsHeight: 3 * (ITEM_HEIGHT + VERTICAL_SPACING)\r\n\t\t\t},\r\n\t\t\t{\r\n\t\t\t\tprependedItemsCount: 5,\r\n\t\t\t\tappendedItemsCount: 5\r\n\t\t\t}, {\r\n\t\t\t\titemsCount: 5 + 5 + items.length,\r\n\t\t\t\tcolumnsCount: 4,\r\n\t\t\t\tshouldRestoreScrollPosition: true,\r\n\t\t\t\tonResetGridLayout: () => shouldResetGridLayout = true\r\n\t\t\t}\r\n\t\t)).to.deep.equal({\r\n\t\t\tfirstShownItemIndex: 0,\r\n\t\t\tlastShownItemIndex: 5 + 5,\r\n\t\t\tbeforeItemsHeight: 0,\r\n\t\t\tafterItemsHeight: 5 * (ITEM_HEIGHT + VERTICAL_SPACING)\r\n\t\t})\r\n\r\n\t\t// Stop collecting `VirtualScroller` errors in the `errors` array.\r\n\t\t// Use the default behavior of just `throw`-ing such errors.\r\n\t\tglobal.VirtualScrollerCatchError = undefined\r\n\t\t// Verify the errors that have been `throw`-n.\r\n\t\texpect(errors.length).to.equal(2)\r\n\t\texpect(errors[0].message).to.equal('[virtual-scroller] ~ Prepended items count 5 is not divisible by Columns Count 4 ~')\r\n\t\texpect(errors[1].message).to.equal('[virtual-scroller] Layout reset required')\r\n\r\n\t\texpect(shouldResetGridLayout).to.equal(true)\r\n\t})\r\n})"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,EAAnB,QAA6B,OAA7B;AACA,SAASC,MAAT,QAAuB,MAAvB;AAEA,OAAOC,MAAP,MAAmB,aAAnB;AAEAH,QAAQ,CAAC,QAAD,EAAW,YAAW;EAC7BC,EAAE,CAAC,aAAD,EAAgB,YAAW;IAC5B,IAAMG,aAAa,GAAG,GAAtB;IAEA,IAAMC,mBAAmB,GAAG;MAC3BC,KAAK,EAAE,GADoB;MAE3BC,MAAM,EAAEH;IAFmB,CAA5B;IAKA,IAAMI,UAAU,GAAGH,mBAAmB,CAACC,KAAvC;IACA,IAAMG,WAAW,GAAG,GAApB;IAEA,IAAMC,gBAAgB,GAAG,GAAzB;IAEA,IAAMC,KAAK,GAAG,IAAIC,KAAJ,CAAU,CAAV,EAAaC,IAAb,CAAkBL,UAAU,GAAGC,WAA/B,CAAd;IAEA,IAAMK,MAAM,GAAG,IAAIX,MAAJ,CAAW;MACzBY,kBAAkB,EAAE;QAAA,OAAMX,aAAN;MAAA,CADK;MAEzBY,kBAAkB,EAAE;QAAA,OAAMN,gBAAN;MAAA,CAFK;MAGzBO,eAAe,EAAE;QAAA,OAAM,CAAN;MAAA,CAHQ;MAIzBC,aAAa,EAAE,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AAnB;IAJnB,CADM,EAON;MACC2B,mBAAmB,EAAE,CADtB;MAECC,kBAAkB,EAAE;IAFrB,CAPM,EAUH;MACFd,UAAU,EAAE,IAAI,CAAJ,GAAQb,KAAK,CAACc,MADxB;MAEFc,YAAY,EAAE,CAFZ;MAGFO,2BAA2B,EAAE,IAH3B;MAIFC,iBAAiB,EAAE;QAAA,OAAMP,qBAAqB,GAAG,IAA9B;MAAA;IAJjB,CAVG,CAAD,CAAN,CAgBGX,EAhBH,CAgBMC,IAhBN,CAgBWC,KAhBX,CAgBiB;MAChBC,mBAAmB,EAAE,CADL;MAEhBC,kBAAkB,EAAE,IAAI,CAFR;MAGhBE,iBAAiB,EAAE,CAHH;MAIhBC,gBAAgB,EAAE,KAAK3B,WAAW,GAAGC,gBAAnB;IAJF,CAhBjB,EA9BwF,CAqDxF;IACA;;IACAgC,MAAM,CAACC,yBAAP,GAAmCK,SAAnC,CAvDwF,CAwDxF;;IACA9C,MAAM,CAACuC,MAAM,CAAChB,MAAR,CAAN,CAAsBI,EAAtB,CAAyBE,KAAzB,CAA+B,CAA/B;IACA7B,MAAM,CAACuC,MAAM,CAAC,CAAD,CAAN,CAAUQ,OAAX,CAAN,CAA0BpB,EAA1B,CAA6BE,KAA7B,CAAmC,oFAAnC;IACA7B,MAAM,CAACuC,MAAM,CAAC,CAAD,CAAN,CAAUQ,OAAX,CAAN,CAA0BpB,EAA1B,CAA6BE,KAA7B,CAAmC,0CAAnC;IAEA7B,MAAM,CAACsC,qBAAD,CAAN,CAA8BX,EAA9B,CAAiCE,KAAjC,CAAuC,IAAvC;EACA,CA9DC,CAAF;AA+DA,CAnMO,CAAR"}
package/modules/Scroll.js CHANGED
@@ -30,7 +30,7 @@ var Scroll = /*#__PURE__*/function () {
30
30
  getListTopOffset = _ref.getListTopOffset,
31
31
  getPrerenderMargin = _ref.getPrerenderMargin,
32
32
  onScrolledToTop = _ref.onScrolledToTop,
33
- waitForScrollingToStop = _ref.waitForScrollingToStop;
33
+ delayUnnecessaryRerenderUntilStopsScrolling = _ref.delayUnnecessaryRerenderUntilStopsScrolling;
34
34
 
35
35
  _classCallCheck(this, Scroll);
36
36
 
@@ -92,21 +92,18 @@ var Scroll = /*#__PURE__*/function () {
92
92
  //
93
93
  _this.getScrollY() + _this.scrollableContainer.getHeight() > _this.getLatestLayoutVisibleArea().bottom + _this.getPrerenderMargin() && _this.hasNonRenderedItemsAtTheBottom());
94
94
 
95
- if (forceUpdate) {
95
+ if (forceUpdate || _this.delayUnnecessaryRerenderUntilStopsScrolling === false) {
96
96
  log('The user has scrolled far enough: perform a re-layout');
97
- } else {
98
- log('The user is scrolling: perform a re-layout when they stop scrolling');
99
- }
100
-
101
- if (forceUpdate || _this.waitForScrollingToStop === false) {
102
97
  return _this.onScroll();
103
- } // If a re-layout is already scheduled at the next "frame",
104
- // don't schedule a "re-layout when user stops scrolling" timer.
98
+ }
105
99
 
100
+ log('The user is scrolling: perform a re-layout when they stop scrolling'); // If a re-layout is already scheduled at the next "frame",
101
+ // don't schedule a timer to wait for the user to stop scrolling.
106
102
 
107
103
  if (_this.isImmediateLayoutScheduled()) {
108
104
  return;
109
- }
105
+ } // Schedule a timer to wait for the user to stop scrolling.
106
+
110
107
 
111
108
  _this.shouldCallOnScrollListenerWhenStopsScrolling = true;
112
109
 
@@ -126,7 +123,7 @@ var Scroll = /*#__PURE__*/function () {
126
123
  this.getListTopOffset = getListTopOffset;
127
124
  this.getPrerenderMargin = getPrerenderMargin;
128
125
  this.onScrolledToTop = onScrolledToTop;
129
- this.waitForScrollingToStop = waitForScrollingToStop;
126
+ this.delayUnnecessaryRerenderUntilStopsScrolling = delayUnnecessaryRerenderUntilStopsScrolling;
130
127
  }
131
128
 
132
129
  _createClass(Scroll, [{
@@ -1 +1 @@
1
- {"version":3,"file":"Scroll.js","names":["setTimeout","clearTimeout","log","Scroll","isInBypassMode","scrollableContainer","itemsContainer","onScroll","initialScrollPosition","onScrollPositionChange","isImmediateLayoutScheduled","hasNonRenderedItemsAtTheTop","hasNonRenderedItemsAtTheBottom","getLatestLayoutVisibleArea","getListTopOffset","getPrerenderMargin","onScrolledToTop","waitForScrollingToStop","scrollByY","scrollToY","getScrollY","ignoreScrollEvents","cancelOnStopScrollingTimer","forceUpdate","top","getHeight","bottom","shouldCallOnScrollListenerWhenStopsScrolling","watchOnStopScrolling","undefined","stopListeningToScroll","onScrollListener","scrollY","onStopScrollingTimer","delayed","ON_STOP_SCROLLING_INACTIVE_PERIOD"],"sources":["../source/Scroll.js"],"sourcesContent":["// For some weird reason, in Chrome, `setTimeout()` would lag up to a second (or more) behind.\r\n// Turns out, Chrome developers have deprecated `setTimeout()` API entirely without asking anyone.\r\n// Replacing `setTimeout()` with `requestAnimationFrame()` can work around that Chrome bug.\r\n// https://github.com/bvaughn/react-virtualized/issues/722\r\nimport { setTimeout, clearTimeout } from 'request-animation-frame-timeout'\r\n\r\nimport log from './utility/debug.js'\r\n\r\nexport default class Scroll {\r\n\tconstructor({\r\n\t\tisInBypassMode,\r\n\t\tscrollableContainer,\r\n\t\titemsContainer,\r\n\t\tonScroll,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\tisImmediateLayoutScheduled,\r\n\t\thasNonRenderedItemsAtTheTop,\r\n\t\thasNonRenderedItemsAtTheBottom,\r\n\t\tgetLatestLayoutVisibleArea,\r\n\t\tgetListTopOffset,\r\n\t\tgetPrerenderMargin,\r\n\t\tonScrolledToTop,\r\n\t\twaitForScrollingToStop\r\n\t}) {\r\n\t\tthis.isInBypassMode = isInBypassMode\r\n\t\tthis.scrollableContainer = scrollableContainer\r\n\t\tthis.itemsContainer = itemsContainer\r\n\t\tthis.onScroll = onScroll\r\n\t\tthis.initialScrollPosition = initialScrollPosition\r\n\t\tthis.onScrollPositionChange = onScrollPositionChange\r\n\t\tthis.isImmediateLayoutScheduled = isImmediateLayoutScheduled\r\n\t\tthis.hasNonRenderedItemsAtTheTop = hasNonRenderedItemsAtTheTop\r\n\t\tthis.hasNonRenderedItemsAtTheBottom = hasNonRenderedItemsAtTheBottom\r\n\t\tthis.getLatestLayoutVisibleArea = getLatestLayoutVisibleArea\r\n\t\tthis.getListTopOffset = getListTopOffset\r\n\t\tthis.getPrerenderMargin = getPrerenderMargin\r\n\t\tthis.onScrolledToTop = onScrolledToTop\r\n\t\tthis.waitForScrollingToStop = waitForScrollingToStop\r\n\t}\r\n\r\n\tstart() {\r\n\t\tif (this.initialScrollPosition !== undefined) {\r\n\t\t\tthis.scrollToY(this.initialScrollPosition)\r\n\t\t\t// Don't restore this scroll position on restart.\r\n\t\t\tthis.initialScrollPosition = undefined\r\n\t\t}\r\n\t\tif (this.onScrollPositionChange) {\r\n\t\t\tthis.onScrollPositionChange(this.getScrollY())\r\n\t\t}\r\n\t\tthis.stopListeningToScroll = this.scrollableContainer.onScroll(this.onScrollListener)\r\n\t}\r\n\r\n\tstop() {\r\n\t\tthis.stopListeningToScroll()\r\n\t\tthis.stopListeningToScroll = undefined\r\n\t\t// this.onStopScrollingListener = undefined\r\n\t\tthis.shouldCallOnScrollListenerWhenStopsScrolling = undefined\r\n\t\tthis.cancelOnStopScrollingTimer()\r\n\t}\r\n\r\n\tscrollToY(scrollY) {\r\n\t\tthis.ignoreScrollEvents = true\r\n\t\tthis.scrollableContainer.scrollToY(scrollY)\r\n\t\tthis.ignoreScrollEvents = undefined\r\n\t}\r\n\r\n\tscrollByY = (scrollByY) => {\r\n\t\tthis.scrollToY(this.getScrollY() + scrollByY)\r\n\t}\r\n\r\n\tgetScrollY() {\r\n\t\treturn this.scrollableContainer.getScrollY()\r\n\t}\r\n\r\n\tcancelOnStopScrollingTimer() {\r\n\t\tif (this.onStopScrollingTimer) {\r\n\t\t\tclearTimeout(this.onStopScrollingTimer)\r\n\t\t\tthis.onStopScrollingTimer = undefined\r\n\t\t}\r\n\t}\r\n\r\n\tcancelScheduledLayout() {\r\n\t\t// Cancel a \"re-layout when user stops scrolling\" timer.\r\n\t\tthis.cancelOnStopScrollingTimer()\r\n\t}\r\n\r\n\tonScrollListener = () => {\r\n\t\tif (this.onScrollPositionChange) {\r\n\t\t\tthis.onScrollPositionChange(this.getScrollY())\r\n\t\t}\r\n\r\n\t\t// If the user has scrolled up to the top of the items container.\r\n\t\t// (this option isn't currently used)\r\n\t\tif (this.onScrolledToTop) {\r\n\t\t\tif (this.getScrollY() < this.getListTopOffset()) {\r\n\t\t\t\tthis.onScrolledToTop()\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (this.isInBypassMode()) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (this.ignoreScrollEvents) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// Prefer not performing a re-layout while the user is scrolling (if possible).\r\n\t\t// If the user doesn't scroll too far and then stops for a moment,\r\n\t\t// then a mid-scroll re-layout could be delayed until such a brief stop:\r\n\t\t// presumably, this results in better (smoother) scrolling performance,\r\n\t\t// delaying the work to when it doesn't introduce any stutter or \"jank\".\r\n\r\n\t\t// Reset `this.onStopScrollingTimer` (will be re-created below).\r\n\t\tthis.cancelOnStopScrollingTimer()\r\n\r\n\t\t// See if the latest \"layout\" (the currently rendered set of items)\r\n\t\t// is still sufficient in order to show all the items that're\r\n\t\t// currently inside the viewport. If there're some non-rendered items\r\n\t\t// that're visible in the current viewport, then those items\r\n\t\t// should be rendered \"immediately\" rather than waiting until\r\n\t\t// the user stops scrolling.\r\n\t\tconst forceUpdate =\r\n\t\t\t// If the items have been rendered at least once\r\n\t\t\tthis.getLatestLayoutVisibleArea() && (\r\n\t\t\t\t(\r\n\t\t\t\t\t// If the user has scrolled up past the \"prerender margin\"\r\n\t\t\t\t\t// and there're some non-rendered items at the top,\r\n\t\t\t\t\t// then force a re-layout.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// (during these calculations we assume that the list's top coordinate\r\n\t\t\t\t\t// hasn't changed since previous layout; even if that's not exactly true,\r\n\t\t\t\t\t// the items will be re-layout when the user stops scrolling anyway)\r\n\t\t\t\t\t//\r\n\t\t\t\t\t(this.getScrollY() < this.getLatestLayoutVisibleArea().top - this.getPrerenderMargin()) &&\r\n\t\t\t\t\tthis.hasNonRenderedItemsAtTheTop()\r\n\t\t\t\t)\r\n\t\t\t\t||\r\n\t\t\t\t(\r\n\t\t\t\t\t// If the user has scrolled down past the \"prerender margin\"\r\n\t\t\t\t\t// and there're any non-rendered items left at the end,\r\n\t\t\t\t\t// then force a re-layout.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// (during these calculations we assume that the list's top coordinate\r\n\t\t\t\t\t// hasn't changed since previous layout; even if that's not exactly true,\r\n\t\t\t\t\t// the items will be re-layout when the user stops scrolling anyway)\r\n\t\t\t\t\t//\r\n\t\t\t\t\t(this.getScrollY() + this.scrollableContainer.getHeight() > this.getLatestLayoutVisibleArea().bottom + this.getPrerenderMargin()) &&\r\n\t\t\t\t\tthis.hasNonRenderedItemsAtTheBottom()\r\n\t\t\t\t)\r\n\t\t\t)\r\n\r\n\t\tif (forceUpdate) {\r\n\t\t\tlog('The user has scrolled far enough: perform a re-layout')\r\n\t\t} else {\r\n\t\t\tlog('The user is scrolling: perform a re-layout when they stop scrolling')\r\n\t\t}\r\n\r\n\t\tif (forceUpdate || this.waitForScrollingToStop === false) {\r\n\t\t\treturn this.onScroll()\r\n\t\t}\r\n\r\n\t\t// If a re-layout is already scheduled at the next \"frame\",\r\n\t\t// don't schedule a \"re-layout when user stops scrolling\" timer.\r\n\t\tif (this.isImmediateLayoutScheduled()) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tthis.shouldCallOnScrollListenerWhenStopsScrolling = true\r\n\t\tthis.watchOnStopScrolling()\r\n\t}\r\n\r\n\twatchOnStopScrolling() {\r\n\t\tthis.onStopScrollingTimer = setTimeout(\r\n\t\t\t() => {\r\n\t\t\t\tthis.onStopScrollingTimer = undefined\r\n\r\n\t\t\t\tif (this.shouldCallOnScrollListenerWhenStopsScrolling) {\r\n\t\t\t\t\tthis.shouldCallOnScrollListenerWhenStopsScrolling = undefined\r\n\t\t\t\t\tthis.onScroll({ delayed: true })\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// `onStopScrolling()` feature is not currently used.\r\n\t\t\t\t// if (this.onStopScrollingListener) {\r\n\t\t\t\t// \tconst onStopScrollingListener = this.onStopScrollingListener\r\n\t\t\t\t// \tthis.onStopScrollingListener = undefined\r\n\t\t\t\t// \t// `onStopScrollingListener()` may hypothetically schedule\r\n\t\t\t\t// \t// another `onStopScrolling()` listener, so set\r\n\t\t\t\t// \t// `this.onStopScrollingListener` to `undefined` before\r\n\t\t\t\t// \t// calling it rather than after.\r\n\t\t\t\t// \tlog('~ The user has stopped scrolling ~')\r\n\t\t\t\t// \tonStopScrollingListener()\r\n\t\t\t\t// }\r\n\t\t\t},\r\n\t\t\t// \"scroll\" events are usually dispatched every 16 milliseconds\r\n\t\t\t// for 60fps refresh rate, so waiting for 100 milliseconds feels\r\n\t\t\t// reasonable: that would be about 6 frames of inactivity period,\r\n\t\t\t// which could mean that either the user has stopped scrolling\r\n\t\t\t// (for a moment) or the browser is lagging and stuttering\r\n\t\t\t// (skipping frames due to high load).\r\n\t\t\t// If the user continues scrolling then this timeout is constantly\r\n\t\t\t// refreshed (cancelled and then re-created).\r\n\t\t\tON_STOP_SCROLLING_INACTIVE_PERIOD\r\n\t\t)\r\n\t}\r\n\r\n\t// (this function isn't currently used)\r\n\t// onStopScrolling(onStopScrollingListener) {\r\n\t// \tthis.onStopScrollingListener = onStopScrollingListener\r\n\t// \tif (!this.onStopScrollingTimer) {\r\n\t// \t\tthis.watchOnStopScrolling()\r\n\t// \t}\r\n\t// }\r\n\r\n\t/**\r\n\t * Returns visible area coordinates relative to the scrollable container.\r\n\t * @return {object} `{ top: number, bottom: number }`\r\n\t */\r\n\tgetVisibleAreaBounds() {\r\n\t\tconst scrollY = this.getScrollY()\r\n\t\treturn {\r\n\t\t\t// The first pixel of the screen.\r\n\t\t\ttop: scrollY,\r\n\t\t\t// The pixel after the last pixel of the screen.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B;;QAEA,IAAI,MAAI,CAACF,4CAAT,EAAuD;UACtD,MAAI,CAACA,4CAAL,GAAoDE,SAApD;;UACA,MAAI,CAACtB,QAAL,CAAc;YAAE2B,OAAO,EAAE;UAAX,CAAd;QACA,CANI,CAQL;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;MACA,CApBoC,EAqBrC;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACAC,iCA7BqC,CAAtC;IA+BA,C,CAED;IACA;IACA;IACA;IACA;IACA;IACA;;IAEA;AACD;AACA;AACA;;;;WACC,gCAAuB;MACtB,IAAMH,OAAO,GAAG,KAAKZ,UAAL,EAAhB;MACA,OAAO;QACN;QACAI,GAAG,EAAEQ,OAFC;QAGN;QACAN,MAAM,EAAEM,OAAO,GAAG,KAAK3B,mBAAL,CAAyBoB,SAAzB;MAJZ,CAAP;IAMA;;;;;;SA3NmBtB,M;AA8NrB,IAAMgC,iCAAiC,GAAG,GAA1C"}
1
+ {"version":3,"file":"Scroll.js","names":["setTimeout","clearTimeout","log","Scroll","isInBypassMode","scrollableContainer","itemsContainer","onScroll","initialScrollPosition","onScrollPositionChange","isImmediateLayoutScheduled","hasNonRenderedItemsAtTheTop","hasNonRenderedItemsAtTheBottom","getLatestLayoutVisibleArea","getListTopOffset","getPrerenderMargin","onScrolledToTop","delayUnnecessaryRerenderUntilStopsScrolling","scrollByY","scrollToY","getScrollY","ignoreScrollEvents","cancelOnStopScrollingTimer","forceUpdate","top","getHeight","bottom","shouldCallOnScrollListenerWhenStopsScrolling","watchOnStopScrolling","undefined","stopListeningToScroll","onScrollListener","scrollY","onStopScrollingTimer","delayed","ON_STOP_SCROLLING_INACTIVE_PERIOD"],"sources":["../source/Scroll.js"],"sourcesContent":["// For some weird reason, in Chrome, `setTimeout()` would lag up to a second (or more) behind.\r\n// Turns out, Chrome developers have deprecated `setTimeout()` API entirely without asking anyone.\r\n// Replacing `setTimeout()` with `requestAnimationFrame()` can work around that Chrome bug.\r\n// https://github.com/bvaughn/react-virtualized/issues/722\r\nimport { setTimeout, clearTimeout } from 'request-animation-frame-timeout'\r\n\r\nimport log from './utility/debug.js'\r\n\r\nexport default class Scroll {\r\n\tconstructor({\r\n\t\tisInBypassMode,\r\n\t\tscrollableContainer,\r\n\t\titemsContainer,\r\n\t\tonScroll,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\tisImmediateLayoutScheduled,\r\n\t\thasNonRenderedItemsAtTheTop,\r\n\t\thasNonRenderedItemsAtTheBottom,\r\n\t\tgetLatestLayoutVisibleArea,\r\n\t\tgetListTopOffset,\r\n\t\tgetPrerenderMargin,\r\n\t\tonScrolledToTop,\r\n\t\tdelayUnnecessaryRerenderUntilStopsScrolling\r\n\t}) {\r\n\t\tthis.isInBypassMode = isInBypassMode\r\n\t\tthis.scrollableContainer = scrollableContainer\r\n\t\tthis.itemsContainer = itemsContainer\r\n\t\tthis.onScroll = onScroll\r\n\t\tthis.initialScrollPosition = initialScrollPosition\r\n\t\tthis.onScrollPositionChange = onScrollPositionChange\r\n\t\tthis.isImmediateLayoutScheduled = isImmediateLayoutScheduled\r\n\t\tthis.hasNonRenderedItemsAtTheTop = hasNonRenderedItemsAtTheTop\r\n\t\tthis.hasNonRenderedItemsAtTheBottom = hasNonRenderedItemsAtTheBottom\r\n\t\tthis.getLatestLayoutVisibleArea = getLatestLayoutVisibleArea\r\n\t\tthis.getListTopOffset = getListTopOffset\r\n\t\tthis.getPrerenderMargin = getPrerenderMargin\r\n\t\tthis.onScrolledToTop = onScrolledToTop\r\n\t\tthis.delayUnnecessaryRerenderUntilStopsScrolling = delayUnnecessaryRerenderUntilStopsScrolling\r\n\t}\r\n\r\n\tstart() {\r\n\t\tif (this.initialScrollPosition !== undefined) {\r\n\t\t\tthis.scrollToY(this.initialScrollPosition)\r\n\t\t\t// Don't restore this scroll position on restart.\r\n\t\t\tthis.initialScrollPosition = undefined\r\n\t\t}\r\n\t\tif (this.onScrollPositionChange) {\r\n\t\t\tthis.onScrollPositionChange(this.getScrollY())\r\n\t\t}\r\n\t\tthis.stopListeningToScroll = this.scrollableContainer.onScroll(this.onScrollListener)\r\n\t}\r\n\r\n\tstop() {\r\n\t\tthis.stopListeningToScroll()\r\n\t\tthis.stopListeningToScroll = undefined\r\n\t\t// this.onStopScrollingListener = undefined\r\n\t\tthis.shouldCallOnScrollListenerWhenStopsScrolling = undefined\r\n\t\tthis.cancelOnStopScrollingTimer()\r\n\t}\r\n\r\n\tscrollToY(scrollY) {\r\n\t\tthis.ignoreScrollEvents = true\r\n\t\tthis.scrollableContainer.scrollToY(scrollY)\r\n\t\tthis.ignoreScrollEvents = undefined\r\n\t}\r\n\r\n\tscrollByY = (scrollByY) => {\r\n\t\tthis.scrollToY(this.getScrollY() + scrollByY)\r\n\t}\r\n\r\n\tgetScrollY() {\r\n\t\treturn this.scrollableContainer.getScrollY()\r\n\t}\r\n\r\n\tcancelOnStopScrollingTimer() {\r\n\t\tif (this.onStopScrollingTimer) {\r\n\t\t\tclearTimeout(this.onStopScrollingTimer)\r\n\t\t\tthis.onStopScrollingTimer = undefined\r\n\t\t}\r\n\t}\r\n\r\n\tcancelScheduledLayout() {\r\n\t\t// Cancel a \"re-layout when user stops scrolling\" timer.\r\n\t\tthis.cancelOnStopScrollingTimer()\r\n\t}\r\n\r\n\tonScrollListener = () => {\r\n\t\tif (this.onScrollPositionChange) {\r\n\t\t\tthis.onScrollPositionChange(this.getScrollY())\r\n\t\t}\r\n\r\n\t\t// If the user has scrolled up to the top of the items container.\r\n\t\t// (this option isn't currently used)\r\n\t\tif (this.onScrolledToTop) {\r\n\t\t\tif (this.getScrollY() < this.getListTopOffset()) {\r\n\t\t\t\tthis.onScrolledToTop()\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (this.isInBypassMode()) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (this.ignoreScrollEvents) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// Prefer not performing a re-layout while the user is scrolling (if possible).\r\n\t\t// If the user doesn't scroll too far and then stops for a moment,\r\n\t\t// then a mid-scroll re-layout could be delayed until such a brief stop:\r\n\t\t// presumably, this results in better (smoother) scrolling performance,\r\n\t\t// delaying the work to when it doesn't introduce any stutter or \"jank\".\r\n\r\n\t\t// Reset `this.onStopScrollingTimer` (will be re-created below).\r\n\t\tthis.cancelOnStopScrollingTimer()\r\n\r\n\t\t// See if the latest \"layout\" (the currently rendered set of items)\r\n\t\t// is still sufficient in order to show all the items that're\r\n\t\t// currently inside the viewport. If there're some non-rendered items\r\n\t\t// that're visible in the current viewport, then those items\r\n\t\t// should be rendered \"immediately\" rather than waiting until\r\n\t\t// the user stops scrolling.\r\n\t\tconst forceUpdate =\r\n\t\t\t// If the items have been rendered at least once\r\n\t\t\tthis.getLatestLayoutVisibleArea() && (\r\n\t\t\t\t(\r\n\t\t\t\t\t// If the user has scrolled up past the \"prerender margin\"\r\n\t\t\t\t\t// and there're some non-rendered items at the top,\r\n\t\t\t\t\t// then force a re-layout.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// (during these calculations we assume that the list's top coordinate\r\n\t\t\t\t\t// hasn't changed since previous layout; even if that's not exactly true,\r\n\t\t\t\t\t// the items will be re-layout when the user stops scrolling anyway)\r\n\t\t\t\t\t//\r\n\t\t\t\t\t(this.getScrollY() < this.getLatestLayoutVisibleArea().top - this.getPrerenderMargin()) &&\r\n\t\t\t\t\tthis.hasNonRenderedItemsAtTheTop()\r\n\t\t\t\t)\r\n\t\t\t\t||\r\n\t\t\t\t(\r\n\t\t\t\t\t// If the user has scrolled down past the \"prerender margin\"\r\n\t\t\t\t\t// and there're any non-rendered items left at the end,\r\n\t\t\t\t\t// then force a re-layout.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// (during these calculations we assume that the list's top coordinate\r\n\t\t\t\t\t// hasn't changed since previous layout; even if that's not exactly true,\r\n\t\t\t\t\t// the items will be re-layout when the user stops scrolling anyway)\r\n\t\t\t\t\t//\r\n\t\t\t\t\t(this.getScrollY() + this.scrollableContainer.getHeight() > this.getLatestLayoutVisibleArea().bottom + this.getPrerenderMargin()) &&\r\n\t\t\t\t\tthis.hasNonRenderedItemsAtTheBottom()\r\n\t\t\t\t)\r\n\t\t\t)\r\n\r\n\t\tif (forceUpdate || this.delayUnnecessaryRerenderUntilStopsScrolling === false) {\r\n\t\t\tlog('The user has scrolled far enough: perform a re-layout')\r\n\t\t\treturn this.onScroll()\r\n\t\t}\r\n\r\n\t\tlog('The user is scrolling: perform a re-layout when they stop scrolling')\r\n\r\n\t\t// If a re-layout is already scheduled at the next \"frame\",\r\n\t\t// don't schedule a timer to wait for the user to stop scrolling.\r\n\t\tif (this.isImmediateLayoutScheduled()) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\t// Schedule a timer to wait for the user to stop scrolling.\r\n\t\tthis.shouldCallOnScrollListenerWhenStopsScrolling = true\r\n\t\tthis.watchOnStopScrolling()\r\n\t}\r\n\r\n\twatchOnStopScrolling() {\r\n\t\tthis.onStopScrollingTimer = setTimeout(\r\n\t\t\t() => {\r\n\t\t\t\tthis.onStopScrollingTimer = undefined\r\n\r\n\t\t\t\tif (this.shouldCallOnScrollListenerWhenStopsScrolling) {\r\n\t\t\t\t\tthis.shouldCallOnScrollListenerWhenStopsScrolling = undefined\r\n\t\t\t\t\tthis.onScroll({ delayed: true })\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// `onStopScrolling()` feature is not currently used.\r\n\t\t\t\t// if (this.onStopScrollingListener) {\r\n\t\t\t\t// \tconst onStopScrollingListener = this.onStopScrollingListener\r\n\t\t\t\t// \tthis.onStopScrollingListener = undefined\r\n\t\t\t\t// \t// `onStopScrollingListener()` may hypothetically schedule\r\n\t\t\t\t// \t// another `onStopScrolling()` listener, so set\r\n\t\t\t\t// \t// `this.onStopScrollingListener` to `undefined` before\r\n\t\t\t\t// \t// calling it rather than after.\r\n\t\t\t\t// \tlog('~ The user has stopped scrolling ~')\r\n\t\t\t\t// \tonStopScrollingListener()\r\n\t\t\t\t// }\r\n\t\t\t},\r\n\t\t\t// \"scroll\" events are usually dispatched every 16 milliseconds\r\n\t\t\t// for 60fps refresh rate, so waiting for 100 milliseconds feels\r\n\t\t\t// reasonable: that would be about 6 frames of inactivity period,\r\n\t\t\t// which could mean that either the user has stopped scrolling\r\n\t\t\t// (for a moment) or the browser is lagging and stuttering\r\n\t\t\t// (skipping frames due to high load).\r\n\t\t\t// If the user continues scrolling then this timeout is constantly\r\n\t\t\t// refreshed (cancelled and then re-created).\r\n\t\t\tON_STOP_SCROLLING_INACTIVE_PERIOD\r\n\t\t)\r\n\t}\r\n\r\n\t// (this function isn't currently used)\r\n\t// onStopScrolling(onStopScrollingListener) {\r\n\t// \tthis.onStopScrollingListener = onStopScrollingListener\r\n\t// \tif (!this.onStopScrollingTimer) {\r\n\t// \t\tthis.watchOnStopScrolling()\r\n\t// \t}\r\n\t// }\r\n\r\n\t/**\r\n\t * Returns visible area coordinates relative to the scrollable container.\r\n\t * @return {object} `{ top: number, bottom: number }`\r\n\t */\r\n\tgetVisibleAreaBounds() {\r\n\t\tconst scrollY = this.getScrollY()\r\n\t\treturn {\r\n\t\t\t// The first pixel of the screen.\r\n\t\t\ttop: scrollY,\r\n\t\t\t// The pixel after the last pixel of the screen.\r\n\t\t\tbottom: scrollY + this.scrollableContainer.getHeight()\r\n\t\t}\r\n\t}\r\n}\r\n\r\nconst ON_STOP_SCROLLING_INACTIVE_PERIOD = 100"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,YAArB,QAAyC,iCAAzC;AAEA,OAAOC,GAAP,MAAgB,oBAAhB;;IAEqBC,M;EACpB,sBAeG;IAAA;;IAAA,IAdFC,cAcE,QAdFA,cAcE;IAAA,IAbFC,mBAaE,QAbFA,mBAaE;IAAA,IAZFC,cAYE,QAZFA,cAYE;IAAA,IAXFC,QAWE,QAXFA,QAWE;IAAA,IAVFC,qBAUE,QAVF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FC;QAGN;QACAN,MAAM,EAAEM,OAAO,GAAG,KAAK3B,mBAAL,CAAyBoB,SAAzB;MAJZ,CAAP;IAMA;;;;;;SAzNmBtB,M;AA4NrB,IAAMgC,iCAAiC,GAAG,GAA1C"}
@@ -43,8 +43,8 @@ export default function VirtualScrollerConstructor(getItemsContainerElement, ite
43
43
  getEstimatedInterItemVerticalSpacing = options.getEstimatedInterItemVerticalSpacing,
44
44
  onItemInitialRender = options.onItemInitialRender,
45
45
  onItemFirstRender = options.onItemFirstRender,
46
- _useTimeoutInRenderLoop = options._useTimeoutInRenderLoop,
47
- _waitForScrollingToStop = options._waitForScrollingToStop,
46
+ delayRecursiveRenderUntilNextTick = options.delayRecursiveRenderUntilNextTick,
47
+ _delayUnnecessaryRerenderUntilStopsScrolling = options._delayUnnecessaryRerenderUntilStopsScrolling,
48
48
  engine = options.engine;
49
49
  var getEstimatedItemHeight = options.getEstimatedItemHeight,
50
50
  getScrollableContainer = options.getScrollableContainer;
@@ -127,7 +127,7 @@ export default function VirtualScrollerConstructor(getItemsContainerElement, ite
127
127
  // `.setState()` inside `componentWillUpdate()` or `componentDidUpdate()`.
128
128
  // React limits the number of nested updates to prevent infinite loops."
129
129
 
130
- this._useTimeoutInRenderLoop = _useTimeoutInRenderLoop; // `_getItemId()` function is used in `_getItemIndexByItemOrIndex()` function.
130
+ this._delayRecursiveRenderUntilNextTick = delayRecursiveRenderUntilNextTick; // `_getItemId()` function is used in `_getItemIndexByItemOrIndex()` function.
131
131
 
132
132
  this._getItemId = getItemId;
133
133
 
@@ -204,7 +204,7 @@ export default function VirtualScrollerConstructor(getItemsContainerElement, ite
204
204
  measureItemsBatchSize: measureItemsBatchSize,
205
205
  initialScrollPosition: initialScrollPosition,
206
206
  onScrollPositionChange: onScrollPositionChange,
207
- waitForScrollingToStop: _waitForScrollingToStop
207
+ delayUnnecessaryRerenderUntilStopsScrolling: _delayUnnecessaryRerenderUntilStopsScrolling
208
208
  });
209
209
 
210
210
  if (state) {
@@ -224,7 +224,7 @@ function createHelpers(_ref) {
224
224
  measureItemsBatchSize = _ref.measureItemsBatchSize,
225
225
  initialScrollPosition = _ref.initialScrollPosition,
226
226
  onScrollPositionChange = _ref.onScrollPositionChange,
227
- waitForScrollingToStop = _ref.waitForScrollingToStop;
227
+ delayUnnecessaryRerenderUntilStopsScrolling = _ref.delayUnnecessaryRerenderUntilStopsScrolling;
228
228
  this.itemsContainer = this.engine.createItemsContainer(this.getItemsContainerElement);
229
229
 
230
230
  this.isItemsContainerElementTableBody = function () {
@@ -365,7 +365,7 @@ function createHelpers(_ref) {
365
365
  isInBypassMode: this.isInBypassMode,
366
366
  scrollableContainer: this.scrollableContainer,
367
367
  itemsContainer: this.itemsContainer,
368
- waitForScrollingToStop: waitForScrollingToStop,
368
+ delayUnnecessaryRerenderUntilStopsScrolling: delayUnnecessaryRerenderUntilStopsScrolling,
369
369
  onScroll: function onScroll() {
370
370
  var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
371
371
  delayed = _ref2.delayed;
@@ -401,8 +401,7 @@ function createHelpers(_ref) {
401
401
  if (this.engine.watchListTopOffset) {
402
402
  this.listTopOffsetWatcher = this.engine.watchListTopOffset({
403
403
  getListTopOffset: this.getListTopOffsetInsideScrollableContainer,
404
- onListTopOffsetChange: function onListTopOffsetChange(_ref3) {
405
- var reason = _ref3.reason;
404
+ onListTopOffsetChange: function onListTopOffsetChange() {
406
405
  return _this2.onUpdateShownItemIndexes({
407
406
  reason: LAYOUT_REASON.TOP_OFFSET_CHANGED
408
407
  });
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualScroller.constructor.js","names":["DOMEngine","Layout","LAYOUT_REASON","DEFAULT_ITEM_HEIGHT","ScrollableContainerResizeHandler","BeforeResize","Scroll","ListHeightMeasurement","ItemHeights","log","warn","createStateHelpers","createVerticalSpacingHelpers","createColumnsHelpers","createLayoutHelpers","createOnRenderHelpers","createScrollableContainerResizeHelpers","createItemsHelpers","VirtualScrollerConstructor","getItemsContainerElement","items","options","bypass","render","state","getInitialItemState","onStateChange","initialScrollPosition","onScrollPositionChange","scrollableContainer","measureItemsBatchSize","getColumnsCount","getItemId","estimatedItemHeight","getEstimatedVisibleItemRowsCount","getEstimatedInterItemVerticalSpacing","onItemInitialRender","onItemFirstRender","_useTimeoutInRenderLoop","_waitForScrollingToStop","engine","getEstimatedItemHeight","getScrollableContainer","element","Error","getState","setState","_bypass","_getItemId","isItemEqual","a","b","item","i","indexOf","length","call","createHelpers","waitForScrollingToStop","itemHeights","readItemHeightsFromState","beforeResize","initializeFromState","itemsContainer","createItemsContainer","isItemsContainerElementTableBody","tagName","isInBypassMode","createScrollableContainer","container","getItemHeight","setItemHeight","height","getAverageItemHeight","averageItemHeight","layout","getEstimatedVisibleItemRowsCountForInitialRender","getPrerenderMargin","getPrerenderMarginRatio","getVerticalSpacing","getVerticalSpacingBeforeResize","getColumnsCountBeforeResize","columnsCount","getItemHeightBeforeResize","getBeforeResizeItemsCount","getMaxVisibleAreaHeight","getHeight","getPreviouslyCalculatedLayout","previouslyCalculatedLayout","scrollableContainerResizeHandler","getWidth","listenForResize","listener","onResize","onResizeStart","_isResizing","onResizeStop","undefined","onNoChange","onUpdateShownItemIndexes","reason","VIEWPORT_SIZE_UNCHANGED","onHeightChange","VIEWPORT_HEIGHT_CHANGED","onWidthChange","prevWidth","newWidth","onContainerResize","scroll","onScroll","delayed","STOPPED_SCROLLING","SCROLL","isImmediateLayoutScheduled","Boolean","layoutTimer","hasNonRenderedItemsAtTheTop","firstShownItemIndex","hasNonRenderedItemsAtTheBottom","lastShownItemIndex","getItemsCount","getLatestLayoutVisibleArea","latestLayoutVisibleArea","getListTopOffset","getListTopOffsetInsideScrollableContainer","listHeightMeasurement","watchListTopOffset","listTopOffsetWatcher","onListTopOffsetChange","TOP_OFFSET_CHANGED"],"sources":["../source/VirtualScroller.constructor.js"],"sourcesContent":["import DOMEngine from './DOM/Engine.js'\r\n\r\nimport Layout, { LAYOUT_REASON } from './Layout.js'\r\nimport { DEFAULT_ITEM_HEIGHT } from './Layout.defaults.js'\r\nimport ScrollableContainerResizeHandler from './ScrollableContainerResizeHandler.js'\r\nimport BeforeResize from './BeforeResize.js'\r\nimport Scroll from './Scroll.js'\r\nimport ListHeightMeasurement from './ListHeightMeasurement.js'\r\nimport ItemHeights from './ItemHeights.js'\r\n\r\nimport log, { warn } from './utility/debug.js'\r\n\r\nimport createStateHelpers from './VirtualScroller.state.js'\r\nimport createVerticalSpacingHelpers from './VirtualScroller.verticalSpacing.js'\r\nimport createColumnsHelpers from './VirtualScroller.columns.js'\r\nimport createLayoutHelpers from './VirtualScroller.layout.js'\r\nimport createOnRenderHelpers from './VirtualScroller.onRender.js'\r\nimport createScrollableContainerResizeHelpers from './VirtualScroller.onContainerResize.js'\r\nimport createItemsHelpers from './VirtualScroller.items.js'\r\n\r\n/**\r\n * @param {function} getItemsContainerElement — Returns the container DOM `Element` (or `null`).\r\n * @param {any[]} items — The list of items.\r\n * @param {Object} [options] — See README.md.\r\n * @return {VirtualScroller}\r\n */\r\nexport default function VirtualScrollerConstructor(\r\n\tgetItemsContainerElement,\r\n\titems,\r\n\toptions = {}\r\n) {\r\n\tconst {\r\n\t\tbypass,\r\n\t\trender,\r\n\t\tstate,\r\n\t\tgetInitialItemState = () => {},\r\n\t\tonStateChange,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\t// `scrollableContainer` option is deprecated.\r\n\t\t// Use `getScrollableContainer()` option instead.\r\n\t\tscrollableContainer,\r\n\t\tmeasureItemsBatchSize = 50,\r\n\t\tgetColumnsCount,\r\n\t\tgetItemId,\r\n\t\t// `estimatedItemHeight` is deprecated, use `getEstimatedItemHeight()` instead.\r\n\t\testimatedItemHeight,\r\n\t\tgetEstimatedVisibleItemRowsCount,\r\n\t\tgetEstimatedInterItemVerticalSpacing,\r\n\t\tonItemInitialRender,\r\n\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\tonItemFirstRender,\r\n\t\t_useTimeoutInRenderLoop,\r\n\t\t_waitForScrollingToStop,\r\n\t\tengine\r\n\t} = options\r\n\r\n\tlet {\r\n\t\tgetEstimatedItemHeight,\r\n\t\tgetScrollableContainer\r\n\t} = options\r\n\r\n\tlog('~ Initialize ~')\r\n\r\n\t// Could support non-DOM rendering engines.\r\n\t// For example, React Native, `<canvas/>`, etc.\r\n\tthis.engine = engine || DOMEngine\r\n\r\n\tif (!getEstimatedItemHeight && typeof estimatedItemHeight === 'number') {\r\n\t\tgetEstimatedItemHeight = () => estimatedItemHeight\r\n\t}\r\n\r\n\t// `scrollableContainer` option is deprecated.\r\n\t// Use `getScrollableContainer()` option instead.\r\n\tif (!getScrollableContainer && scrollableContainer) {\r\n\t\tgetScrollableContainer = () => scrollableContainer\r\n\t}\r\n\r\n\t// Sometimes, when `new VirtualScroller()` \"core\" instance is created,\r\n\t// `getItemsContainerElement()` function might not yet be ready to return the \"container\" DOM Element.\r\n\t// For example, because the \"container\" DOM Element not rendered yet.\r\n\t// That's the reason why it's a getter function rather than a simple variable.\r\n\t//\r\n\t// As an example, in React `<VirtualScroller/>` component, a \"core\" `VirtualScroller`\r\n\t// instance is created in the React component's `constructor()`, and at that time\r\n\t// the \"container\" DOM Element has not been rendered yet.\r\n\t// The \"container\" DOM Element is only guaranteed to have been rendered\r\n\t// by the time `useEffect()` callback function is called, but at the same time `useEffect()`\r\n\t// is only executed on client side and is not executed on server side at all.\r\n\t// Still, the code has to work both in a web browser and on the server during the initial\r\n\t// \"server-side render\", i.e. it still must render the list during the initial\r\n\t// \"server-side render\". So `VirtualScroller` can't simply be skipped during server-side render.\r\n\t// It has to render something, and that something has to be correct.\r\n\t// This means that the \"core\" `VirtualScroller` should at least correctly compute the state\r\n\t// regardless of whether the `itemsContainerElement` exists or not.\r\n\t//\r\n\tthis.getItemsContainerElement = () => {\r\n\t\tconst element = getItemsContainerElement()\r\n\t\tif (element === null) {\r\n\t\t\tthrow new Error('[virtual-scroller] Items container element is `null`')\r\n\t\t}\r\n\t\treturn element\r\n\t}\r\n\r\n\t// if (prerenderMargin === undefined) {\r\n\t// \t// Renders items which are outside of the screen by this \"prerender margin\".\r\n\t// \t// Is the screen height by default: seems to be the optimal value\r\n\t// \t// for \"Page Up\" / \"Page Down\" navigation and optimized mouse wheel scrolling.\r\n\t// \tprerenderMargin = this.scrollableContainer ? this.scrollableContainer.getHeight() : 0\r\n\t// }\r\n\r\n\tif (options.getState || options.setState) {\r\n\t\tthrow new Error('[virtual-scroller] `getState`/`setState` options usage has changed in the new version. See the readme for more details.')\r\n\t}\r\n\r\n\tif (bypass) {\r\n\t\tlog('~ \"bypass\" mode ~')\r\n\t}\r\n\r\n\t// In `bypass` mode, `VirtualScroller` doesn't wait\r\n\t// for the user to scroll down to render all items:\r\n\t// instead, it renders all items right away, as if\r\n\t// the list is rendered without using `VirtualScroller`.\r\n\t// It was added just to measure how much is the\r\n\t// performance difference between using a `VirtualScroller`\r\n\t// and not using a `VirtualScroller`.\r\n\t// It turned out that unmounting large React component trees\r\n\t// is a very long process, so `VirtualScroller` does seem to\r\n\t// make sense when used in a React application.\r\n\tthis._bypass = bypass\r\n\t// this.bypassBatchSize = bypassBatchSize || 10\r\n\r\n\t// Using `setTimeout()` in render loop is a workaround\r\n\t// for avoiding a React error message:\r\n\t// \"Maximum update depth exceeded.\r\n\t// This can happen when a component repeatedly calls\r\n\t// `.setState()` inside `componentWillUpdate()` or `componentDidUpdate()`.\r\n\t// React limits the number of nested updates to prevent infinite loops.\"\r\n\tthis._useTimeoutInRenderLoop = _useTimeoutInRenderLoop\r\n\r\n\t// `_getItemId()` function is used in `_getItemIndexByItemOrIndex()` function.\r\n\tthis._getItemId = getItemId\r\n\r\n\tif (getItemId) {\r\n\t\tthis.isItemEqual = (a, b) => getItemId(a) === getItemId(b)\r\n\t} else {\r\n\t\tthis.isItemEqual = (a, b) => a === b\r\n\t}\r\n\r\n\tif (onItemInitialRender) {\r\n\t\tthis.onItemInitialRender = onItemInitialRender\r\n\t}\r\n\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\telse if (onItemFirstRender) {\r\n\t\tthis.onItemInitialRender = (item) => {\r\n\t\t\twarn('`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.')\r\n\t\t\tconst { items } = this.getState()\r\n\t\t\tconst i = items.indexOf(item)\r\n\t\t\t// The `item` could also be non-found due to the inconsistency bug:\r\n\t\t\t// The reason is that `i` can be non-consistent with the `items`\r\n\t\t\t// passed to `<VirtualScroller/>` in React due to `updateState()` not being\r\n\t\t\t// instanteneous: when new `items` are passed to `<VirtualScroller/>`,\r\n\t\t\t// `VirtualScroller.updateState({ items })` is called, and if `onItemFirstRender(i)`\r\n\t\t\t// is called after the aforementioned `updateState()` is called but before it finishes,\r\n\t\t\t// `i` would point to an index in \"previous\" `items` while the application\r\n\t\t\t// would assume that `i` points to an index in the \"new\" `items`,\r\n\t\t\t// resulting in an incorrect item being assumed by the application\r\n\t\t\t// or even in an \"array index out of bounds\" error.\r\n\t\t\tif (i >= 0) {\r\n\t\t\t\tonItemFirstRender(i)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// If initial `state` is passed then use `items` from `state`\r\n\t// instead of the `items` argument.\r\n\tif (state) {\r\n\t\titems = state.items\r\n\t}\r\n\r\n\tlog('Items count', items.length)\r\n\tif (getEstimatedItemHeight) {\r\n\t\tlog('Estimated item height', getEstimatedItemHeight())\r\n\t}\r\n\r\n\tcreateStateHelpers.call(this, { state, getInitialItemState, onStateChange, render, items })\r\n\r\n\tcreateVerticalSpacingHelpers.call(this, { getEstimatedInterItemVerticalSpacing })\r\n\tcreateColumnsHelpers.call(this, { getColumnsCount })\r\n\r\n\tcreateLayoutHelpers.call(this)\r\n\tcreateOnRenderHelpers.call(this)\r\n\tcreateScrollableContainerResizeHelpers.call(this)\r\n\tcreateItemsHelpers.call(this)\r\n\r\n\tcreateHelpers.call(this, {\r\n\t\tgetScrollableContainer,\r\n\t\tgetEstimatedItemHeight,\r\n\t\tgetEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\twaitForScrollingToStop: _waitForScrollingToStop\r\n\t})\r\n\r\n\tif (state) {\r\n\t\t// Initialize `ItemHeights` from previously measured `state.itemHeights`.\r\n\t\tthis.itemHeights.readItemHeightsFromState(state)\r\n\r\n\t\t// Initialize some `BeforeResize` internal flags from a previously saved state.\r\n\t\tthis.beforeResize.initializeFromState(state)\r\n\t}\r\n}\r\n\r\nfunction createHelpers({\r\n\tgetScrollableContainer,\r\n\tgetEstimatedItemHeight,\r\n\tgetEstimatedVisibleItemRowsCount,\r\n\tmeasureItemsBatchSize,\r\n\tinitialScrollPosition,\r\n\tonScrollPositionChange,\r\n\twaitForScrollingToStop\r\n}) {\r\n\tthis.itemsContainer = this.engine.createItemsContainer(\r\n\t\tthis.getItemsContainerElement\r\n\t)\r\n\r\n\tthis.isItemsContainerElementTableBody = () => {\r\n\t\treturn this.engine === DOMEngine &&\r\n\t\t\tthis.getItemsContainerElement().tagName === 'TBODY'\r\n\t}\r\n\r\n\tthis.isInBypassMode = () => this._bypass\r\n\r\n\tthis.scrollableContainer = this.engine.createScrollableContainer(\r\n\t\tgetScrollableContainer,\r\n\t\tthis.getItemsContainerElement\r\n\t)\r\n\r\n\t// Create `ItemHeights` instance.\r\n\tthis.itemHeights = new ItemHeights({\r\n\t\tcontainer: this.itemsContainer,\r\n\t\tgetItemHeight: (i) => this.getState().itemHeights[i],\r\n\t\tsetItemHeight: (i, height) => this.getState().itemHeights[i] = height\r\n\t})\r\n\r\n\tthis.getAverageItemHeight = () => {\r\n\t\tconst averageItemHeight = this.itemHeights.getAverageItemHeight()\r\n\t\tif (typeof averageItemHeight === 'number') {\r\n\t\t\treturn averageItemHeight\r\n\t\t}\r\n\t\treturn this.getEstimatedItemHeight()\r\n\t}\r\n\r\n\tthis.getEstimatedItemHeight = () => {\r\n\t\tif (getEstimatedItemHeight) {\r\n\t\t\tconst estimatedItemHeight = getEstimatedItemHeight()\r\n\t\t\tif (typeof estimatedItemHeight === 'number') {\r\n\t\t\t\treturn estimatedItemHeight\r\n\t\t\t}\r\n\t\t\tthrow new Error('[virtual-scroller] `getEstimatedItemHeight()` must return a number')\r\n\t\t}\r\n\t\t// `DEFAULT_ITEM_HEIGHT` will be used in server-side render\r\n\t\t// unless `getEstimatedItemHeight()` parameter is specified.\r\n\t\treturn DEFAULT_ITEM_HEIGHT\r\n\t}\r\n\r\n\tthis.layout = new Layout({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tgetEstimatedVisibleItemRowsCountForInitialRender: getEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tgetPrerenderMargin: () => this.getPrerenderMargin(),\r\n\t\tgetPrerenderMarginRatio: () => this.getPrerenderMarginRatio(),\r\n\t\tgetVerticalSpacing: () => this.getVerticalSpacing(),\r\n\t\tgetVerticalSpacingBeforeResize: () => this.getVerticalSpacingBeforeResize(),\r\n\t\tgetColumnsCount: () => this.getColumnsCount(),\r\n\t\tgetColumnsCountBeforeResize: () => this.getState().beforeResize && this.getState().beforeResize.columnsCount,\r\n\t\tgetItemHeight: (i) => this.getState().itemHeights[i],\r\n\t\tgetItemHeightBeforeResize: (i) => this.getState().beforeResize && this.getState().beforeResize.itemHeights[i],\r\n\t\tgetBeforeResizeItemsCount: () => this.getState().beforeResize ? this.getState().beforeResize.itemHeights.length : 0,\r\n\t\tgetAverageItemHeight: () => this.getAverageItemHeight(),\r\n\t\t// `this.scrollableContainer` is gonna be `undefined` during server-side rendering.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/30\r\n\t\tgetMaxVisibleAreaHeight: () => this.scrollableContainer && this.scrollableContainer.getHeight(),\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\tgetPreviouslyCalculatedLayout: () => this.previouslyCalculatedLayout\r\n\t})\r\n\r\n\tthis.scrollableContainerResizeHandler = new ScrollableContainerResizeHandler({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tgetWidth: () => this.scrollableContainer.getWidth(),\r\n\t\tgetHeight: () => this.scrollableContainer.getHeight(),\r\n\t\tlistenForResize: (listener) => this.scrollableContainer.onResize(listener),\r\n\t\tonResizeStart: () => {\r\n\t\t\tlog('~ Scrollable container resize started ~')\r\n\t\t\tthis._isResizing = true\r\n\t\t},\r\n\t\tonResizeStop: () => {\r\n\t\t\tlog('~ Scrollable container resize finished ~')\r\n\t\t\tthis._isResizing = undefined\r\n\t\t},\r\n\t\tonNoChange: () => {\r\n\t\t\t// There might have been some missed `this.onUpdateShownItemIndexes()` calls\r\n\t\t\t// due to setting `this._isResizing` flag to `true` during the resize.\r\n\t\t\t// So, update shown item indexes just in case.\r\n\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\treason: LAYOUT_REASON.VIEWPORT_SIZE_UNCHANGED\r\n\t\t\t})\r\n\t\t},\r\n\t\tonHeightChange: () => this.onUpdateShownItemIndexes({\r\n\t\t\treason: LAYOUT_REASON.VIEWPORT_HEIGHT_CHANGED\r\n\t\t}),\r\n\t\tonWidthChange: (prevWidth, newWidth) => {\r\n\t\t\tlog('~ Scrollable container width changed from', prevWidth, 'to', newWidth, '~')\r\n\t\t\tthis.onContainerResize()\r\n\t\t}\r\n\t})\r\n\r\n\tthis.scroll = new Scroll({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tscrollableContainer: this.scrollableContainer,\r\n\t\titemsContainer: this.itemsContainer,\r\n\t\twaitForScrollingToStop,\r\n\t\tonScroll: ({ delayed } = {}) => {\r\n\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\treason: delayed ? LAYOUT_REASON.STOPPED_SCROLLING : LAYOUT_REASON.SCROLL\r\n\t\t\t})\r\n\t\t},\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\tisImmediateLayoutScheduled: () => Boolean(this.layoutTimer),\r\n\t\thasNonRenderedItemsAtTheTop: () => this.getState().firstShownItemIndex > 0,\r\n\t\thasNonRenderedItemsAtTheBottom: () => this.getState().lastShownItemIndex < this.getItemsCount() - 1,\r\n\t\tgetLatestLayoutVisibleArea: () => this.latestLayoutVisibleArea,\r\n\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer,\r\n\t\tgetPrerenderMargin: () => this.getPrerenderMargin()\r\n\t})\r\n\r\n\tthis.listHeightMeasurement = new ListHeightMeasurement({\r\n\t\titemsContainer: this.itemsContainer,\r\n\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer\r\n\t})\r\n\r\n\tif (this.engine.watchListTopOffset) {\r\n\t\tthis.listTopOffsetWatcher = this.engine.watchListTopOffset({\r\n\t\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer,\r\n\t\t\tonListTopOffsetChange: ({ reason }) => this.onUpdateShownItemIndexes({\r\n\t\t\t\treason: LAYOUT_REASON.TOP_OFFSET_CHANGED\r\n\t\t\t})\r\n\t\t})\r\n\t}\r\n\r\n\tthis.beforeResize = new BeforeResize({\r\n\t\tgetState: this.getState,\r\n\t\tgetVerticalSpacing: this.getVerticalSpacing,\r\n\t\tgetColumnsCount: this.getColumnsCount\r\n\t})\r\n}"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,iBAAtB;AAEA,OAAOC,MAAP,IAAiBC,aAAjB,QAAsC,aAAtC;AACA,SAASC,mBAAT,QAAoC,sBAApC;AACA,OAAOC,gCAAP,MAA6C,uCAA7C;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AACA,OAAOC,MAAP,MAAmB,aAAnB;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAA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IACtDwD,cAAc,EAAE,KAAKA,cADiC;IAEtD4D,gBAAgB,EAAE,KAAKC;EAF+B,CAA1B,CAA7B;;EAKA,IAAI,KAAKpF,MAAL,CAAYsF,kBAAhB,EAAoC;IACnC,KAAKC,oBAAL,GAA4B,KAAKvF,MAAL,CAAYsF,kBAAZ,CAA+B;MAC1DH,gBAAgB,EAAE,KAAKC,yCADmC;MAE1DI,qBAAqB,EAAE;QAAA,IAAG5B,MAAH,SAAGA,MAAH;QAAA,OAAgB,MAAI,CAACD,wBAAL,CAA8B;UACpEC,MAAM,EAAElG,aAAa,CAAC+H;QAD8C,CAA9B,CAAhB;MAAA;IAFmC,CAA/B,CAA5B;EAMA;;EAED,KAAKpE,YAAL,GAAoB,IAAIxD,YAAJ,CAAiB;IACpCwC,QAAQ,EAAE,KAAKA,QADqB;IAEpCkC,kBAAkB,EAAE,KAAKA,kBAFW;IAGpChD,eAAe,EAAE,KAAKA;EAHc,CAAjB,CAApB;AAKA"}
1
+ {"version":3,"file":"VirtualScroller.constructor.js","names":["DOMEngine","Layout","LAYOUT_REASON","DEFAULT_ITEM_HEIGHT","ScrollableContainerResizeHandler","BeforeResize","Scroll","ListHeightMeasurement","ItemHeights","log","warn","createStateHelpers","createVerticalSpacingHelpers","createColumnsHelpers","createLayoutHelpers","createOnRenderHelpers","createScrollableContainerResizeHelpers","createItemsHelpers","VirtualScrollerConstructor","getItemsContainerElement","items","options","bypass","render","state","getInitialItemState","onStateChange","initialScrollPosition","onScrollPositionChange","scrollableContainer","measureItemsBatchSize","getColumnsCount","getItemId","estimatedItemHeight","getEstimatedVisibleItemRowsCount","getEstimatedInterItemVerticalSpacing","onItemInitialRender","onItemFirstRender","delayRecursiveRenderUntilNextTick","_delayUnnecessaryRerenderUntilStopsScrolling","engine","getEstimatedItemHeight","getScrollableContainer","element","Error","getState","setState","_bypass","_delayRecursiveRenderUntilNextTick","_getItemId","isItemEqual","a","b","item","i","indexOf","length","call","createHelpers","delayUnnecessaryRerenderUntilStopsScrolling","itemHeights","readItemHeightsFromState","beforeResize","initializeFromState","itemsContainer","createItemsContainer","isItemsContainerElementTableBody","tagName","isInBypassMode","createScrollableContainer","container","getItemHeight","setItemHeight","height","getAverageItemHeight","averageItemHeight","layout","getEstimatedVisibleItemRowsCountForInitialRender","getPrerenderMargin","getPrerenderMarginRatio","getVerticalSpacing","getVerticalSpacingBeforeResize","getColumnsCountBeforeResize","columnsCount","getItemHeightBeforeResize","getBeforeResizeItemsCount","getMaxVisibleAreaHeight","getHeight","getPreviouslyCalculatedLayout","previouslyCalculatedLayout","scrollableContainerResizeHandler","getWidth","listenForResize","listener","onResize","onResizeStart","_isResizing","onResizeStop","undefined","onNoChange","onUpdateShownItemIndexes","reason","VIEWPORT_SIZE_UNCHANGED","onHeightChange","VIEWPORT_HEIGHT_CHANGED","onWidthChange","prevWidth","newWidth","onContainerResize","scroll","onScroll","delayed","STOPPED_SCROLLING","SCROLL","isImmediateLayoutScheduled","Boolean","layoutTimer","hasNonRenderedItemsAtTheTop","firstShownItemIndex","hasNonRenderedItemsAtTheBottom","lastShownItemIndex","getItemsCount","getLatestLayoutVisibleArea","latestLayoutVisibleArea","getListTopOffset","getListTopOffsetInsideScrollableContainer","listHeightMeasurement","watchListTopOffset","listTopOffsetWatcher","onListTopOffsetChange","TOP_OFFSET_CHANGED"],"sources":["../source/VirtualScroller.constructor.js"],"sourcesContent":["import DOMEngine from './DOM/Engine.js'\r\n\r\nimport Layout, { LAYOUT_REASON } from './Layout.js'\r\nimport { DEFAULT_ITEM_HEIGHT } from './Layout.defaults.js'\r\nimport ScrollableContainerResizeHandler from './ScrollableContainerResizeHandler.js'\r\nimport BeforeResize from './BeforeResize.js'\r\nimport Scroll from './Scroll.js'\r\nimport ListHeightMeasurement from './ListHeightMeasurement.js'\r\nimport ItemHeights from './ItemHeights.js'\r\n\r\nimport log, { warn } from './utility/debug.js'\r\n\r\nimport createStateHelpers from './VirtualScroller.state.js'\r\nimport createVerticalSpacingHelpers from './VirtualScroller.verticalSpacing.js'\r\nimport createColumnsHelpers from './VirtualScroller.columns.js'\r\nimport createLayoutHelpers from './VirtualScroller.layout.js'\r\nimport createOnRenderHelpers from './VirtualScroller.onRender.js'\r\nimport createScrollableContainerResizeHelpers from './VirtualScroller.onContainerResize.js'\r\nimport createItemsHelpers from './VirtualScroller.items.js'\r\n\r\n/**\r\n * @param {function} getItemsContainerElement — Returns the container DOM `Element` (or `null`).\r\n * @param {any[]} items — The list of items.\r\n * @param {Object} [options] — See README.md.\r\n * @return {VirtualScroller}\r\n */\r\nexport default function VirtualScrollerConstructor(\r\n\tgetItemsContainerElement,\r\n\titems,\r\n\toptions = {}\r\n) {\r\n\tconst {\r\n\t\tbypass,\r\n\t\trender,\r\n\t\tstate,\r\n\t\tgetInitialItemState = () => {},\r\n\t\tonStateChange,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\t// `scrollableContainer` option is deprecated.\r\n\t\t// Use `getScrollableContainer()` option instead.\r\n\t\tscrollableContainer,\r\n\t\tmeasureItemsBatchSize = 50,\r\n\t\tgetColumnsCount,\r\n\t\tgetItemId,\r\n\t\t// `estimatedItemHeight` is deprecated, use `getEstimatedItemHeight()` instead.\r\n\t\testimatedItemHeight,\r\n\t\tgetEstimatedVisibleItemRowsCount,\r\n\t\tgetEstimatedInterItemVerticalSpacing,\r\n\t\tonItemInitialRender,\r\n\t\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\t\tonItemFirstRender,\r\n\t\tdelayRecursiveRenderUntilNextTick,\r\n\t\t_delayUnnecessaryRerenderUntilStopsScrolling,\r\n\t\tengine\r\n\t} = options\r\n\r\n\tlet {\r\n\t\tgetEstimatedItemHeight,\r\n\t\tgetScrollableContainer\r\n\t} = options\r\n\r\n\tlog('~ Initialize ~')\r\n\r\n\t// Could support non-DOM rendering engines.\r\n\t// For example, React Native, `<canvas/>`, etc.\r\n\tthis.engine = engine || DOMEngine\r\n\r\n\tif (!getEstimatedItemHeight && typeof estimatedItemHeight === 'number') {\r\n\t\tgetEstimatedItemHeight = () => estimatedItemHeight\r\n\t}\r\n\r\n\t// `scrollableContainer` option is deprecated.\r\n\t// Use `getScrollableContainer()` option instead.\r\n\tif (!getScrollableContainer && scrollableContainer) {\r\n\t\tgetScrollableContainer = () => scrollableContainer\r\n\t}\r\n\r\n\t// Sometimes, when `new VirtualScroller()` \"core\" instance is created,\r\n\t// `getItemsContainerElement()` function might not yet be ready to return the \"container\" DOM Element.\r\n\t// For example, because the \"container\" DOM Element not rendered yet.\r\n\t// That's the reason why it's a getter function rather than a simple variable.\r\n\t//\r\n\t// As an example, in React `<VirtualScroller/>` component, a \"core\" `VirtualScroller`\r\n\t// instance is created in the React component's `constructor()`, and at that time\r\n\t// the \"container\" DOM Element has not been rendered yet.\r\n\t// The \"container\" DOM Element is only guaranteed to have been rendered\r\n\t// by the time `useEffect()` callback function is called, but at the same time `useEffect()`\r\n\t// is only executed on client side and is not executed on server side at all.\r\n\t// Still, the code has to work both in a web browser and on the server during the initial\r\n\t// \"server-side render\", i.e. it still must render the list during the initial\r\n\t// \"server-side render\". So `VirtualScroller` can't simply be skipped during server-side render.\r\n\t// It has to render something, and that something has to be correct.\r\n\t// This means that the \"core\" `VirtualScroller` should at least correctly compute the state\r\n\t// regardless of whether the `itemsContainerElement` exists or not.\r\n\t//\r\n\tthis.getItemsContainerElement = () => {\r\n\t\tconst element = getItemsContainerElement()\r\n\t\tif (element === null) {\r\n\t\t\tthrow new Error('[virtual-scroller] Items container element is `null`')\r\n\t\t}\r\n\t\treturn element\r\n\t}\r\n\r\n\t// if (prerenderMargin === undefined) {\r\n\t// \t// Renders items which are outside of the screen by this \"prerender margin\".\r\n\t// \t// Is the screen height by default: seems to be the optimal value\r\n\t// \t// for \"Page Up\" / \"Page Down\" navigation and optimized mouse wheel scrolling.\r\n\t// \tprerenderMargin = this.scrollableContainer ? this.scrollableContainer.getHeight() : 0\r\n\t// }\r\n\r\n\tif (options.getState || options.setState) {\r\n\t\tthrow new Error('[virtual-scroller] `getState`/`setState` options usage has changed in the new version. See the readme for more details.')\r\n\t}\r\n\r\n\tif (bypass) {\r\n\t\tlog('~ \"bypass\" mode ~')\r\n\t}\r\n\r\n\t// In `bypass` mode, `VirtualScroller` doesn't wait\r\n\t// for the user to scroll down to render all items:\r\n\t// instead, it renders all items right away, as if\r\n\t// the list is rendered without using `VirtualScroller`.\r\n\t// It was added just to measure how much is the\r\n\t// performance difference between using a `VirtualScroller`\r\n\t// and not using a `VirtualScroller`.\r\n\t// It turned out that unmounting large React component trees\r\n\t// is a very long process, so `VirtualScroller` does seem to\r\n\t// make sense when used in a React application.\r\n\tthis._bypass = bypass\r\n\t// this.bypassBatchSize = bypassBatchSize || 10\r\n\r\n\t// Using `setTimeout()` in render loop is a workaround\r\n\t// for avoiding a React error message:\r\n\t// \"Maximum update depth exceeded.\r\n\t// This can happen when a component repeatedly calls\r\n\t// `.setState()` inside `componentWillUpdate()` or `componentDidUpdate()`.\r\n\t// React limits the number of nested updates to prevent infinite loops.\"\r\n\tthis._delayRecursiveRenderUntilNextTick = delayRecursiveRenderUntilNextTick\r\n\r\n\t// `_getItemId()` function is used in `_getItemIndexByItemOrIndex()` function.\r\n\tthis._getItemId = getItemId\r\n\r\n\tif (getItemId) {\r\n\t\tthis.isItemEqual = (a, b) => getItemId(a) === getItemId(b)\r\n\t} else {\r\n\t\tthis.isItemEqual = (a, b) => a === b\r\n\t}\r\n\r\n\tif (onItemInitialRender) {\r\n\t\tthis.onItemInitialRender = onItemInitialRender\r\n\t}\r\n\t// `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.\r\n\telse if (onItemFirstRender) {\r\n\t\tthis.onItemInitialRender = (item) => {\r\n\t\t\twarn('`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.')\r\n\t\t\tconst { items } = this.getState()\r\n\t\t\tconst i = items.indexOf(item)\r\n\t\t\t// The `item` could also be non-found due to the inconsistency bug:\r\n\t\t\t// The reason is that `i` can be non-consistent with the `items`\r\n\t\t\t// passed to `<VirtualScroller/>` in React due to `updateState()` not being\r\n\t\t\t// instanteneous: when new `items` are passed to `<VirtualScroller/>`,\r\n\t\t\t// `VirtualScroller.updateState({ items })` is called, and if `onItemFirstRender(i)`\r\n\t\t\t// is called after the aforementioned `updateState()` is called but before it finishes,\r\n\t\t\t// `i` would point to an index in \"previous\" `items` while the application\r\n\t\t\t// would assume that `i` points to an index in the \"new\" `items`,\r\n\t\t\t// resulting in an incorrect item being assumed by the application\r\n\t\t\t// or even in an \"array index out of bounds\" error.\r\n\t\t\tif (i >= 0) {\r\n\t\t\t\tonItemFirstRender(i)\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t// If initial `state` is passed then use `items` from `state`\r\n\t// instead of the `items` argument.\r\n\tif (state) {\r\n\t\titems = state.items\r\n\t}\r\n\r\n\tlog('Items count', items.length)\r\n\tif (getEstimatedItemHeight) {\r\n\t\tlog('Estimated item height', getEstimatedItemHeight())\r\n\t}\r\n\r\n\tcreateStateHelpers.call(this, { state, getInitialItemState, onStateChange, render, items })\r\n\r\n\tcreateVerticalSpacingHelpers.call(this, { getEstimatedInterItemVerticalSpacing })\r\n\tcreateColumnsHelpers.call(this, { getColumnsCount })\r\n\r\n\tcreateLayoutHelpers.call(this)\r\n\tcreateOnRenderHelpers.call(this)\r\n\tcreateScrollableContainerResizeHelpers.call(this)\r\n\tcreateItemsHelpers.call(this)\r\n\r\n\tcreateHelpers.call(this, {\r\n\t\tgetScrollableContainer,\r\n\t\tgetEstimatedItemHeight,\r\n\t\tgetEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\tdelayUnnecessaryRerenderUntilStopsScrolling: _delayUnnecessaryRerenderUntilStopsScrolling\r\n\t})\r\n\r\n\tif (state) {\r\n\t\t// Initialize `ItemHeights` from previously measured `state.itemHeights`.\r\n\t\tthis.itemHeights.readItemHeightsFromState(state)\r\n\r\n\t\t// Initialize some `BeforeResize` internal flags from a previously saved state.\r\n\t\tthis.beforeResize.initializeFromState(state)\r\n\t}\r\n}\r\n\r\nfunction createHelpers({\r\n\tgetScrollableContainer,\r\n\tgetEstimatedItemHeight,\r\n\tgetEstimatedVisibleItemRowsCount,\r\n\tmeasureItemsBatchSize,\r\n\tinitialScrollPosition,\r\n\tonScrollPositionChange,\r\n\tdelayUnnecessaryRerenderUntilStopsScrolling\r\n}) {\r\n\tthis.itemsContainer = this.engine.createItemsContainer(\r\n\t\tthis.getItemsContainerElement\r\n\t)\r\n\r\n\tthis.isItemsContainerElementTableBody = () => {\r\n\t\treturn this.engine === DOMEngine &&\r\n\t\t\tthis.getItemsContainerElement().tagName === 'TBODY'\r\n\t}\r\n\r\n\tthis.isInBypassMode = () => this._bypass\r\n\r\n\tthis.scrollableContainer = this.engine.createScrollableContainer(\r\n\t\tgetScrollableContainer,\r\n\t\tthis.getItemsContainerElement\r\n\t)\r\n\r\n\t// Create `ItemHeights` instance.\r\n\tthis.itemHeights = new ItemHeights({\r\n\t\tcontainer: this.itemsContainer,\r\n\t\tgetItemHeight: (i) => this.getState().itemHeights[i],\r\n\t\tsetItemHeight: (i, height) => this.getState().itemHeights[i] = height\r\n\t})\r\n\r\n\tthis.getAverageItemHeight = () => {\r\n\t\tconst averageItemHeight = this.itemHeights.getAverageItemHeight()\r\n\t\tif (typeof averageItemHeight === 'number') {\r\n\t\t\treturn averageItemHeight\r\n\t\t}\r\n\t\treturn this.getEstimatedItemHeight()\r\n\t}\r\n\r\n\tthis.getEstimatedItemHeight = () => {\r\n\t\tif (getEstimatedItemHeight) {\r\n\t\t\tconst estimatedItemHeight = getEstimatedItemHeight()\r\n\t\t\tif (typeof estimatedItemHeight === 'number') {\r\n\t\t\t\treturn estimatedItemHeight\r\n\t\t\t}\r\n\t\t\tthrow new Error('[virtual-scroller] `getEstimatedItemHeight()` must return a number')\r\n\t\t}\r\n\t\t// `DEFAULT_ITEM_HEIGHT` will be used in server-side render\r\n\t\t// unless `getEstimatedItemHeight()` parameter is specified.\r\n\t\treturn DEFAULT_ITEM_HEIGHT\r\n\t}\r\n\r\n\tthis.layout = new Layout({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tgetEstimatedVisibleItemRowsCountForInitialRender: getEstimatedVisibleItemRowsCount,\r\n\t\tmeasureItemsBatchSize,\r\n\t\tgetPrerenderMargin: () => this.getPrerenderMargin(),\r\n\t\tgetPrerenderMarginRatio: () => this.getPrerenderMarginRatio(),\r\n\t\tgetVerticalSpacing: () => this.getVerticalSpacing(),\r\n\t\tgetVerticalSpacingBeforeResize: () => this.getVerticalSpacingBeforeResize(),\r\n\t\tgetColumnsCount: () => this.getColumnsCount(),\r\n\t\tgetColumnsCountBeforeResize: () => this.getState().beforeResize && this.getState().beforeResize.columnsCount,\r\n\t\tgetItemHeight: (i) => this.getState().itemHeights[i],\r\n\t\tgetItemHeightBeforeResize: (i) => this.getState().beforeResize && this.getState().beforeResize.itemHeights[i],\r\n\t\tgetBeforeResizeItemsCount: () => this.getState().beforeResize ? this.getState().beforeResize.itemHeights.length : 0,\r\n\t\tgetAverageItemHeight: () => this.getAverageItemHeight(),\r\n\t\t// `this.scrollableContainer` is gonna be `undefined` during server-side rendering.\r\n\t\t// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/30\r\n\t\tgetMaxVisibleAreaHeight: () => this.scrollableContainer && this.scrollableContainer.getHeight(),\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\tgetPreviouslyCalculatedLayout: () => this.previouslyCalculatedLayout\r\n\t})\r\n\r\n\tthis.scrollableContainerResizeHandler = new ScrollableContainerResizeHandler({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tgetWidth: () => this.scrollableContainer.getWidth(),\r\n\t\tgetHeight: () => this.scrollableContainer.getHeight(),\r\n\t\tlistenForResize: (listener) => this.scrollableContainer.onResize(listener),\r\n\t\tonResizeStart: () => {\r\n\t\t\tlog('~ Scrollable container resize started ~')\r\n\t\t\tthis._isResizing = true\r\n\t\t},\r\n\t\tonResizeStop: () => {\r\n\t\t\tlog('~ Scrollable container resize finished ~')\r\n\t\t\tthis._isResizing = undefined\r\n\t\t},\r\n\t\tonNoChange: () => {\r\n\t\t\t// There might have been some missed `this.onUpdateShownItemIndexes()` calls\r\n\t\t\t// due to setting `this._isResizing` flag to `true` during the resize.\r\n\t\t\t// So, update shown item indexes just in case.\r\n\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\treason: LAYOUT_REASON.VIEWPORT_SIZE_UNCHANGED\r\n\t\t\t})\r\n\t\t},\r\n\t\tonHeightChange: () => this.onUpdateShownItemIndexes({\r\n\t\t\treason: LAYOUT_REASON.VIEWPORT_HEIGHT_CHANGED\r\n\t\t}),\r\n\t\tonWidthChange: (prevWidth, newWidth) => {\r\n\t\t\tlog('~ Scrollable container width changed from', prevWidth, 'to', newWidth, '~')\r\n\t\t\tthis.onContainerResize()\r\n\t\t}\r\n\t})\r\n\r\n\tthis.scroll = new Scroll({\r\n\t\tisInBypassMode: this.isInBypassMode,\r\n\t\tscrollableContainer: this.scrollableContainer,\r\n\t\titemsContainer: this.itemsContainer,\r\n\t\tdelayUnnecessaryRerenderUntilStopsScrolling,\r\n\t\tonScroll: ({ delayed } = {}) => {\r\n\t\t\tthis.onUpdateShownItemIndexes({\r\n\t\t\t\treason: delayed ? LAYOUT_REASON.STOPPED_SCROLLING : LAYOUT_REASON.SCROLL\r\n\t\t\t})\r\n\t\t},\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\tisImmediateLayoutScheduled: () => Boolean(this.layoutTimer),\r\n\t\thasNonRenderedItemsAtTheTop: () => this.getState().firstShownItemIndex > 0,\r\n\t\thasNonRenderedItemsAtTheBottom: () => this.getState().lastShownItemIndex < this.getItemsCount() - 1,\r\n\t\tgetLatestLayoutVisibleArea: () => this.latestLayoutVisibleArea,\r\n\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer,\r\n\t\tgetPrerenderMargin: () => this.getPrerenderMargin()\r\n\t})\r\n\r\n\tthis.listHeightMeasurement = new ListHeightMeasurement({\r\n\t\titemsContainer: this.itemsContainer,\r\n\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer\r\n\t})\r\n\r\n\tif (this.engine.watchListTopOffset) {\r\n\t\tthis.listTopOffsetWatcher = this.engine.watchListTopOffset({\r\n\t\t\tgetListTopOffset: this.getListTopOffsetInsideScrollableContainer,\r\n\t\t\tonListTopOffsetChange: () => this.onUpdateShownItemIndexes({\r\n\t\t\t\treason: LAYOUT_REASON.TOP_OFFSET_CHANGED\r\n\t\t\t})\r\n\t\t})\r\n\t}\r\n\r\n\tthis.beforeResize = new BeforeResize({\r\n\t\tgetState: this.getState,\r\n\t\tgetVerticalSpacing: this.getVerticalSpacing,\r\n\t\tgetColumnsCount: this.getColumnsCount\r\n\t})\r\n}"],"mappings":"AAAA,OAAOA,SAAP,MAAsB,iBAAtB;AAEA,OAAOC,MAAP,IAAiBC,aAAjB,QAAsC,aAAtC;AACA,SAASC,mBAAT,QAAoC,sBAApC;AACA,OAAOC,gCAAP,MAA6C,uCAA7C;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AACA,OAAOC,MAAP,MAAmB,aAAnB;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,WAAP,MAAwB,kBAAxB;AAEA,OAAOC,GAAP,IAAcC,IAAd,QAA0B,oBAA1B;AAEA,OAAOC,kBAAP,MAA+B,4BAA/B;AACA,OAAOC,4BAAP,MAAyC,sCAAzC;AACA,OAAOC,oBAAP,MAAiC,8BAAjC;AACA,OAAOC,mBAAP,MAAgC,6BAAhC;AACA,OAAOC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H,gBAAgB,EAAE,KAAKC,yCADmC;MAE1DI,qBAAqB,EAAE;QAAA,OAAM,MAAI,CAAC7B,wBAAL,CAA8B;UAC1DC,MAAM,EAAEnG,aAAa,CAACgI;QADoC,CAA9B,CAAN;MAAA;IAFmC,CAA/B,CAA5B;EAMA;;EAED,KAAKpE,YAAL,GAAoB,IAAIzD,YAAJ,CAAiB;IACpCwC,QAAQ,EAAE,KAAKA,QADqB;IAEpCmC,kBAAkB,EAAE,KAAKA,kBAFW;IAGpCjD,eAAe,EAAE,KAAKA;EAHc,CAAjB,CAApB;AAKA"}
@@ -12,6 +12,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
12
12
 
13
13
  import VirtualScrollerConstructor from './VirtualScroller.constructor.js';
14
14
  import { LAYOUT_REASON } from './Layout.js';
15
+ import { unscheduleOnNextTick } from './utility/scheduleOnNextTick.js';
15
16
  import log, { warn, reportError } from './utility/debug.js';
16
17
  import { supportsTbody, hasTbodyStyles, addTbodyStyles, BROWSER_NOT_SUPPORTED_ERROR } from './DOM/tbody.js';
17
18
 
@@ -47,9 +48,16 @@ var VirtualScroller = /*#__PURE__*/function () {
47
48
  if (_this.listTopOffsetWatcher && _this.listTopOffsetWatcher.isStarted()) {
48
49
  _this.listTopOffsetWatcher.stop();
49
50
  } // Cancel any scheduled layout.
51
+ // Any pending state update is discarded here.
50
52
 
51
53
 
52
- _this.cancelLayoutTimer({});
54
+ _this.cancelLayoutTimer({}); // Cancel any scheduled "recursive re-render duration" timer.
55
+
56
+
57
+ if (_this._stateUpdateSequenceStartedAtResetTimer !== undefined) {
58
+ unscheduleOnNextTick(_this._stateUpdateSequenceStartedAtResetTimer);
59
+ _this._stateUpdateSequenceStartedAtResetTimer = undefined;
60
+ }
53
61
  });
54
62
 
55
63
  _defineProperty(this, "updateLayout", function () {