virtual-scroller 1.12.3 → 1.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +0 -2
  2. package/bundle/index-bypass.html +2 -2
  3. package/bundle/index-grid.html +2 -2
  4. package/bundle/index-scrollableContainer.html +2 -2
  5. package/bundle/virtual-scroller-dom.js +1 -1
  6. package/bundle/virtual-scroller-dom.js.map +1 -1
  7. package/bundle/virtual-scroller-react.js +1 -1
  8. package/bundle/virtual-scroller-react.js.map +1 -1
  9. package/bundle/virtual-scroller.js +1 -1
  10. package/bundle/virtual-scroller.js.map +1 -1
  11. package/commonjs/Layout.js +9 -12
  12. package/commonjs/Layout.js.map +1 -1
  13. package/commonjs/Layout.test.js +20 -10
  14. package/commonjs/Layout.test.js.map +1 -1
  15. package/commonjs/{Resize.js → ScrollableContainerResizeHandler.js} +7 -7
  16. package/commonjs/ScrollableContainerResizeHandler.js.map +1 -0
  17. package/commonjs/VirtualScroller.constructor.js +5 -5
  18. package/commonjs/VirtualScroller.constructor.js.map +1 -1
  19. package/commonjs/VirtualScroller.items.js +1 -1
  20. package/commonjs/VirtualScroller.items.js.map +1 -1
  21. package/commonjs/VirtualScroller.js +5 -5
  22. package/commonjs/VirtualScroller.js.map +1 -1
  23. package/commonjs/VirtualScroller.layout.js +8 -12
  24. package/commonjs/VirtualScroller.layout.js.map +1 -1
  25. package/commonjs/{VirtualScroller.resize.js → VirtualScroller.onContainerResize.js} +2 -2
  26. package/commonjs/VirtualScroller.onContainerResize.js.map +1 -0
  27. package/modules/Layout.js +9 -12
  28. package/modules/Layout.js.map +1 -1
  29. package/modules/Layout.test.js +20 -10
  30. package/modules/Layout.test.js.map +1 -1
  31. package/modules/{Resize.js → ScrollableContainerResizeHandler.js} +7 -7
  32. package/modules/ScrollableContainerResizeHandler.js.map +1 -0
  33. package/modules/VirtualScroller.constructor.js +5 -5
  34. package/modules/VirtualScroller.constructor.js.map +1 -1
  35. package/modules/VirtualScroller.items.js +1 -1
  36. package/modules/VirtualScroller.items.js.map +1 -1
  37. package/modules/VirtualScroller.js +5 -5
  38. package/modules/VirtualScroller.js.map +1 -1
  39. package/modules/VirtualScroller.layout.js +8 -12
  40. package/modules/VirtualScroller.layout.js.map +1 -1
  41. package/modules/{VirtualScroller.resize.js → VirtualScroller.onContainerResize.js} +2 -2
  42. package/modules/VirtualScroller.onContainerResize.js.map +1 -0
  43. package/package.json +1 -1
  44. package/source/Layout.js +9 -12
  45. package/source/Layout.test.js +20 -10
  46. package/source/{Resize.js → ScrollableContainerResizeHandler.js} +1 -1
  47. package/source/VirtualScroller.constructor.js +5 -5
  48. package/source/VirtualScroller.items.js +1 -1
  49. package/source/VirtualScroller.js +5 -5
  50. package/source/VirtualScroller.layout.js +8 -12
  51. package/source/{VirtualScroller.resize.js → VirtualScroller.onContainerResize.js} +1 -1
  52. package/website/index-bypass.html +4 -14
  53. package/website/index-dom.html +1 -1
  54. package/website/index-grid.html +4 -4
  55. package/website/index-scrollableContainer.html +4 -4
  56. package/website/index-tbody-scrollableContainer.html +2 -0
  57. package/website/index-tbody.html +2 -0
  58. package/website/index.html +3 -3
  59. package/commonjs/Resize.js.map +0 -1
  60. package/commonjs/VirtualScroller.resize.js.map +0 -1
  61. package/modules/Resize.js.map +0 -1
  62. package/modules/VirtualScroller.resize.js.map +0 -1
@@ -102,7 +102,7 @@ export default class VirtualScroller {
102
102
  }
103
103
  }
104
104
 
105
- this.resize.start()
105
+ this.scrollableContainerResizeHandler.start()
106
106
  this.scroll.start()
107
107
 
108
108
  // If `scrollableContainerWidth` hasn't been measured yet,
@@ -123,9 +123,9 @@ export default class VirtualScroller {
123
123
  log('~ Scrollable container width changed from', prevWidth, 'to', newWidth, '~')
124
124
  // The pending state update (if present) won't be applied in this case.
125
125
  // That's ok because such state update could currently only originate in
126
- // `this.onResize()` function. Therefore, alling `this.onResize()` again
126
+ // `this.onContainerResize()` function. Therefore, alling `this.onContainerResize()` again
127
127
  // would rewrite all those `stateUpdate` properties anyway, so they're not passed.
128
- return this.onResize()
128
+ return this.onContainerResize()
129
129
  }
130
130
  }
131
131
 
@@ -136,7 +136,7 @@ export default class VirtualScroller {
136
136
  const columnsCount = this.getActualColumnsCount()
137
137
  const columnsCountFromState = this.getState().columnsCount || 1
138
138
  if (columnsCount !== columnsCountFromState) {
139
- return this.onResize()
139
+ return this.onContainerResize()
140
140
  }
141
141
  }
142
142
 
@@ -158,7 +158,7 @@ export default class VirtualScroller {
158
158
 
159
159
  log('~ Stop ~')
160
160
 
161
- this.resize.stop()
161
+ this.scrollableContainerResizeHandler.stop()
162
162
  this.scroll.stop()
163
163
 
164
164
  // Stop `ListTopOffsetWatcher` if it has been started.
@@ -217,25 +217,22 @@ export default function() {
217
217
  })
218
218
  }
219
219
 
220
- function getVisibleArea() {
221
- const visibleArea = this.scroll.getVisibleAreaBounds()
222
- this.latestLayoutVisibleArea = visibleArea
220
+ function getCoordinatesOfVisibleAreaInsideTheList() {
221
+ const visibleAreaBounds = this.scroll.getVisibleAreaBounds()
222
+ this.latestLayoutVisibleArea = visibleAreaBounds
223
223
 
224
224
  // Subtract the top offset of the list inside the scrollable container.
225
225
  const listTopOffsetInsideScrollableContainer = this.getListTopOffsetInsideScrollableContainer()
226
226
  return {
227
- top: visibleArea.top - listTopOffsetInsideScrollableContainer,
228
- bottom: visibleArea.bottom - listTopOffsetInsideScrollableContainer
227
+ top: visibleAreaBounds.top - listTopOffsetInsideScrollableContainer,
228
+ bottom: visibleAreaBounds.bottom - listTopOffsetInsideScrollableContainer
229
229
  }
230
230
  }
231
231
 
232
232
  function getShownItemIndexes() {
233
233
  const itemsCount = this.getItemsCount()
234
234
 
235
- const {
236
- top: visibleAreaTop,
237
- bottom: visibleAreaBottom
238
- } = getVisibleArea.call(this)
235
+ const visibleAreaInsideTheList = getCoordinatesOfVisibleAreaInsideTheList.call(this)
239
236
 
240
237
  if (this.bypass) {
241
238
  return {
@@ -254,7 +251,7 @@ export default function() {
254
251
  // then it would also require listening for "scroll" events on the screen.
255
252
  // Overall, I suppose that such "actual visibility" feature would be
256
253
  // a very minor optimization and not something I'd deal with.
257
- const isVisible = visibleAreaTop < this.itemsContainer.getHeight() && visibleAreaBottom > 0
254
+ const isVisible = visibleAreaInsideTheList.top < this.itemsContainer.getHeight() + this.layout.getPrerenderMargin() && visibleAreaInsideTheList.bottom > 0 - this.layout.getPrerenderMargin()
258
255
  if (!isVisible) {
259
256
  log('The entire list is off-screen. No items are visible.')
260
257
  return this.layout.getNonVisibleListShownItemIndexes()
@@ -263,8 +260,7 @@ export default function() {
263
260
  // Get shown item indexes.
264
261
  return this.layout.getShownItemIndexes({
265
262
  itemsCount: this.getItemsCount(),
266
- visibleAreaTop,
267
- visibleAreaBottom
263
+ visibleAreaInsideTheList
268
264
  })
269
265
  }
270
266
 
@@ -1,7 +1,7 @@
1
1
  import log from './utility/debug.js'
2
2
 
3
3
  export default function() {
4
- this.onResize = () => {
4
+ this.onContainerResize = () => {
5
5
  // Reset "previously calculated layout".
6
6
  //
7
7
  // The "previously calculated layout" feature is not currently used.
@@ -8,31 +8,21 @@
8
8
 
9
9
  <title>React VirtualScroller Demo</title>
10
10
 
11
- <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
12
- <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
11
+ <script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
12
+ <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
13
13
  <script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.7.2/prop-types.min.js"></script>
14
14
  <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
15
15
 
16
16
  <script src="./virtual-scroller-react.js"></script>
17
- <script src="./on-scroll-to-react.js"></script>
17
+ <script src="./lib/on-scroll-to-react.js"></script>
18
18
  <script src="./messages.js"></script>
19
19
 
20
20
  <link rel="stylesheet" href="./style.css"/>
21
-
22
- <!--
23
- <style>
24
- #messages {
25
- border-top: 2px solid rgb(230, 236, 240);
26
- display: grid;
27
- grid-gap: 2em;
28
- }
29
- </style>
30
- -->
31
21
  </head>
32
22
 
33
23
  <body>
34
24
  <!-- http://tholman.com/github-corners/ -->
35
- <a title="Go to GitHub repo" href="https://github.com/catamphetamine/virtual-scroller" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
25
+ <a title="Go to GitLab repo" href="https://gitlab.com/catamphetamine/virtual-scroller" class="github-corner" aria-label="View source on GitLab"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
36
26
 
37
27
  <div id="root"></div>
38
28
 
@@ -19,7 +19,7 @@
19
19
 
20
20
  <body>
21
21
  <!-- http://tholman.com/github-corners/ -->
22
- <a title="Go to GitHub repo" href="https://github.com/catamphetamine/virtual-scroller" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
22
+ <a title="Go to GitLab repo" href="https://gitlab.com/catamphetamine/virtual-scroller" class="github-corner" aria-label="View source on GitLab"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
23
23
 
24
24
  <section class="container">
25
25
  <h1>
@@ -8,13 +8,13 @@
8
8
 
9
9
  <title>React VirtualScroller Demo (Grid Layout)</title>
10
10
 
11
- <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
12
- <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
11
+ <script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
12
+ <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
13
13
  <script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.7.2/prop-types.min.js"></script>
14
14
  <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
15
15
 
16
16
  <script src="./virtual-scroller-react.js"></script>
17
- <script src="./on-scroll-to-react.js"></script>
17
+ <script src="./lib/on-scroll-to-react.js"></script>
18
18
  <script src="./messages.js"></script>
19
19
 
20
20
  <link rel="stylesheet" href="./style.css"/>
@@ -45,7 +45,7 @@
45
45
 
46
46
  <body>
47
47
  <!-- http://tholman.com/github-corners/ -->
48
- <a title="Go to GitHub repo" href="https://github.com/catamphetamine/virtual-scroller" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
48
+ <a title="Go to GitLab repo" href="https://gitlab.com/catamphetamine/virtual-scroller" class="github-corner" aria-label="View source on GitLab"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
49
49
 
50
50
  <div id="root"></div>
51
51
 
@@ -8,13 +8,13 @@
8
8
 
9
9
  <title>React VirtualScroller Demo (Scrollable Container)</title>
10
10
 
11
- <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
12
- <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
11
+ <script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
12
+ <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
13
13
  <script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.7.2/prop-types.min.js"></script>
14
14
  <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
15
15
 
16
16
  <script src="./virtual-scroller-react.js"></script>
17
- <script src="./on-scroll-to-react.js"></script>
17
+ <script src="./lib/on-scroll-to-react.js"></script>
18
18
  <script src="./messages.js"></script>
19
19
 
20
20
  <link rel="stylesheet" href="./style.css"/>
@@ -22,7 +22,7 @@
22
22
 
23
23
  <body>
24
24
  <!-- http://tholman.com/github-corners/ -->
25
- <a title="Go to GitHub repo" href="https://github.com/catamphetamine/virtual-scroller" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
25
+ <a title="Go to GitLab repo" href="https://gitlab.com/catamphetamine/virtual-scroller" class="github-corner" aria-label="View source on GitLab"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
26
26
 
27
27
  <div id="root"></div>
28
28
 
@@ -2,6 +2,8 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
+ <!-- Fix document width for mobile devices. -->
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
7
  <title>
6
8
  VirtualScroller scrollable container test
7
9
  </title>
@@ -2,6 +2,8 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
+ <!-- Fix document width for mobile devices. -->
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
7
  <title>
6
8
  VirtualScroller scrollable container test
7
9
  </title>
@@ -8,8 +8,8 @@
8
8
 
9
9
  <title>React VirtualScroller Demo</title>
10
10
 
11
- <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
12
- <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
11
+ <script crossorigin src="https://unpkg.com/react@18/umd/react.development.js"></script>
12
+ <script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
13
13
  <script crossorigin src="https://cdnjs.cloudflare.com/ajax/libs/prop-types/15.7.2/prop-types.min.js"></script>
14
14
  <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
15
15
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  <body>
24
24
  <!-- http://tholman.com/github-corners/ -->
25
- <a title="Go to GitHub repo" href="https://github.com/catamphetamine/virtual-scroller" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
25
+ <a title="Go to GitLab repo" href="https://gitlab.com/catamphetamine/virtual-scroller" class="github-corner" aria-label="View source on GitLab"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
26
26
 
27
27
  <div id="root"></div>
28
28
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"Resize.js","names":["Resize","bypass","getWidth","getHeight","listenForResize","onResizeStart","onResizeStop","onHeightChange","onWidthChange","onNoChange","isActive","prevScrollableContainerWidth","width","prevScrollableContainerHeight","height","onResize","debounce","_onResize","SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL","onStart","onStop","unlistenResize","undefined"],"sources":["../source/Resize.js"],"sourcesContent":["import debounce from './utility/debounce.js'\r\nimport log from './utility/debug.js'\r\n\r\nexport default class Resize {\r\n\tconstructor({\r\n\t\tbypass,\r\n\t\tgetWidth,\r\n\t\tgetHeight,\r\n\t\tlistenForResize,\r\n\t\tonResizeStart,\r\n\t\tonResizeStop,\r\n\t\tonHeightChange,\r\n\t\tonWidthChange,\r\n\t\tonNoChange\r\n\t}) {\r\n\t\tthis.bypass = bypass\r\n\r\n\t\tthis.onHeightChange = onHeightChange\r\n\t\tthis.onWidthChange = onWidthChange\r\n\t\tthis.onNoChange = onNoChange\r\n\r\n\t\tthis.getWidth = getWidth\r\n\t\tthis.getHeight = getHeight\r\n\t\tthis.listenForResize = listenForResize\r\n\r\n\t\tthis.onResize = debounce(\r\n\t\t\tthis._onResize,\r\n\t\t\tSCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL,\r\n\t\t\t{\r\n\t\t\t\tonStart: onResizeStart,\r\n\t\t\t\tonStop: onResizeStop\r\n\t\t\t}\r\n\t\t)\r\n\t}\r\n\r\n\tstart() {\r\n\t\tthis.isActive = true\r\n\t\tif (this.bypass) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\tthis.width = this.getWidth()\r\n\t\tthis.height = this.getHeight()\r\n\t\tthis.unlistenResize = this.listenForResize(this.onResize)\r\n\t}\r\n\r\n\tstop() {\r\n\t\tthis.isActive = false\r\n\t\tthis.width = undefined\r\n\t\tthis.height = undefined\r\n\t\tif (this.unlistenResize) {\r\n\t\t\tthis.unlistenResize()\r\n\t\t\tthis.unlistenResize = undefined\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * On scrollable container resize.\r\n\t */\r\n\t_onResize = () => {\r\n\t\t// If `VirtualScroller` has been unmounted\r\n\t\t// while `debounce()`'s `setTimeout()` was waiting, then exit.\r\n\t\t// If the `VirtualScroller` gets restarted later, it will detect\r\n\t\t// that `state.scrollableContainerWidth` doesn't match the actual\r\n\t\t// scrollable container width, and will call `this.onResize()`.\r\n\t\tif (!this.isActive) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tconst prevScrollableContainerWidth = this.width\r\n\t\tconst prevScrollableContainerHeight = this.height\r\n\r\n\t\tthis.width = this.getWidth()\r\n\t\tthis.height = this.getHeight()\r\n\r\n\t\tif (this.width === prevScrollableContainerWidth) {\r\n\t\t\tif (this.height === prevScrollableContainerHeight) {\r\n\t\t\t\t// The dimensions of the container didn't change,\r\n\t\t\t\t// so there's no need to re-layout anything.\r\n\t\t\t\tthis.onNoChange()\r\n\t\t\t} else {\r\n\t\t\t\t// Scrollable container height has changed,\r\n\t\t\t\t// so just recalculate shown item indexes.\r\n\t\t\t\t// No need to perform a re-layout from scratch.\r\n\t\t\t\tthis.onHeightChange(prevScrollableContainerHeight, this.height)\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t// Reset item heights, because if scrollable container's width (or height)\r\n\t\t\t// has changed, then the list width (or height) most likely also has changed,\r\n\t\t\t// and also some CSS `@media()` rules might have been added or removed.\r\n\t\t\t// So re-render the list entirely.\r\n\t\t\tthis.onWidthChange(prevScrollableContainerWidth, this.width)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nconst SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL = 250"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;;;;;IAEqBA,M;EACpB,sBAUG;IAAA;;IAAA,IATFC,MASE,QATFA,MASE;IAAA,IARFC,QAQE,QARFA,QAQE;IAAA,IAPFC,SAOE,QAPFA,SAOE;IAAA,IANFC,eAME,QANFA,eAME;IAAA,IALFC,aA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B,IAAhB;;MACA,IAAI,KAAKT,MAAT,EAAiB;QAChB;MACA;;MACD,KAAKW,KAAL,GAAa,KAAKV,QAAL,EAAb;MACA,KAAKY,MAAL,GAAc,KAAKX,SAAL,EAAd;MACA,KAAKkB,cAAL,GAAsB,KAAKjB,eAAL,CAAqB,KAAKW,QAA1B,CAAtB;IACA;;;WAED,gBAAO;MACN,KAAKL,QAAL,GAAgB,KAAhB;MACA,KAAKE,KAAL,GAAaU,SAAb;MACA,KAAKR,MAAL,GAAcQ,SAAd;;MACA,IAAI,KAAKD,cAAT,EAAyB;QACxB,KAAKA,cAAL;QACA,KAAKA,cAAL,GAAsBC,SAAtB;MACA;IACD;IAED;AACD;AACA;;;;;;;;AAsCA,IAAMJ,6CAA6C,GAAG,GAAtD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"VirtualScroller.resize.js","names":["onResize","previouslyCalculatedLayout","undefined","listHeightMeasurement","reset","itemsCount","newItemsWillBeRendered","count","getState","itemHeights","length","layout","newState","scrollableContainerWidth","scrollableContainer","getWidth","firstShownItemIndex","lastShownItemIndex","beforeItemsHeight","afterItemsHeight","Array","columnsCount","getActualColumnsCountForState","verticalSpacing","newColumnsCount","getActualColumnsCount","newFirstShownItemIndex","Math","floor","newLastShownItemIndex","min","ceil","log","getVerticalSpacing","getColumnsCount","shouldDiscardBeforeResizeItemHeights","beforeResize","shouldIncludeBeforeResizeValuesInState","snapshotBeforeResizeItemHeights","widthHasChanged","stateUpdate","updateState","prepend","replace"],"sources":["../source/VirtualScroller.resize.js"],"sourcesContent":["import log from './utility/debug.js'\r\n\r\nexport default function() {\r\n\tthis.onResize = () => {\r\n\t\t// Reset \"previously calculated layout\".\r\n\t\t//\r\n\t\t// The \"previously calculated layout\" feature is not currently used.\r\n\t\t//\r\n\t\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t\t// rather than from scratch, which would be an optimization.\r\n\t\t//\r\n\t\tthis.previouslyCalculatedLayout = undefined\r\n\r\n\t\t// Cancel any potential scheduled scroll position restoration.\r\n\t\tthis.listHeightMeasurement.reset()\r\n\r\n\t\t// Get the most recent items count.\r\n\t\t// If there're a \"pending\" `setItems()` call then use the items count from that call\r\n\t\t// instead of using the count of currently shown `items` from `state`.\r\n\t\t// A `setItems()` call is \"pending\" when `updateState()` operation is \"asynchronous\", that is\r\n\t\t// when `updateState()` calls aren't applied immediately, like in React.\r\n\t\tconst itemsCount = this.newItemsWillBeRendered\r\n\t\t\t? this.newItemsWillBeRendered.count\r\n\t\t\t: this.getState().itemHeights.length\r\n\r\n\t\t// If layout values have been calculated as a result of a \"pending\" `setItems()` call,\r\n\t\t// then don't discard those new layout values and use them instead of the ones from `state`.\r\n\t\t//\r\n\t\t// A `setItems()` call is \"pending\" when `updateState()` operation is \"asynchronous\", that is\r\n\t\t// when `updateState()` calls aren't applied immediately, like in React.\r\n\t\t//\r\n\t\tconst layout = this.newItemsWillBeRendered\r\n\t\t\t? this.newItemsWillBeRendered.layout\r\n\t\t\t: this.getState()\r\n\r\n\t\t// Update `VirtualScroller` state.\r\n\t\tconst newState = {\r\n\t\t\tscrollableContainerWidth: this.scrollableContainer.getWidth(),\r\n\r\n\t\t\t// This state update should also overwrite all the `state` properties\r\n\t\t\t// that are also updated in the \"on scroll\" handler (`getShownItemIndexes()`):\r\n\t\t\t//\r\n\t\t\t// * `firstShownItemIndex`\r\n\t\t\t// * `lastShownItemIndex`\r\n\t\t\t// * `beforeItemsHeight`\r\n\t\t\t// * `afterItemsHeight`\r\n\t\t\t//\r\n\t\t\t// That's because this `updateState()` update has a higher priority\r\n\t\t\t// than that of the \"on scroll\" handler, so it should overwrite\r\n\t\t\t// any potential state changes dispatched by the \"on scroll\" handler.\r\n\t\t\t//\r\n\t\t\t// All these properties might have changed, but they're not\r\n\t\t\t// recalculated here becase they'll be recalculated after\r\n\t\t\t// this new state is applied (rendered).\r\n\t\t\t//\r\n\t\t\tfirstShownItemIndex: layout.firstShownItemIndex,\r\n\t\t\tlastShownItemIndex: layout.lastShownItemIndex,\r\n\t\t\tbeforeItemsHeight: layout.beforeItemsHeight,\r\n\t\t\tafterItemsHeight: layout.afterItemsHeight,\r\n\r\n\t\t\t// Reset item heights, because if scrollable container's width (or height)\r\n\t\t\t// has changed, then the list width (or height) most likely also has changed,\r\n\t\t\t// and also some CSS `@media()` rules might have been added or removed.\r\n\t\t\t// So re-render the list entirely.\r\n\t\t\titemHeights: new Array(itemsCount),\r\n\r\n\t\t\tcolumnsCount: this.getActualColumnsCountForState(),\r\n\r\n\t\t\t// Re-measure vertical spacing after render because new CSS styles\r\n\t\t\t// might be applied for the new window width.\r\n\t\t\tverticalSpacing: undefined\r\n\t\t}\r\n\r\n\t\tconst { firstShownItemIndex, lastShownItemIndex } = layout\r\n\r\n\t\t// Get the `columnsCount` for the new window width.\r\n\t\tconst newColumnsCount = this.getActualColumnsCount()\r\n\r\n\t\t// Re-calculate `firstShownItemIndex` and `lastShownItemIndex`\r\n\t\t// based on the new `columnsCount` so that the whole row is visible.\r\n\t\tconst newFirstShownItemIndex = Math.floor(firstShownItemIndex / newColumnsCount) * newColumnsCount\r\n\t\tconst newLastShownItemIndex = Math.min(\r\n\t\t\tMath.ceil((lastShownItemIndex + 1) / newColumnsCount) * newColumnsCount,\r\n\t\t\titemsCount\r\n\t\t) - 1\r\n\r\n\t\t// Potentially update `firstShownItemIndex` if it needs to be adjusted in order to\r\n\t\t// correspond to the new `columnsCount`.\r\n\t\tif (newFirstShownItemIndex !== firstShownItemIndex) {\r\n\t\t\tlog('Columns Count changed from', this.getState().columnsCount || 1, 'to', newColumnsCount)\r\n\t\t\tlog('First Shown Item Index needs to change from', firstShownItemIndex, 'to', newFirstShownItemIndex)\r\n\t\t}\r\n\r\n\t\t// Always rewrite `firstShownItemIndex` and `lastShownItemIndex`\r\n\t\t// as part of the `state` update, even if it hasn't been modified.\r\n\t\t//\r\n\t\t// The reason is that there could be two subsequent `onResize()` calls:\r\n\t\t// the first one could be user resizing the window to half of its width,\r\n\t\t// resulting in an \"asynchronous\" `updateState()` call, and then, before that\r\n\t\t// `updateState()` call is applied, a second resize event happens when the user\r\n\t\t// has resized the window back to its original width, meaning that the\r\n\t\t// `columnsCount` is back to its original value.\r\n\t\t// In that case, the final `newFirstShownItemIndex` will be equal to the\r\n\t\t// original `firstShownItemIndex` that was in `state` before the user\r\n\t\t// has started resizing the window, so, in the end, `state.firstShownItemIndex`\r\n\t\t// property wouldn't have changed, but it still has to be part of the final\r\n\t\t// state update in order to overwrite the previous update of `firstShownItemIndex`\r\n\t\t// property that has been scheduled to be applied in state after the first resize\r\n\t\t// happened.\r\n\t\t//\r\n\t\tnewState.firstShownItemIndex = newFirstShownItemIndex\r\n\t\tnewState.lastShownItemIndex = newLastShownItemIndex\r\n\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\r\n\t\t// `beforeResize` is always overwritten in `state` here.\r\n\t\t// (once it has started being tracked in `state`)\r\n\t\tif (this.shouldDiscardBeforeResizeItemHeights() || newFirstShownItemIndex === 0) {\r\n\t\t\tif (this.beforeResize.shouldIncludeBeforeResizeValuesInState()) {\r\n\t\t\t\tnewState.beforeResize = undefined\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Snapshot \"before resize\" values in order to preserve the currently\r\n\t\t// shown items' vertical position on screen so that there's no \"content jumping\".\r\n\t\telse {\r\n\t\t\t// Keep \"before resize\" values in order to preserve the currently\r\n\t\t\t// shown items' vertical position on screen so that there's no\r\n\t\t\t// \"content jumping\". These \"before resize\" values will be discarded\r\n\t\t\t// when (if) the user scrolls back to the top of the list.\r\n\t\t\tnewState.beforeResize = {\r\n\t\t\t\tverticalSpacing,\r\n\t\t\t\tcolumnsCount,\r\n\t\t\t\titemHeights: this.beforeResize.snapshotBeforeResizeItemHeights({\r\n\t\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\t\tnewFirstShownItemIndex,\r\n\t\t\t\t\tnewColumnsCount\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `this.widthHasChanged` tells `VirtualScroller` that it should\r\n\t\t// temporarily stop other updates (like \"on scroll\" updates) and wait\r\n\t\t// for the new `state` to be applied, after which the `onRender()`\r\n\t\t// function will clear this flag and perform a re-layout.\r\n\t\t//\r\n\t\t// A re-layout is required because the layout parameters calculated above\r\n\t\t// are approximate ones, and the exact item heights aren't known at this point.\r\n\t\t// So the `updateState()` call below is just to re-render the `VirtualScroller`.\r\n\t\t// After it has been re-rendered, it will measure item heights and then calculate\r\n\t\t// correct layout parameters.\r\n\t\t//\r\n\t\tthis.widthHasChanged = {\r\n\t\t\tstateUpdate: newState\r\n\t\t}\r\n\r\n\t\t// Rerender.\r\n\t\tthis.updateState(newState)\r\n\t}\r\n\r\n\t// Returns whether \"before resize\" item heights should be discarded\r\n\t// as a result of calling `setItems()` with a new set of items\r\n\t// when an asynchronous `updateState()` call inside that function\r\n\t// hasn't been applied yet.\r\n\t//\r\n\t// If `setItems()` update was an \"incremental\" one and no items\r\n\t// have been prepended, then `firstShownItemIndex` is preserved,\r\n\t// and all items' heights before it should be kept in order to\r\n\t// preserve the top offset of the first shown item so that there's\r\n\t// no \"content jumping\".\r\n\t//\r\n\t// If `setItems()` update was an \"incremental\" one but there're\r\n\t// some prepended items, then it means that now there're new items\r\n\t// with unknown heights at the top, so the top offset of the first\r\n\t// shown item won't be preserved because there're no \"before resize\"\r\n\t// heights of those items.\r\n\t//\r\n\t// If `setItems()` update was not an \"incremental\" one, then don't\r\n\t// attempt to restore previous item heights after a potential window\r\n\t// width change because all item heights have been reset.\r\n\t//\r\n\tthis.shouldDiscardBeforeResizeItemHeights = () => {\r\n\t\tif (this.newItemsWillBeRendered) {\r\n\t\t\tconst { prepend, replace } = this.newItemsWillBeRendered\r\n\t\t\treturn prepend || replace\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;;AAAA;;;;AAEe,oBAAW;EAAA;;EAC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AC9DtB,mBAAmB,EAAnBA,mBAD8D;UAE9DU,sBAAsB,EAAtBA,sBAF8D;UAG9DF,eAAe,EAAfA;QAH8D,CAAlD;MAHU,CAAxB;IASA,CAzIoB,CA2IrB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;IACA,KAAI,CAACe,eAAL,GAAuB;MACtBC,WAAW,EAAE5B;IADS,CAAvB,CAtJqB,CA0JrB;;IACA,KAAI,CAAC6B,WAAL,CAAiB7B,QAAjB;EACA,CA5JD,CADyB,CA+JzB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;EACA,KAAKuB,oCAAL,GAA4C,YAAM;IACjD,IAAI,KAAI,CAAC7B,sBAAT,EAAiC;MAChC,4BAA6B,KAAI,CAACA,sBAAlC;MAAA,IAAQoC,OAAR,yBAAQA,OAAR;MAAA,IAAiBC,OAAjB,yBAAiBA,OAAjB;MACA,OAAOD,OAAO,IAAIC,OAAlB;IACA;EACD,CALD;AAMA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Resize.js","names":["debounce","log","Resize","bypass","getWidth","getHeight","listenForResize","onResizeStart","onResizeStop","onHeightChange","onWidthChange","onNoChange","isActive","prevScrollableContainerWidth","width","prevScrollableContainerHeight","height","onResize","_onResize","SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL","onStart","onStop","unlistenResize","undefined"],"sources":["../source/Resize.js"],"sourcesContent":["import debounce from './utility/debounce.js'\r\nimport log from './utility/debug.js'\r\n\r\nexport default class Resize {\r\n\tconstructor({\r\n\t\tbypass,\r\n\t\tgetWidth,\r\n\t\tgetHeight,\r\n\t\tlistenForResize,\r\n\t\tonResizeStart,\r\n\t\tonResizeStop,\r\n\t\tonHeightChange,\r\n\t\tonWidthChange,\r\n\t\tonNoChange\r\n\t}) {\r\n\t\tthis.bypass = bypass\r\n\r\n\t\tthis.onHeightChange = onHeightChange\r\n\t\tthis.onWidthChange = onWidthChange\r\n\t\tthis.onNoChange = onNoChange\r\n\r\n\t\tthis.getWidth = getWidth\r\n\t\tthis.getHeight = getHeight\r\n\t\tthis.listenForResize = listenForResize\r\n\r\n\t\tthis.onResize = debounce(\r\n\t\t\tthis._onResize,\r\n\t\t\tSCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL,\r\n\t\t\t{\r\n\t\t\t\tonStart: onResizeStart,\r\n\t\t\t\tonStop: onResizeStop\r\n\t\t\t}\r\n\t\t)\r\n\t}\r\n\r\n\tstart() {\r\n\t\tthis.isActive = true\r\n\t\tif (this.bypass) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\tthis.width = this.getWidth()\r\n\t\tthis.height = this.getHeight()\r\n\t\tthis.unlistenResize = this.listenForResize(this.onResize)\r\n\t}\r\n\r\n\tstop() {\r\n\t\tthis.isActive = false\r\n\t\tthis.width = undefined\r\n\t\tthis.height = undefined\r\n\t\tif (this.unlistenResize) {\r\n\t\t\tthis.unlistenResize()\r\n\t\t\tthis.unlistenResize = undefined\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * On scrollable container resize.\r\n\t */\r\n\t_onResize = () => {\r\n\t\t// If `VirtualScroller` has been unmounted\r\n\t\t// while `debounce()`'s `setTimeout()` was waiting, then exit.\r\n\t\t// If the `VirtualScroller` gets restarted later, it will detect\r\n\t\t// that `state.scrollableContainerWidth` doesn't match the actual\r\n\t\t// scrollable container width, and will call `this.onResize()`.\r\n\t\tif (!this.isActive) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tconst prevScrollableContainerWidth = this.width\r\n\t\tconst prevScrollableContainerHeight = this.height\r\n\r\n\t\tthis.width = this.getWidth()\r\n\t\tthis.height = this.getHeight()\r\n\r\n\t\tif (this.width === prevScrollableContainerWidth) {\r\n\t\t\tif (this.height === prevScrollableContainerHeight) {\r\n\t\t\t\t// The dimensions of the container didn't change,\r\n\t\t\t\t// so there's no need to re-layout anything.\r\n\t\t\t\tthis.onNoChange()\r\n\t\t\t} else {\r\n\t\t\t\t// Scrollable container height has changed,\r\n\t\t\t\t// so just recalculate shown item indexes.\r\n\t\t\t\t// No need to perform a re-layout from scratch.\r\n\t\t\t\tthis.onHeightChange(prevScrollableContainerHeight, this.height)\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\t// Reset item heights, because if scrollable container's width (or height)\r\n\t\t\t// has changed, then the list width (or height) most likely also has changed,\r\n\t\t\t// and also some CSS `@media()` rules might have been added or removed.\r\n\t\t\t// So re-render the list entirely.\r\n\t\t\tthis.onWidthChange(prevScrollableContainerWidth, this.width)\r\n\t\t}\r\n\t}\r\n}\r\n\r\nconst SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL = 250"],"mappings":";;;;;;;;AAAA,OAAOA,QAAP,MAAqB,uBAArB;AACA,OAAOC,GAAP,MAAgB,oBAAhB;;IAEqBC,M;EACpB,sBAUG;IAAA;;IAAA,IATFC,MASE,QATFA,MASE;IAAA,IARFC,QAQE,QARFA,QAQE;IAAA,IAPFC,SAOE,QAPFA,SAOE;IAAA,IANFC,eAME,QANFA,eAME;IAAA,IALFC,aAKE,QALFA,aAKE;IAAA,IAJFC,YAIE,QAJFA,YAIE;IAAA,IAHFC,cAGE,QAHFA,cAGE;IAAA,IAFFC,aAEE,QAFFA,aAEE;IAAA,IADFC,UACE,QADFA,UACE;;IAAA;;IAAA,mCA4CS,YAAM;MACjB;MACA;MACA;MACA;MACA;MACA,IAAI,CAAC,KAAI,CAACC,QAAV,EAAoB;QACnB;MACA;;MAED,IAAMC,4BAA4B,GAAG,KAAI,CAACC,KAA1C;MACA,IAAMC,6BAA6B,GAAG,KAAI,CAACC,MAA3C;MAEA,KAAI,CAACF,KAAL,GAAa,KAAI,CAACV,QAAL,EAAb;MACA,KAAI,CAACY,MAAL,GAAc,KAAI,CAACX,SAAL,EAAd;;MAEA,IAAI,KAAI,CAACS,KAAL,KAAeD,4BAAnB,EAAi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@@ -1 +0,0 @@
1
- {"version":3,"file":"VirtualScroller.resize.js","names":["log","onResize","previouslyCalculatedLayout","undefined","listHeightMeasurement","reset","itemsCount","newItemsWillBeRendered","count","getState","itemHeights","length","layout","newState","scrollableContainerWidth","scrollableContainer","getWidth","firstShownItemIndex","lastShownItemIndex","beforeItemsHeight","afterItemsHeight","Array","columnsCount","getActualColumnsCountForState","verticalSpacing","newColumnsCount","getActualColumnsCount","newFirstShownItemIndex","Math","floor","newLastShownItemIndex","min","ceil","getVerticalSpacing","getColumnsCount","shouldDiscardBeforeResizeItemHeights","beforeResize","shouldIncludeBeforeResizeValuesInState","snapshotBeforeResizeItemHeights","widthHasChanged","stateUpdate","updateState","prepend","replace"],"sources":["../source/VirtualScroller.resize.js"],"sourcesContent":["import log from './utility/debug.js'\r\n\r\nexport default function() {\r\n\tthis.onResize = () => {\r\n\t\t// Reset \"previously calculated layout\".\r\n\t\t//\r\n\t\t// The \"previously calculated layout\" feature is not currently used.\r\n\t\t//\r\n\t\t// The current layout snapshot could be stored as a \"previously calculated layout\" variable\r\n\t\t// so that it could theoretically be used when calculating new layout incrementally\r\n\t\t// rather than from scratch, which would be an optimization.\r\n\t\t//\r\n\t\tthis.previouslyCalculatedLayout = undefined\r\n\r\n\t\t// Cancel any potential scheduled scroll position restoration.\r\n\t\tthis.listHeightMeasurement.reset()\r\n\r\n\t\t// Get the most recent items count.\r\n\t\t// If there're a \"pending\" `setItems()` call then use the items count from that call\r\n\t\t// instead of using the count of currently shown `items` from `state`.\r\n\t\t// A `setItems()` call is \"pending\" when `updateState()` operation is \"asynchronous\", that is\r\n\t\t// when `updateState()` calls aren't applied immediately, like in React.\r\n\t\tconst itemsCount = this.newItemsWillBeRendered\r\n\t\t\t? this.newItemsWillBeRendered.count\r\n\t\t\t: this.getState().itemHeights.length\r\n\r\n\t\t// If layout values have been calculated as a result of a \"pending\" `setItems()` call,\r\n\t\t// then don't discard those new layout values and use them instead of the ones from `state`.\r\n\t\t//\r\n\t\t// A `setItems()` call is \"pending\" when `updateState()` operation is \"asynchronous\", that is\r\n\t\t// when `updateState()` calls aren't applied immediately, like in React.\r\n\t\t//\r\n\t\tconst layout = this.newItemsWillBeRendered\r\n\t\t\t? this.newItemsWillBeRendered.layout\r\n\t\t\t: this.getState()\r\n\r\n\t\t// Update `VirtualScroller` state.\r\n\t\tconst newState = {\r\n\t\t\tscrollableContainerWidth: this.scrollableContainer.getWidth(),\r\n\r\n\t\t\t// This state update should also overwrite all the `state` properties\r\n\t\t\t// that are also updated in the \"on scroll\" handler (`getShownItemIndexes()`):\r\n\t\t\t//\r\n\t\t\t// * `firstShownItemIndex`\r\n\t\t\t// * `lastShownItemIndex`\r\n\t\t\t// * `beforeItemsHeight`\r\n\t\t\t// * `afterItemsHeight`\r\n\t\t\t//\r\n\t\t\t// That's because this `updateState()` update has a higher priority\r\n\t\t\t// than that of the \"on scroll\" handler, so it should overwrite\r\n\t\t\t// any potential state changes dispatched by the \"on scroll\" handler.\r\n\t\t\t//\r\n\t\t\t// All these properties might have changed, but they're not\r\n\t\t\t// recalculated here becase they'll be recalculated after\r\n\t\t\t// this new state is applied (rendered).\r\n\t\t\t//\r\n\t\t\tfirstShownItemIndex: layout.firstShownItemIndex,\r\n\t\t\tlastShownItemIndex: layout.lastShownItemIndex,\r\n\t\t\tbeforeItemsHeight: layout.beforeItemsHeight,\r\n\t\t\tafterItemsHeight: layout.afterItemsHeight,\r\n\r\n\t\t\t// Reset item heights, because if scrollable container's width (or height)\r\n\t\t\t// has changed, then the list width (or height) most likely also has changed,\r\n\t\t\t// and also some CSS `@media()` rules might have been added or removed.\r\n\t\t\t// So re-render the list entirely.\r\n\t\t\titemHeights: new Array(itemsCount),\r\n\r\n\t\t\tcolumnsCount: this.getActualColumnsCountForState(),\r\n\r\n\t\t\t// Re-measure vertical spacing after render because new CSS styles\r\n\t\t\t// might be applied for the new window width.\r\n\t\t\tverticalSpacing: undefined\r\n\t\t}\r\n\r\n\t\tconst { firstShownItemIndex, lastShownItemIndex } = layout\r\n\r\n\t\t// Get the `columnsCount` for the new window width.\r\n\t\tconst newColumnsCount = this.getActualColumnsCount()\r\n\r\n\t\t// Re-calculate `firstShownItemIndex` and `lastShownItemIndex`\r\n\t\t// based on the new `columnsCount` so that the whole row is visible.\r\n\t\tconst newFirstShownItemIndex = Math.floor(firstShownItemIndex / newColumnsCount) * newColumnsCount\r\n\t\tconst newLastShownItemIndex = Math.min(\r\n\t\t\tMath.ceil((lastShownItemIndex + 1) / newColumnsCount) * newColumnsCount,\r\n\t\t\titemsCount\r\n\t\t) - 1\r\n\r\n\t\t// Potentially update `firstShownItemIndex` if it needs to be adjusted in order to\r\n\t\t// correspond to the new `columnsCount`.\r\n\t\tif (newFirstShownItemIndex !== firstShownItemIndex) {\r\n\t\t\tlog('Columns Count changed from', this.getState().columnsCount || 1, 'to', newColumnsCount)\r\n\t\t\tlog('First Shown Item Index needs to change from', firstShownItemIndex, 'to', newFirstShownItemIndex)\r\n\t\t}\r\n\r\n\t\t// Always rewrite `firstShownItemIndex` and `lastShownItemIndex`\r\n\t\t// as part of the `state` update, even if it hasn't been modified.\r\n\t\t//\r\n\t\t// The reason is that there could be two subsequent `onResize()` calls:\r\n\t\t// the first one could be user resizing the window to half of its width,\r\n\t\t// resulting in an \"asynchronous\" `updateState()` call, and then, before that\r\n\t\t// `updateState()` call is applied, a second resize event happens when the user\r\n\t\t// has resized the window back to its original width, meaning that the\r\n\t\t// `columnsCount` is back to its original value.\r\n\t\t// In that case, the final `newFirstShownItemIndex` will be equal to the\r\n\t\t// original `firstShownItemIndex` that was in `state` before the user\r\n\t\t// has started resizing the window, so, in the end, `state.firstShownItemIndex`\r\n\t\t// property wouldn't have changed, but it still has to be part of the final\r\n\t\t// state update in order to overwrite the previous update of `firstShownItemIndex`\r\n\t\t// property that has been scheduled to be applied in state after the first resize\r\n\t\t// happened.\r\n\t\t//\r\n\t\tnewState.firstShownItemIndex = newFirstShownItemIndex\r\n\t\tnewState.lastShownItemIndex = newLastShownItemIndex\r\n\r\n\t\tconst verticalSpacing = this.getVerticalSpacing()\r\n\t\tconst columnsCount = this.getColumnsCount()\r\n\r\n\t\t// `beforeResize` is always overwritten in `state` here.\r\n\t\t// (once it has started being tracked in `state`)\r\n\t\tif (this.shouldDiscardBeforeResizeItemHeights() || newFirstShownItemIndex === 0) {\r\n\t\t\tif (this.beforeResize.shouldIncludeBeforeResizeValuesInState()) {\r\n\t\t\t\tnewState.beforeResize = undefined\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Snapshot \"before resize\" values in order to preserve the currently\r\n\t\t// shown items' vertical position on screen so that there's no \"content jumping\".\r\n\t\telse {\r\n\t\t\t// Keep \"before resize\" values in order to preserve the currently\r\n\t\t\t// shown items' vertical position on screen so that there's no\r\n\t\t\t// \"content jumping\". These \"before resize\" values will be discarded\r\n\t\t\t// when (if) the user scrolls back to the top of the list.\r\n\t\t\tnewState.beforeResize = {\r\n\t\t\t\tverticalSpacing,\r\n\t\t\t\tcolumnsCount,\r\n\t\t\t\titemHeights: this.beforeResize.snapshotBeforeResizeItemHeights({\r\n\t\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\t\tnewFirstShownItemIndex,\r\n\t\t\t\t\tnewColumnsCount\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `this.widthHasChanged` tells `VirtualScroller` that it should\r\n\t\t// temporarily stop other updates (like \"on scroll\" updates) and wait\r\n\t\t// for the new `state` to be applied, after which the `onRender()`\r\n\t\t// function will clear this flag and perform a re-layout.\r\n\t\t//\r\n\t\t// A re-layout is required because the layout parameters calculated above\r\n\t\t// are approximate ones, and the exact item heights aren't known at this point.\r\n\t\t// So the `updateState()` call below is just to re-render the `VirtualScroller`.\r\n\t\t// After it has been re-rendered, it will measure item heights and then calculate\r\n\t\t// correct layout parameters.\r\n\t\t//\r\n\t\tthis.widthHasChanged = {\r\n\t\t\tstateUpdate: newState\r\n\t\t}\r\n\r\n\t\t// Rerender.\r\n\t\tthis.updateState(newState)\r\n\t}\r\n\r\n\t// Returns whether \"before resize\" item heights should be discarded\r\n\t// as a result of calling `setItems()` with a new set of items\r\n\t// when an asynchronous `updateState()` call inside that function\r\n\t// hasn't been applied yet.\r\n\t//\r\n\t// If `setItems()` update was an \"incremental\" one and no items\r\n\t// have been prepended, then `firstShownItemIndex` is preserved,\r\n\t// and all items' heights before it should be kept in order to\r\n\t// preserve the top offset of the first shown item so that there's\r\n\t// no \"content jumping\".\r\n\t//\r\n\t// If `setItems()` update was an \"incremental\" one but there're\r\n\t// some prepended items, then it means that now there're new items\r\n\t// with unknown heights at the top, so the top offset of the first\r\n\t// shown item won't be preserved because there're no \"before resize\"\r\n\t// heights of those items.\r\n\t//\r\n\t// If `setItems()` update was not an \"incremental\" one, then don't\r\n\t// attempt to restore previous item heights after a potential window\r\n\t// width change because all item heights have been reset.\r\n\t//\r\n\tthis.shouldDiscardBeforeResizeItemHeights = () => {\r\n\t\tif (this.newItemsWillBeRendered) {\r\n\t\t\tconst { prepend, replace } = this.newItemsWillBeRendered\r\n\t\t\treturn prepend || replace\r\n\t\t}\r\n\t}\r\n}"],"mappings":"AAAA,OAAOA,GAAP,MAAgB,oBAAhB;AAEA,eAAe,YAAW;EAAA;;EACzB,KAAKC,QAAL,GAAgB,YAAM;IACrB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,KAAI,CAACC,0BAAL,GAAkCC,SAAlC,CATqB,CAWrB;;IACA,KAAI,CAACC,qBAAL,CAA2BC,KAA3B,GAZqB,CAcrB;IACA;IACA;IACA;IACA;;;IACA,IAAMC,UAAU,GAAG,KAAI,CAACC,sBAAL,GAChB,KAAI,CAACA,sBAAL,CAA4BC,KADZ,GAEhB,KAAI,CAACC,QAAL,GAAgBC,WAAhB,CAA4BC,MAF/B,CAnBqB,CAuBrB;IACA;IACA;IACA;IACA;IACA;;IACA,IAAMC,MAAM,GAAG,KAAI,CAACL,sBAAL,GACZ,KAAI,CAACA,sBAAL,CAA4BK,MAD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