virtual-scroller 1.7.9 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/.gitlab-ci.yml +1 -1
  2. package/CHANGELOG.md +71 -1
  3. package/README.md +434 -151
  4. package/bundle/index-bypass.html +1 -1
  5. package/bundle/index-dom.html +1 -1
  6. package/bundle/index-grid.html +1 -2
  7. package/bundle/index-scrollableContainer.html +1 -1
  8. package/bundle/index-tbody-scrollableContainer.html +2 -0
  9. package/bundle/index-tbody.html +2 -0
  10. package/bundle/virtual-scroller-dom.js +1 -1
  11. package/bundle/virtual-scroller-dom.js.map +1 -1
  12. package/bundle/virtual-scroller-react.js +1 -1
  13. package/bundle/virtual-scroller-react.js.map +1 -1
  14. package/bundle/virtual-scroller.js +1 -1
  15. package/bundle/virtual-scroller.js.map +1 -1
  16. package/commonjs/BeforeResize.js +315 -0
  17. package/commonjs/BeforeResize.js.map +1 -0
  18. package/commonjs/DOM/Engine.js +46 -0
  19. package/commonjs/DOM/Engine.js.map +1 -0
  20. package/commonjs/DOM/ItemsContainer.js +78 -0
  21. package/commonjs/DOM/ItemsContainer.js.map +1 -0
  22. package/commonjs/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +71 -44
  23. package/commonjs/DOM/ListTopOffsetWatcher.js.map +1 -0
  24. package/commonjs/DOM/ScrollableContainer.js +69 -101
  25. package/commonjs/DOM/ScrollableContainer.js.map +1 -1
  26. package/commonjs/DOM/VirtualScroller.js +37 -29
  27. package/commonjs/DOM/VirtualScroller.js.map +1 -1
  28. package/commonjs/DOM/tbody.js +17 -11
  29. package/commonjs/DOM/tbody.js.map +1 -1
  30. package/commonjs/ItemHeights.js +33 -34
  31. package/commonjs/ItemHeights.js.map +1 -1
  32. package/commonjs/Layout.js +591 -216
  33. package/commonjs/Layout.js.map +1 -1
  34. package/commonjs/Layout.test.js +196 -0
  35. package/commonjs/Layout.test.js.map +1 -0
  36. package/commonjs/ListHeightMeasurement.js +124 -0
  37. package/commonjs/ListHeightMeasurement.js.map +1 -0
  38. package/commonjs/Resize.js +50 -39
  39. package/commonjs/Resize.js.map +1 -1
  40. package/commonjs/Scroll.js +139 -95
  41. package/commonjs/Scroll.js.map +1 -1
  42. package/commonjs/VirtualScroller.columns.js +43 -0
  43. package/commonjs/VirtualScroller.columns.js.map +1 -0
  44. package/commonjs/VirtualScroller.constructor.js +408 -0
  45. package/commonjs/VirtualScroller.constructor.js.map +1 -0
  46. package/commonjs/VirtualScroller.items.js +305 -0
  47. package/commonjs/VirtualScroller.items.js.map +1 -0
  48. package/commonjs/VirtualScroller.js +160 -1021
  49. package/commonjs/VirtualScroller.js.map +1 -1
  50. package/commonjs/VirtualScroller.layout.js +562 -0
  51. package/commonjs/VirtualScroller.layout.js.map +1 -0
  52. package/commonjs/VirtualScroller.onRender.js +357 -0
  53. package/commonjs/VirtualScroller.onRender.js.map +1 -0
  54. package/commonjs/VirtualScroller.resize.js +186 -0
  55. package/commonjs/VirtualScroller.resize.js.map +1 -0
  56. package/commonjs/VirtualScroller.state.js +301 -0
  57. package/commonjs/VirtualScroller.state.js.map +1 -0
  58. package/commonjs/VirtualScroller.verticalSpacing.js +65 -0
  59. package/commonjs/VirtualScroller.verticalSpacing.js.map +1 -0
  60. package/commonjs/getItemCoordinates.js.map +1 -1
  61. package/commonjs/getItemsDiff.js.map +1 -1
  62. package/commonjs/getVerticalSpacing.js +8 -8
  63. package/commonjs/getVerticalSpacing.js.map +1 -1
  64. package/commonjs/package.json +5 -0
  65. package/commonjs/react/VirtualScroller.js +182 -628
  66. package/commonjs/react/VirtualScroller.js.map +1 -1
  67. package/commonjs/react/useClassName.js +26 -0
  68. package/commonjs/react/useClassName.js.map +1 -0
  69. package/commonjs/react/useHandleItemsChange.js +116 -0
  70. package/commonjs/react/useHandleItemsChange.js.map +1 -0
  71. package/commonjs/react/useInstanceMethods.js +37 -0
  72. package/commonjs/react/useInstanceMethods.js.map +1 -0
  73. package/commonjs/react/useItemKeys.js +60 -0
  74. package/commonjs/react/useItemKeys.js.map +1 -0
  75. package/commonjs/react/useOnItemHeightChange.js +32 -0
  76. package/commonjs/react/useOnItemHeightChange.js.map +1 -0
  77. package/commonjs/react/useOnItemStateChange.js +32 -0
  78. package/commonjs/react/useOnItemStateChange.js.map +1 -0
  79. package/commonjs/react/useState.js +140 -0
  80. package/commonjs/react/useState.js.map +1 -0
  81. package/commonjs/react/useStyle.js +29 -0
  82. package/commonjs/react/useStyle.js.map +1 -0
  83. package/commonjs/react/useVirtualScroller.js +62 -0
  84. package/commonjs/react/useVirtualScroller.js.map +1 -0
  85. package/commonjs/react/useVirtualScrollerStartStop.js +20 -0
  86. package/commonjs/react/useVirtualScrollerStartStop.js.map +1 -0
  87. package/commonjs/test/Engine.js +23 -0
  88. package/commonjs/test/Engine.js.map +1 -0
  89. package/commonjs/test/ItemsContainer.js +127 -0
  90. package/commonjs/test/ItemsContainer.js.map +1 -0
  91. package/commonjs/test/ScrollableContainer.js +130 -0
  92. package/commonjs/test/ScrollableContainer.js.map +1 -0
  93. package/commonjs/test/VirtualScroller.js +281 -0
  94. package/commonjs/test/VirtualScroller.js.map +1 -0
  95. package/commonjs/utility/debounce.js +28 -6
  96. package/commonjs/utility/debounce.js.map +1 -1
  97. package/commonjs/utility/debug.js +51 -12
  98. package/commonjs/utility/debug.js.map +1 -1
  99. package/commonjs/utility/getStateSnapshot.js +50 -0
  100. package/commonjs/utility/getStateSnapshot.js.map +1 -0
  101. package/commonjs/utility/px.js +1 -1
  102. package/commonjs/utility/px.js.map +1 -1
  103. package/commonjs/utility/px.test.js +14 -0
  104. package/commonjs/utility/px.test.js.map +1 -0
  105. package/commonjs/utility/shallowEqual.js +1 -1
  106. package/commonjs/utility/shallowEqual.js.map +1 -1
  107. package/commonjs/utility/throttle.js.map +1 -1
  108. package/dom/index.cjs +4 -0
  109. package/dom/index.cjs.js +9 -0
  110. package/dom/index.d.ts +25 -0
  111. package/dom/index.js +1 -1
  112. package/dom/package.json +10 -4
  113. package/index.cjs +4 -0
  114. package/index.cjs.js +9 -0
  115. package/index.d.ts +99 -0
  116. package/index.js +1 -1
  117. package/modules/BeforeResize.js +305 -0
  118. package/modules/BeforeResize.js.map +1 -0
  119. package/modules/DOM/Engine.js +27 -0
  120. package/modules/DOM/Engine.js.map +1 -0
  121. package/modules/DOM/ItemsContainer.js +71 -0
  122. package/modules/DOM/ItemsContainer.js.map +1 -0
  123. package/modules/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +72 -44
  124. package/modules/DOM/ListTopOffsetWatcher.js.map +1 -0
  125. package/modules/DOM/ScrollableContainer.js +68 -100
  126. package/modules/DOM/ScrollableContainer.js.map +1 -1
  127. package/modules/DOM/VirtualScroller.js +32 -28
  128. package/modules/DOM/VirtualScroller.js.map +1 -1
  129. package/modules/DOM/tbody.js +11 -9
  130. package/modules/DOM/tbody.js.map +1 -1
  131. package/modules/ItemHeights.js +28 -33
  132. package/modules/ItemHeights.js.map +1 -1
  133. package/modules/Layout.js +585 -214
  134. package/modules/Layout.js.map +1 -1
  135. package/modules/Layout.test.js +190 -0
  136. package/modules/Layout.test.js.map +1 -0
  137. package/modules/ListHeightMeasurement.js +117 -0
  138. package/modules/ListHeightMeasurement.js.map +1 -0
  139. package/modules/Resize.js +50 -39
  140. package/modules/Resize.js.map +1 -1
  141. package/modules/Scroll.js +139 -94
  142. package/modules/Scroll.js.map +1 -1
  143. package/modules/VirtualScroller.columns.js +36 -0
  144. package/modules/VirtualScroller.columns.js.map +1 -0
  145. package/modules/VirtualScroller.constructor.js +371 -0
  146. package/modules/VirtualScroller.constructor.js.map +1 -0
  147. package/modules/VirtualScroller.items.js +288 -0
  148. package/modules/VirtualScroller.items.js.map +1 -0
  149. package/modules/VirtualScroller.js +159 -1014
  150. package/modules/VirtualScroller.js.map +1 -1
  151. package/modules/VirtualScroller.layout.js +549 -0
  152. package/modules/VirtualScroller.layout.js.map +1 -0
  153. package/modules/VirtualScroller.onRender.js +337 -0
  154. package/modules/VirtualScroller.onRender.js.map +1 -0
  155. package/modules/VirtualScroller.resize.js +176 -0
  156. package/modules/VirtualScroller.resize.js.map +1 -0
  157. package/modules/VirtualScroller.state.js +283 -0
  158. package/modules/VirtualScroller.state.js.map +1 -0
  159. package/modules/VirtualScroller.verticalSpacing.js +54 -0
  160. package/modules/VirtualScroller.verticalSpacing.js.map +1 -0
  161. package/modules/getItemCoordinates.js.map +1 -1
  162. package/modules/getItemsDiff.js.map +1 -1
  163. package/modules/getVerticalSpacing.js +8 -8
  164. package/modules/getVerticalSpacing.js.map +1 -1
  165. package/modules/react/VirtualScroller.js +179 -634
  166. package/modules/react/VirtualScroller.js.map +1 -1
  167. package/modules/react/useClassName.js +18 -0
  168. package/modules/react/useClassName.js.map +1 -0
  169. package/modules/react/useHandleItemsChange.js +108 -0
  170. package/modules/react/useHandleItemsChange.js.map +1 -0
  171. package/modules/react/useInstanceMethods.js +28 -0
  172. package/modules/react/useInstanceMethods.js.map +1 -0
  173. package/modules/react/useItemKeys.js +52 -0
  174. package/modules/react/useItemKeys.js.map +1 -0
  175. package/modules/react/useOnItemHeightChange.js +24 -0
  176. package/modules/react/useOnItemHeightChange.js.map +1 -0
  177. package/modules/react/useOnItemStateChange.js +24 -0
  178. package/modules/react/useOnItemStateChange.js.map +1 -0
  179. package/modules/react/useState.js +132 -0
  180. package/modules/react/useState.js.map +1 -0
  181. package/modules/react/useStyle.js +19 -0
  182. package/modules/react/useStyle.js.map +1 -0
  183. package/modules/react/useVirtualScroller.js +51 -0
  184. package/modules/react/useVirtualScroller.js.map +1 -0
  185. package/modules/react/useVirtualScrollerStartStop.js +12 -0
  186. package/modules/react/useVirtualScrollerStartStop.js.map +1 -0
  187. package/modules/test/Engine.js +11 -0
  188. package/modules/test/Engine.js.map +1 -0
  189. package/modules/test/ItemsContainer.js +120 -0
  190. package/modules/test/ItemsContainer.js.map +1 -0
  191. package/modules/test/ScrollableContainer.js +123 -0
  192. package/modules/test/ScrollableContainer.js.map +1 -0
  193. package/modules/test/VirtualScroller.js +270 -0
  194. package/modules/test/VirtualScroller.js.map +1 -0
  195. package/modules/utility/debounce.js +28 -6
  196. package/modules/utility/debounce.js.map +1 -1
  197. package/modules/utility/debug.js +47 -10
  198. package/modules/utility/debug.js.map +1 -1
  199. package/modules/utility/getStateSnapshot.js +43 -0
  200. package/modules/utility/getStateSnapshot.js.map +1 -0
  201. package/modules/utility/px.js +1 -1
  202. package/modules/utility/px.js.map +1 -1
  203. package/modules/utility/px.test.js +9 -0
  204. package/modules/utility/px.test.js.map +1 -0
  205. package/modules/utility/shallowEqual.js +1 -1
  206. package/modules/utility/shallowEqual.js.map +1 -1
  207. package/modules/utility/throttle.js.map +1 -1
  208. package/package.json +54 -29
  209. package/react/index.cjs +4 -0
  210. package/react/index.cjs.js +9 -0
  211. package/react/index.d.ts +28 -0
  212. package/react/index.js +1 -1
  213. package/react/package.json +10 -4
  214. package/rollup.config.mjs +62 -0
  215. package/runnable/create-commonjs-package-json.js +11 -0
  216. package/source/BeforeResize.js +312 -0
  217. package/source/DOM/Engine.js +30 -0
  218. package/source/DOM/ItemsContainer.js +48 -0
  219. package/source/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +61 -30
  220. package/source/DOM/ScrollableContainer.js +51 -73
  221. package/source/DOM/VirtualScroller.js +33 -18
  222. package/source/DOM/tbody.js +30 -21
  223. package/source/ItemHeights.js +27 -27
  224. package/source/Layout.js +629 -252
  225. package/source/Layout.test.js +176 -0
  226. package/source/ListHeightMeasurement.js +95 -0
  227. package/source/Resize.js +56 -32
  228. package/source/Scroll.js +135 -82
  229. package/source/VirtualScroller.columns.js +26 -0
  230. package/source/VirtualScroller.constructor.js +336 -0
  231. package/source/VirtualScroller.items.js +302 -0
  232. package/source/VirtualScroller.js +162 -936
  233. package/source/VirtualScroller.layout.js +539 -0
  234. package/source/VirtualScroller.onRender.js +345 -0
  235. package/source/VirtualScroller.resize.js +189 -0
  236. package/source/VirtualScroller.state.js +284 -0
  237. package/source/VirtualScroller.verticalSpacing.js +51 -0
  238. package/source/getVerticalSpacing.js +7 -7
  239. package/source/react/VirtualScroller.js +243 -603
  240. package/source/react/useClassName.js +14 -0
  241. package/source/react/useHandleItemsChange.js +115 -0
  242. package/source/react/useInstanceMethods.js +25 -0
  243. package/source/react/useItemKeys.js +59 -0
  244. package/source/react/useOnItemHeightChange.js +28 -0
  245. package/source/react/useOnItemStateChange.js +28 -0
  246. package/source/react/useState.js +114 -0
  247. package/source/react/useStyle.js +20 -0
  248. package/source/react/useVirtualScroller.js +59 -0
  249. package/source/react/useVirtualScrollerStartStop.js +12 -0
  250. package/source/test/Engine.js +11 -0
  251. package/source/test/ItemsContainer.js +87 -0
  252. package/source/test/ScrollableContainer.js +88 -0
  253. package/source/test/VirtualScroller.js +232 -0
  254. package/source/utility/debounce.js +22 -5
  255. package/source/utility/debug.js +34 -3
  256. package/source/utility/getStateSnapshot.js +36 -0
  257. package/source/utility/px.js +1 -1
  258. package/source/utility/px.test.js +9 -0
  259. package/website/index-bypass.html +195 -0
  260. package/website/index-grid.html +0 -1
  261. package/website/index-scrollableContainer.html +208 -0
  262. package/website/index-tbody-scrollableContainer.html +68 -0
  263. package/website/index-tbody.html +55 -0
  264. package/commonjs/DOM/RenderingEngine.js +0 -33
  265. package/commonjs/DOM/RenderingEngine.js.map +0 -1
  266. package/commonjs/DOM/Screen.js +0 -87
  267. package/commonjs/DOM/Screen.js.map +0 -1
  268. package/commonjs/DOM/WaitForStylesToLoad.js.map +0 -1
  269. package/commonjs/RestoreScroll.js +0 -118
  270. package/commonjs/RestoreScroll.js.map +0 -1
  271. package/dom/index.commonjs.js +0 -4
  272. package/index.commonjs.js +0 -4
  273. package/modules/DOM/RenderingEngine.js +0 -19
  274. package/modules/DOM/RenderingEngine.js.map +0 -1
  275. package/modules/DOM/Screen.js +0 -80
  276. package/modules/DOM/Screen.js.map +0 -1
  277. package/modules/DOM/WaitForStylesToLoad.js.map +0 -1
  278. package/modules/RestoreScroll.js +0 -111
  279. package/modules/RestoreScroll.js.map +0 -1
  280. package/react/index.commonjs.js +0 -4
  281. package/source/DOM/RenderingEngine.js +0 -22
  282. package/source/DOM/Screen.js +0 -51
  283. package/source/RestoreScroll.js +0 -86
package/modules/Resize.js CHANGED
@@ -2,89 +2,100 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
2
2
 
3
3
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4
4
 
5
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
6
 
7
7
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
8
 
9
- import { LAYOUT_REASON } from './Layout';
10
- import debounce from './utility/debounce';
9
+ import debounce from './utility/debounce.js';
10
+ import log from './utility/debug.js';
11
11
 
12
- var Resize =
13
- /*#__PURE__*/
14
- function () {
12
+ var Resize = /*#__PURE__*/function () {
15
13
  function Resize(_ref) {
16
14
  var _this = this;
17
15
 
18
16
  var bypass = _ref.bypass,
19
- scrollableContainer = _ref.scrollableContainer,
20
- getContainerElement = _ref.getContainerElement,
21
- updateLayout = _ref.updateLayout,
22
- resetStateAndLayout = _ref.resetStateAndLayout;
17
+ getWidth = _ref.getWidth,
18
+ getHeight = _ref.getHeight,
19
+ listenForResize = _ref.listenForResize,
20
+ onResizeStart = _ref.onResizeStart,
21
+ onResizeStop = _ref.onResizeStop,
22
+ onHeightChange = _ref.onHeightChange,
23
+ onWidthChange = _ref.onWidthChange,
24
+ onNoChange = _ref.onNoChange;
23
25
 
24
26
  _classCallCheck(this, Resize);
25
27
 
26
- _defineProperty(this, "onResize", debounce(function () {
28
+ _defineProperty(this, "_onResize", function () {
27
29
  // If `VirtualScroller` has been unmounted
28
30
  // while `debounce()`'s `setTimeout()` was waiting, then exit.
29
- if (!_this.isRendered) {
31
+ // If the `VirtualScroller` gets restarted later, it will detect
32
+ // that `state.scrollableContainerWidth` doesn't match the actual
33
+ // scrollable container width, and will call `this.onResize()`.
34
+ if (!_this.isActive) {
30
35
  return;
31
36
  }
32
37
 
33
- var prevScrollableContainerWidth = _this.scrollableContainerWidth;
34
- var prevScrollableContainerHeight = _this.scrollableContainerHeight;
35
- _this.scrollableContainerWidth = _this.scrollableContainer.getWidth();
36
- _this.scrollableContainerHeight = _this.scrollableContainer.getHeight();
38
+ var prevScrollableContainerWidth = _this.width;
39
+ var prevScrollableContainerHeight = _this.height;
40
+ _this.width = _this.getWidth();
41
+ _this.height = _this.getHeight();
37
42
 
38
- if (_this.scrollableContainerWidth === prevScrollableContainerWidth) {
39
- if (_this.scrollableContainerHeight === prevScrollableContainerHeight) {
43
+ if (_this.width === prevScrollableContainerWidth) {
44
+ if (_this.height === prevScrollableContainerHeight) {
40
45
  // The dimensions of the container didn't change,
41
46
  // so there's no need to re-layout anything.
42
- return;
47
+ _this.onNoChange();
43
48
  } else {
44
49
  // Scrollable container height has changed,
45
50
  // so just recalculate shown item indexes.
46
51
  // No need to perform a re-layout from scratch.
47
- _this.updateLayout({
48
- reason: LAYOUT_REASON.RESIZE
49
- });
52
+ _this.onHeightChange(prevScrollableContainerHeight, _this.height);
50
53
  }
51
54
  } else {
52
55
  // Reset item heights, because if scrollable container's width (or height)
53
56
  // has changed, then the list width (or height) most likely also has changed,
54
57
  // and also some CSS `@media()` rules might have been added or removed.
55
58
  // So re-render the list entirely.
56
- _this.resetStateAndLayout();
59
+ _this.onWidthChange(prevScrollableContainerWidth, _this.width);
57
60
  }
58
- }, SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL));
61
+ });
59
62
 
60
63
  this.bypass = bypass;
61
- this.scrollableContainer = scrollableContainer;
62
- this.getContainerElement = getContainerElement;
63
- this.updateLayout = updateLayout;
64
- this.resetStateAndLayout = resetStateAndLayout;
64
+ this.onHeightChange = onHeightChange;
65
+ this.onWidthChange = onWidthChange;
66
+ this.onNoChange = onNoChange;
67
+ this.getWidth = getWidth;
68
+ this.getHeight = getHeight;
69
+ this.listenForResize = listenForResize;
70
+ this.onResize = debounce(this._onResize, SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL, {
71
+ onStart: onResizeStart,
72
+ onStop: onResizeStop
73
+ });
65
74
  }
66
75
 
67
76
  _createClass(Resize, [{
68
- key: "listen",
69
- value: function listen() {
77
+ key: "start",
78
+ value: function start() {
79
+ this.isActive = true;
80
+
70
81
  if (this.bypass) {
71
82
  return;
72
83
  }
73
84
 
74
- this.isRendered = true;
75
- this.scrollableContainerWidth = this.scrollableContainer.getWidth();
76
- this.scrollableContainerHeight = this.scrollableContainer.getHeight();
77
- this.scrollableContainerUnlistenResize = this.scrollableContainer.onResize(this.onResize, {
78
- container: this.getContainerElement()
79
- });
85
+ this.width = this.getWidth();
86
+ this.height = this.getHeight();
87
+ this.unlistenResize = this.listenForResize(this.onResize);
80
88
  }
81
89
  }, {
82
90
  key: "stop",
83
91
  value: function stop() {
84
- this.isRendered = false;
92
+ this.isActive = false;
93
+ this.width = undefined;
94
+ this.height = undefined;
85
95
 
86
- if (this.scrollableContainerUnlistenResize) {
87
- this.scrollableContainerUnlistenResize();
96
+ if (this.unlistenResize) {
97
+ this.unlistenResize();
98
+ this.unlistenResize = undefined;
88
99
  }
89
100
  }
90
101
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../source/Resize.js"],"names":["LAYOUT_REASON","debounce","Resize","bypass","scrollableContainer","getContainerElement","updateLayout","resetStateAndLayout","isRendered","prevScrollableContainerWidth","scrollableContainerWidth","prevScrollableContainerHeight","scrollableContainerHeight","getWidth","getHeight","reason","RESIZE","SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL","scrollableContainerUnlistenResize","onResize","container"],"mappings":";;;;;;;;AAAA,SAASA,aAAT,QAA8B,UAA9B;AACA,OAAOC,QAAP,MAAqB,oBAArB;;IAEqBC,M;;;AACpB,wBAMG;AAAA;;AAAA,QALFC,MAKE,QALFA,MAKE;AAAA,QAJFC,mBAIE,QAJFA,mBAIE;AAAA,QAHFC,mBAGE,QAHFA,mBAGE;AAAA,QAFFC,YAEE,QAFFA,YAEE;AAAA,QADFC,mBACE,QADFA,mBACE;;AAAA;;AAAA,sCA8BQN,QAAQ,CAAC,YAAM;AACzB;AACA;AACA,UAAI,CAAC,KAAI,CAACO,UAAV,EAAsB;AACrB;AACA;;AACD,UAAMC,4BAA4B,GAAG,KAAI,CAACC,wBAA1C;AACA,UAAMC,6BAA6B,GAAG,KAAI,CAACC,yBAA3C;AACA,MAAA,KAAI,CAACF,wBAAL,GAAgC,KAAI,CAACN,mBAAL,CAAyBS,QAAzB,EAAhC;AACA,MAAA,KAAI,CAACD,yBAAL,GAAiC,KAAI,CAACR,mBAAL,CAAyBU,SAAzB,EAAjC;;AACA,UAAI,KAAI,CAACJ,wBAAL,KAAkCD,4BAAtC,EAAoE;AACnE,YAAI,KAAI,CAACG,yBAAL,KAAmCD,6BAAvC,EAAsE;AACrE;AACA;AACA;AACA,SAJD,MAIO;AACN;AACA;AACA;AACA,UAAA,KAAI,CAACL,YAAL,CAAkB;AAAES,YAAAA,MAAM,EAAEf,aAAa,CAACgB;AAAxB,WAAlB;AACA;AACD,OAXD,MAWO;AACN;AACA;AACA;AACA;AACA,QAAA,KAAI,CAACT,mBAAL;AACA;AACD,KA5BkB,EA4BhBU,6CA5BgB,CA9BhB;;AACF,SAAKd,MAAL,GAAcA,MAAd;AACA,SAAKC,mBAAL,GAA2BA,mBAA3B;AACA,SAAKC,mBAAL,GAA2BA,mBAA3B;AACA,SAAKC,YAAL,GAAoBA,YAApB;AACA,SAAKC,mBAAL,GAA2BA,mBAA3B;AACA;;;;6BAEQ;AACR,UAAI,KAAKJ,MAAT,EAAiB;AAChB;AACA;;AACD,WAAKK,UAAL,GAAkB,IAAlB;AACA,WAAKE,wBAAL,GAAgC,KAAKN,mBAAL,CAAyBS,QAAzB,EAAhC;AACA,WAAKD,yBAAL,GAAiC,KAAKR,mBAAL,CAAyBU,SAAzB,EAAjC;AACA,WAAKI,iCAAL,GAAyC,KAAKd,mBAAL,CAAyBe,QAAzB,CAAkC,KAAKA,QAAvC,EAAiD;AACzFC,QAAAA,SAAS,EAAE,KAAKf,mBAAL;AAD8E,OAAjD,CAAzC;AAGA;;;2BAEM;AACN,WAAKG,UAAL,GAAkB,KAAlB;;AACA,UAAI,KAAKU,iCAAT,EAA4C;AAC3C,aAAKA,iCAAL;AACA;AACD;AAED;;;;;;;;;SAlCoBhB,M;AAoErB,IAAMe,6CAA6C,GAAG,GAAtD","sourcesContent":["import { LAYOUT_REASON } from './Layout'\r\nimport debounce from './utility/debounce'\r\n\r\nexport default class Resize {\r\n\tconstructor({\r\n\t\tbypass,\r\n\t\tscrollableContainer,\r\n\t\tgetContainerElement,\r\n\t\tupdateLayout,\r\n\t\tresetStateAndLayout\r\n\t}) {\r\n\t\tthis.bypass = bypass\r\n\t\tthis.scrollableContainer = scrollableContainer\r\n\t\tthis.getContainerElement = getContainerElement\r\n\t\tthis.updateLayout = updateLayout\r\n\t\tthis.resetStateAndLayout = resetStateAndLayout\r\n\t}\r\n\r\n\tlisten() {\r\n\t\tif (this.bypass) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\tthis.isRendered = true\r\n\t\tthis.scrollableContainerWidth = this.scrollableContainer.getWidth()\r\n\t\tthis.scrollableContainerHeight = this.scrollableContainer.getHeight()\r\n\t\tthis.scrollableContainerUnlistenResize = this.scrollableContainer.onResize(this.onResize, {\r\n\t\t\tcontainer: this.getContainerElement()\r\n\t\t})\r\n\t}\r\n\r\n\tstop() {\r\n\t\tthis.isRendered = false\r\n\t\tif (this.scrollableContainerUnlistenResize) {\r\n\t\t\tthis.scrollableContainerUnlistenResize()\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * On scrollable container resize.\r\n\t */\r\n\tonResize = debounce(() => {\r\n\t\t// If `VirtualScroller` has been unmounted\r\n\t\t// while `debounce()`'s `setTimeout()` was waiting, then exit.\r\n\t\tif (!this.isRendered) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\tconst prevScrollableContainerWidth = this.scrollableContainerWidth\r\n\t\tconst prevScrollableContainerHeight = this.scrollableContainerHeight\r\n\t\tthis.scrollableContainerWidth = this.scrollableContainer.getWidth()\r\n\t\tthis.scrollableContainerHeight = this.scrollableContainer.getHeight()\r\n\t\tif (this.scrollableContainerWidth === prevScrollableContainerWidth) {\r\n\t\t\tif (this.scrollableContainerHeight === 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\treturn\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.updateLayout({ reason: LAYOUT_REASON.RESIZE })\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.resetStateAndLayout()\r\n\t\t}\r\n\t}, SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL)\r\n}\r\n\r\nconst SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL = 250"],"file":"Resize.js"}
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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;MACP,KAAKI,QAAL,GAAgB,IAAhB;;MACA,IAAI,KAAKT,MAAT,EAAiB;QAChB;MACA;;MACD,KAAKW,KAAL,GAAa,KAAKV,QAAL,EAAb;MACA,KAAKY,MAAL,GAAc,KAAKX,SAAL,EAAd;MACA,KAAKiB,cAAL,GAAsB,KAAKhB,eAAL,CAAqB,KAAKW,QAA1B,CAAtB;IACA;;;WAED,gBAAO;MACN,KAAKL,QAAL,GAAgB,KAAhB;MACA,KAAKE,KAAL,GAAaS,SAAb;MACA,KAAKP,MAAL,GAAcO,SAAd;;MACA,IAAI,KAAKD,cAAT,EAAyB;QACxB,KAAKA,cAAL;QACA,KAAKA,cAAL,GAAsBC,SAAtB;MACA;IACD;IAED;AACD;AACA;;;;;;;SAtDqBrB,M;AA4FrB,IAAMiB,6CAA6C,GAAG,GAAtD"}
package/modules/Scroll.js CHANGED
@@ -2,7 +2,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
2
2
 
3
3
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4
4
 
5
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
6
 
7
7
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
8
 
@@ -11,178 +11,223 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
11
11
  // Replacing `setTimeout()` with `requestAnimationFrame()` can work around that Chrome bug.
12
12
  // https://github.com/bvaughn/react-virtualized/issues/722
13
13
  import { setTimeout, clearTimeout } from 'request-animation-frame-timeout';
14
- import { LAYOUT_REASON } from './Layout';
15
- import log from './utility/debug';
14
+ import log from './utility/debug.js';
16
15
 
17
- var Scroll =
18
- /*#__PURE__*/
19
- function () {
16
+ var Scroll = /*#__PURE__*/function () {
20
17
  function Scroll(_ref) {
21
18
  var _this = this;
22
19
 
23
20
  var bypass = _ref.bypass,
24
21
  scrollableContainer = _ref.scrollableContainer,
25
- updateLayout = _ref.updateLayout,
22
+ itemsContainer = _ref.itemsContainer,
23
+ onScroll = _ref.onScroll,
26
24
  initialScrollPosition = _ref.initialScrollPosition,
27
25
  onScrollPositionChange = _ref.onScrollPositionChange,
28
26
  isImmediateLayoutScheduled = _ref.isImmediateLayoutScheduled,
29
27
  hasNonRenderedItemsAtTheTop = _ref.hasNonRenderedItemsAtTheTop,
30
28
  hasNonRenderedItemsAtTheBottom = _ref.hasNonRenderedItemsAtTheBottom,
31
- getLatestLayoutVisibleAreaIncludingMargins = _ref.getLatestLayoutVisibleAreaIncludingMargins,
32
- preserveScrollPositionOfTheBottomOfTheListOnMount = _ref.preserveScrollPositionOfTheBottomOfTheListOnMount;
29
+ getLatestLayoutVisibleArea = _ref.getLatestLayoutVisibleArea,
30
+ getListTopOffset = _ref.getListTopOffset,
31
+ getPrerenderMargin = _ref.getPrerenderMargin,
32
+ onScrolledToTop = _ref.onScrolledToTop,
33
+ waitForScrollingToStop = _ref.waitForScrollingToStop;
33
34
 
34
35
  _classCallCheck(this, Scroll);
35
36
 
36
- _defineProperty(this, "updateScrollPosition", function () {
37
- _this.onScrollPositionChange(_this.getScrollY());
37
+ _defineProperty(this, "scrollByY", function (scrollByY) {
38
+ _this.scrollToY(_this.getScrollY() + scrollByY);
38
39
  });
39
40
 
40
- _defineProperty(this, "onScroll", function () {
41
- // Prefer not performing a re-layout while the user is scrolling (if possible).
41
+ _defineProperty(this, "onScrollListener", function () {
42
+ if (_this.onScrollPositionChange) {
43
+ _this.onScrollPositionChange(_this.getScrollY());
44
+ } // If the user has scrolled up to the top of the items container.
45
+ // (this option isn't currently used)
46
+
47
+
48
+ if (_this.onScrolledToTop) {
49
+ if (_this.getScrollY() < _this.getListTopOffset()) {
50
+ _this.onScrolledToTop();
51
+ }
52
+ }
53
+
54
+ if (_this.bypass) {
55
+ return;
56
+ }
57
+
58
+ if (_this.ignoreScrollEvents) {
59
+ return;
60
+ } // Prefer not performing a re-layout while the user is scrolling (if possible).
42
61
  // If the user doesn't scroll too far and then stops for a moment,
43
62
  // then a mid-scroll re-layout could be delayed until such a brief stop:
44
63
  // presumably, this results in better (smoother) scrolling performance,
45
64
  // delaying the work to when it doesn't introduce any stutter or "jank".
46
- // Reset `this.onUserStopsScrollingTimer` (will be re-created below).
47
- _this.cancelOnUserStopsScrollingTimer(); // See whether rendering "new" previous/next items is required
48
- // right now, or it can wait until the user stops scrolling.
65
+ // Reset `this.onStopScrollingTimer` (will be re-created below).
66
+
67
+
68
+ _this.cancelOnStopScrollingTimer(); // See if the latest "layout" (the currently rendered set of items)
69
+ // is still sufficient in order to show all the items that're
70
+ // currently inside the viewport. If there're some non-rendered items
71
+ // that're visible in the current viewport, then those items
72
+ // should be rendered "immediately" rather than waiting until
73
+ // the user stops scrolling.
49
74
 
50
75
 
51
76
  var forceUpdate = // If the items have been rendered at least once
52
- _this.getLatestLayoutVisibleAreaIncludingMargins() && ( // If the user has scrolled up past the extra "margin"
53
- _this.getScrollY() < _this.getLatestLayoutVisibleAreaIncludingMargins().top && // and if there're any previous non-rendered items to render.
54
- _this.hasNonRenderedItemsAtTheTop() || // If the user has scrolled down past the extra "margin"
55
- _this.getScrollY() + _this.scrollableContainer.getHeight() > _this.getLatestLayoutVisibleAreaIncludingMargins().bottom && // and if there're any next non-rendered items to render.
56
- _this.hasNonRenderedItemsAtTheBottom());
77
+ _this.getLatestLayoutVisibleArea() && ( // If the user has scrolled up past the "prerender margin"
78
+ // and there're some non-rendered items at the top,
79
+ // then force a re-layout.
80
+ //
81
+ // (during these calculations we assume that the list's top coordinate
82
+ // hasn't changed since previous layout; even if that's not exactly true,
83
+ // the items will be re-layout when the user stops scrolling anyway)
84
+ //
85
+ _this.getScrollY() < _this.getLatestLayoutVisibleArea().top - _this.getPrerenderMargin() && _this.hasNonRenderedItemsAtTheTop() || // If the user has scrolled down past the "prerender margin"
86
+ // and there're any non-rendered items left at the end,
87
+ // then force a re-layout.
88
+ //
89
+ // (during these calculations we assume that the list's top coordinate
90
+ // hasn't changed since previous layout; even if that's not exactly true,
91
+ // the items will be re-layout when the user stops scrolling anyway)
92
+ //
93
+ _this.getScrollY() + _this.scrollableContainer.getHeight() > _this.getLatestLayoutVisibleArea().bottom + _this.getPrerenderMargin() && _this.hasNonRenderedItemsAtTheBottom());
57
94
 
58
95
  if (forceUpdate) {
59
- log('The user has scrolled far enough: force re-layout');
96
+ log('The user has scrolled far enough: perform a re-layout');
60
97
  } else {
61
- log('The user hasn\'t scrolled too much: delay re-layout');
98
+ log('The user is scrolling: perform a re-layout when they stop scrolling');
62
99
  }
63
100
 
64
- if (!forceUpdate) {
65
- // If a re-layout is already scheduled at the next "frame",
66
- // don't schedule a "re-layout when user stops scrolling" timer.
67
- if (_this.isImmediateLayoutScheduled()) {
68
- return;
69
- }
101
+ if (forceUpdate || _this.waitForScrollingToStop === false) {
102
+ 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.
70
105
 
71
- _this.onUserStopsScrollingTimer = setTimeout(function () {
72
- _this.onUserStopsScrollingTimer = undefined;
73
106
 
74
- _this.updateLayout({
75
- reason: LAYOUT_REASON.STOPPED_SCROLLING
76
- });
77
- }, // "scroll" events are usually dispatched every 16 milliseconds
78
- // for 60fps refresh rate, so waiting for 100 milliseconds feels
79
- // reasonable: that would be about 6 frames of inactivity period,
80
- // which could mean that either the user has stopped scrolling
81
- // (for a moment) or the browser is lagging and stuttering
82
- // (skipping frames due to high load).
83
- // If the user continues scrolling then this timeout is constantly
84
- // refreshed (cancelled and then re-created).
85
- WAIT_FOR_USER_TO_STOP_SCROLLING_TIMEOUT);
107
+ if (_this.isImmediateLayoutScheduled()) {
86
108
  return;
87
109
  }
88
110
 
89
- _this.updateLayout({
90
- reason: LAYOUT_REASON.SCROLL
91
- });
111
+ _this.shouldCallOnScrollListenerWhenStopsScrolling = true;
112
+
113
+ _this.watchOnStopScrolling();
92
114
  });
93
115
 
94
116
  this.bypass = bypass;
95
117
  this.scrollableContainer = scrollableContainer;
96
- this.updateLayout = updateLayout;
118
+ this.itemsContainer = itemsContainer;
119
+ this.onScroll = onScroll;
97
120
  this.initialScrollPosition = initialScrollPosition;
98
121
  this.onScrollPositionChange = onScrollPositionChange;
99
122
  this.isImmediateLayoutScheduled = isImmediateLayoutScheduled;
100
123
  this.hasNonRenderedItemsAtTheTop = hasNonRenderedItemsAtTheTop;
101
124
  this.hasNonRenderedItemsAtTheBottom = hasNonRenderedItemsAtTheBottom;
102
- this.getLatestLayoutVisibleAreaIncludingMargins = getLatestLayoutVisibleAreaIncludingMargins;
103
-
104
- if (preserveScrollPositionOfTheBottomOfTheListOnMount) {
105
- if (scrollableContainer) {
106
- this.preserveScrollPositionOfTheBottomOfTheListOnMount = {
107
- scrollableContainerContentHeight: scrollableContainer.getContentHeight()
108
- };
109
- }
110
- }
125
+ this.getLatestLayoutVisibleArea = getLatestLayoutVisibleArea;
126
+ this.getListTopOffset = getListTopOffset;
127
+ this.getPrerenderMargin = getPrerenderMargin;
128
+ this.onScrolledToTop = onScrolledToTop;
129
+ this.waitForScrollingToStop = waitForScrollingToStop;
111
130
  }
112
131
 
113
132
  _createClass(Scroll, [{
114
- key: "listen",
115
- value: function listen() {
133
+ key: "start",
134
+ value: function start() {
116
135
  if (this.initialScrollPosition !== undefined) {
117
136
  this.scrollToY(this.initialScrollPosition);
137
+ this.initialScrollPosition = undefined;
118
138
  }
119
139
 
120
140
  if (this.onScrollPositionChange) {
121
- this.updateScrollPosition();
122
- this.removeScrollPositionListener = this.scrollableContainer.addScrollListener(this.updateScrollPosition);
123
- }
124
-
125
- if (!this.bypass) {
126
- this.removeScrollListener = this.scrollableContainer.addScrollListener(this.onScroll);
141
+ this.onScrollPositionChange(this.getScrollY());
127
142
  }
128
143
 
129
- if (this.preserveScrollPositionOfTheBottomOfTheListOnMount) {
130
- this.scrollToY(this.getScrollY() + (this.scrollableContainer.getContentHeight() - this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight));
131
- }
144
+ this.stopListeningToScroll = this.scrollableContainer.onScroll(this.onScrollListener);
132
145
  }
133
146
  }, {
134
147
  key: "stop",
135
148
  value: function stop() {
136
- if (this.removeScrollPositionListener) {
137
- this.removeScrollPositionListener();
138
- }
139
-
140
- if (this.removeScrollListener) {
141
- this.removeScrollListener();
142
- }
149
+ this.stopListeningToScroll();
150
+ this.stopListeningToScroll = undefined; // this.onStopScrollingListener = undefined
143
151
 
144
- this.cancelOnUserStopsScrollingTimer();
152
+ this.shouldCallOnScrollListenerWhenStopsScrolling = undefined;
153
+ this.cancelOnStopScrollingTimer();
145
154
  }
146
155
  }, {
147
156
  key: "scrollToY",
148
157
  value: function scrollToY(scrollY) {
158
+ this.ignoreScrollEvents = true;
149
159
  this.scrollableContainer.scrollToY(scrollY);
150
- }
151
- }, {
152
- key: "scrollByY",
153
- value: function scrollByY(_scrollByY) {
154
- this.scrollToY(this.getScrollY() + _scrollByY);
160
+ this.ignoreScrollEvents = undefined;
155
161
  }
156
162
  }, {
157
163
  key: "getScrollY",
158
164
  value: function getScrollY() {
159
165
  return this.scrollableContainer.getScrollY();
160
166
  }
161
- /**
162
- * Updates the current scroll Y position in state.
163
- */
164
-
165
167
  }, {
166
- key: "cancelOnUserStopsScrollingTimer",
167
- value: function cancelOnUserStopsScrollingTimer() {
168
- if (this.onUserStopsScrollingTimer) {
169
- clearTimeout(this.onUserStopsScrollingTimer);
170
- this.onUserStopsScrollingTimer = undefined;
168
+ key: "cancelOnStopScrollingTimer",
169
+ value: function cancelOnStopScrollingTimer() {
170
+ if (this.onStopScrollingTimer) {
171
+ clearTimeout(this.onStopScrollingTimer);
172
+ this.onStopScrollingTimer = undefined;
171
173
  }
172
174
  }
173
175
  }, {
174
- key: "onLayout",
175
- value: function onLayout() {
176
+ key: "cancelScheduledLayout",
177
+ value: function cancelScheduledLayout() {
176
178
  // Cancel a "re-layout when user stops scrolling" timer.
177
- this.cancelOnUserStopsScrollingTimer();
179
+ this.cancelOnStopScrollingTimer();
178
180
  }
179
181
  }, {
180
- key: "getVisibleAreaBounds",
182
+ key: "watchOnStopScrolling",
183
+ value: function watchOnStopScrolling() {
184
+ var _this2 = this;
185
+
186
+ this.onStopScrollingTimer = setTimeout(function () {
187
+ _this2.onStopScrollingTimer = undefined;
188
+
189
+ if (_this2.shouldCallOnScrollListenerWhenStopsScrolling) {
190
+ _this2.shouldCallOnScrollListenerWhenStopsScrolling = undefined;
191
+
192
+ _this2.onScroll({
193
+ delayed: true
194
+ });
195
+ } // `onStopScrolling()` feature is not currently used.
196
+ // if (this.onStopScrollingListener) {
197
+ // const onStopScrollingListener = this.onStopScrollingListener
198
+ // this.onStopScrollingListener = undefined
199
+ // // `onStopScrollingListener()` may hypothetically schedule
200
+ // // another `onStopScrolling()` listener, so set
201
+ // // `this.onStopScrollingListener` to `undefined` before
202
+ // // calling it rather than after.
203
+ // log('~ The user has stopped scrolling ~')
204
+ // onStopScrollingListener()
205
+ // }
206
+
207
+ }, // "scroll" events are usually dispatched every 16 milliseconds
208
+ // for 60fps refresh rate, so waiting for 100 milliseconds feels
209
+ // reasonable: that would be about 6 frames of inactivity period,
210
+ // which could mean that either the user has stopped scrolling
211
+ // (for a moment) or the browser is lagging and stuttering
212
+ // (skipping frames due to high load).
213
+ // If the user continues scrolling then this timeout is constantly
214
+ // refreshed (cancelled and then re-created).
215
+ ON_STOP_SCROLLING_INACTIVE_PERIOD);
216
+ } // (this function isn't currently used)
217
+ // onStopScrolling(onStopScrollingListener) {
218
+ // this.onStopScrollingListener = onStopScrollingListener
219
+ // if (!this.onStopScrollingTimer) {
220
+ // this.watchOnStopScrolling()
221
+ // }
222
+ // }
181
223
 
182
224
  /**
183
225
  * Returns visible area coordinates relative to the scrollable container.
184
226
  * @return {object} `{ top: number, bottom: number }`
185
227
  */
228
+
229
+ }, {
230
+ key: "getVisibleAreaBounds",
186
231
  value: function getVisibleAreaBounds() {
187
232
  var scrollY = this.getScrollY();
188
233
  return {
@@ -198,5 +243,5 @@ function () {
198
243
  }();
199
244
 
200
245
  export { Scroll as default };
201
- var WAIT_FOR_USER_TO_STOP_SCROLLING_TIMEOUT = 100;
246
+ var ON_STOP_SCROLLING_INACTIVE_PERIOD = 100;
202
247
  //# sourceMappingURL=Scroll.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../source/Scroll.js"],"names":["setTimeout","clearTimeout","LAYOUT_REASON","log","Scroll","bypass","scrollableContainer","updateLayout","initialScrollPosition","onScrollPositionChange","isImmediateLayoutScheduled","hasNonRenderedItemsAtTheTop","hasNonRenderedItemsAtTheBottom","getLatestLayoutVisibleAreaIncludingMargins","preserveScrollPositionOfTheBottomOfTheListOnMount","getScrollY","cancelOnUserStopsScrollingTimer","forceUpdate","top","getHeight","bottom","onUserStopsScrollingTimer","undefined","reason","STOPPED_SCROLLING","WAIT_FOR_USER_TO_STOP_SCROLLING_TIMEOUT","SCROLL","scrollableContainerContentHeight","getContentHeight","scrollToY","updateScrollPosition","removeScrollPositionListener","addScrollListener","removeScrollListener","onScroll","scrollY","scrollByY"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,YAArB,QAAyC,iCAAzC;AAEA,SAASC,aAAT,QAA8B,UAA9B;AACA,OAAOC,GAAP,MAAgB,iBAAhB;;IAEqBC,M;;;AACpB,wBAWG;AAAA;;AAAA,QAVFC,MAUE,QAVFA,MAUE;AAAA,QATFC,mBASE,QATFA,mBASE;AAAA,QARFC,YA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gCAA1H,CAAf;AACA;AACD;;;2BAEM;AACN,UAAI,KAAKI,4BAAT,EAAuC;AACtC,aAAKA,4BAAL;AACA;;AACD,UAAI,KAAKE,oBAAT,EAA+B;AAC9B,aAAKA,oBAAL;AACA;;AACD,WAAKjB,+BAAL;AACA;;;8BAESmB,O,EAAS;AAClB,WAAK7B,mBAAL,CAAyBuB,SAAzB,CAAmCM,OAAnC;AACA;;;8BAESC,U,EAAW;AACpB,WAAKP,SAAL,CAAe,KAAKd,UAAL,KAAoBqB,UAAnC;AACA;;;iCAEY;AACZ,aAAO,KAAK9B,mBAAL,CAAyBS,UAAzB,EAAP;AACA;AAED;;;;;;sDAOkC;AACjC,UAAI,KAAKM,yBAAT,EAAoC;AACnCpB,QAAAA,YAAY,CAAC,KAAKoB,yBAAN,CAAZ;AACA,aAAKA,yBAAL,GAAiCC,SAAjC;AACA;AACD;;;+BAEU;AACV;AACA,WAAKN,+BAAL;AACA;;;;AAiED;;;;2CAIuB;AACtB,UAAMmB,OAAO,GAAG,KAAKpB,UAAL,EAAhB;AACA,aAAO;AACN;AACAG,QAAAA,GAAG,EAAEiB,OAFC;AAGN;AACAf,QAAAA,MAAM,EAAEe,OAAO,GAAG,KAAK7B,mBAAL,CAAyBa,SAAzB;AAJZ,OAAP;AAMA;;;;;;SApKmBf,M;AAuKrB,IAAMqB,uCAAuC,GAAG,GAAhD","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 { LAYOUT_REASON } from './Layout'\r\nimport log from './utility/debug'\r\n\r\nexport default class Scroll {\r\n\tconstructor({\r\n\t\tbypass,\r\n\t\tscrollableContainer,\r\n\t\tupdateLayout,\r\n\t\tinitialScrollPosition,\r\n\t\tonScrollPositionChange,\r\n\t\tisImmediateLayoutScheduled,\r\n\t\thasNonRenderedItemsAtTheTop,\r\n\t\thasNonRenderedItemsAtTheBottom,\r\n\t\tgetLatestLayoutVisibleAreaIncludingMargins,\r\n\t\tpreserveScrollPositionOfTheBottomOfTheListOnMount\r\n\t}) {\r\n\t\tthis.bypass = bypass\r\n\t\tthis.scrollableContainer = scrollableContainer\r\n\t\tthis.updateLayout = updateLayout\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.getLatestLayoutVisibleAreaIncludingMargins = getLatestLayoutVisibleAreaIncludingMargins\r\n\r\n\t\tif (preserveScrollPositionOfTheBottomOfTheListOnMount) {\r\n\t\t\tif (scrollableContainer) {\r\n\t\t\t\tthis.preserveScrollPositionOfTheBottomOfTheListOnMount = {\r\n\t\t\t\t\tscrollableContainerContentHeight: scrollableContainer.getContentHeight()\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tlisten() {\r\n\t\tif (this.initialScrollPosition !== undefined) {\r\n\t\t\tthis.scrollToY(this.initialScrollPosition)\r\n\t\t}\r\n\t\tif (this.onScrollPositionChange) {\r\n\t\t\tthis.updateScrollPosition()\r\n\t\t\tthis.removeScrollPositionListener = this.scrollableContainer.addScrollListener(this.updateScrollPosition)\r\n\t\t}\r\n\t\tif (!this.bypass) {\r\n\t\t\tthis.removeScrollListener = this.scrollableContainer.addScrollListener(this.onScroll)\r\n\t\t}\r\n\t\tif (this.preserveScrollPositionOfTheBottomOfTheListOnMount) {\r\n\t\t\tthis.scrollToY(this.getScrollY() + (this.scrollableContainer.getContentHeight() - this.preserveScrollPositionOfTheBottomOfTheListOnMount.scrollableContainerContentHeight))\r\n\t\t}\r\n\t}\r\n\r\n\tstop() {\r\n\t\tif (this.removeScrollPositionListener) {\r\n\t\t\tthis.removeScrollPositionListener()\r\n\t\t}\r\n\t\tif (this.removeScrollListener) {\r\n\t\t\tthis.removeScrollListener()\r\n\t\t}\r\n\t\tthis.cancelOnUserStopsScrollingTimer()\r\n\t}\r\n\r\n\tscrollToY(scrollY) {\r\n\t\tthis.scrollableContainer.scrollToY(scrollY)\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\t/**\r\n\t * Updates the current scroll Y position in state.\r\n\t */\r\n\tupdateScrollPosition = () => {\r\n\t\tthis.onScrollPositionChange(this.getScrollY())\r\n\t}\r\n\r\n\tcancelOnUserStopsScrollingTimer() {\r\n\t\tif (this.onUserStopsScrollingTimer) {\r\n\t\t\tclearTimeout(this.onUserStopsScrollingTimer)\r\n\t\t\tthis.onUserStopsScrollingTimer = undefined\r\n\t\t}\r\n\t}\r\n\r\n\tonLayout() {\r\n\t\t// Cancel a \"re-layout when user stops scrolling\" timer.\r\n\t\tthis.cancelOnUserStopsScrollingTimer()\r\n\t}\r\n\r\n\tonScroll = () => {\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.onUserStopsScrollingTimer` (will be re-created below).\r\n\t\tthis.cancelOnUserStopsScrollingTimer()\r\n\r\n\t\t// See whether rendering \"new\" previous/next items is required\r\n\t\t// right now, or it can wait until 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.getLatestLayoutVisibleAreaIncludingMargins() && (\r\n\t\t\t\t(\r\n\t\t\t\t\t// If the user has scrolled up past the extra \"margin\"\r\n\t\t\t\t\t(this.getScrollY() < this.getLatestLayoutVisibleAreaIncludingMargins().top) &&\r\n\t\t\t\t\t// and if there're any previous non-rendered items to render.\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 extra \"margin\"\r\n\t\t\t\t\t(this.getScrollY() + this.scrollableContainer.getHeight() > this.getLatestLayoutVisibleAreaIncludingMargins().bottom) &&\r\n\t\t\t\t\t// and if there're any next non-rendered items to render.\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: force re-layout')\r\n\t\t} else {\r\n\t\t\tlog('The user hasn\\'t scrolled too much: delay re-layout')\r\n\t\t}\r\n\r\n\t\tif (!forceUpdate) {\r\n\t\t\t// If a re-layout is already scheduled at the next \"frame\",\r\n\t\t\t// don't schedule a \"re-layout when user stops scrolling\" timer.\r\n\t\t\tif (this.isImmediateLayoutScheduled()) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\tthis.onUserStopsScrollingTimer = setTimeout(\r\n\t\t\t\t() => {\r\n\t\t\t\t\tthis.onUserStopsScrollingTimer = undefined\r\n\t\t\t\t\tthis.updateLayout({ reason: LAYOUT_REASON.STOPPED_SCROLLING })\r\n\t\t\t\t},\r\n\t\t\t\t// \"scroll\" events are usually dispatched every 16 milliseconds\r\n\t\t\t\t// for 60fps refresh rate, so waiting for 100 milliseconds feels\r\n\t\t\t\t// reasonable: that would be about 6 frames of inactivity period,\r\n\t\t\t\t// which could mean that either the user has stopped scrolling\r\n\t\t\t\t// (for a moment) or the browser is lagging and stuttering\r\n\t\t\t\t// (skipping frames due to high load).\r\n\t\t\t\t// If the user continues scrolling then this timeout is constantly\r\n\t\t\t\t// refreshed (cancelled and then re-created).\r\n\t\t\t\tWAIT_FOR_USER_TO_STOP_SCROLLING_TIMEOUT\r\n\t\t\t)\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tthis.updateLayout({ reason: LAYOUT_REASON.SCROLL })\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 WAIT_FOR_USER_TO_STOP_SCROLLING_TIMEOUT = 100"],"file":"Scroll.js"}
1
+ {"version":3,"file":"Scroll.js","names":["setTimeout","clearTimeout","log","Scroll","bypass","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\tbypass,\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.bypass = bypass\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\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.bypass) {\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.\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,MAcE,QAdFA,MAcE;IAAA,IAbFC,mBAaE,QAbFA,mBAaE;IAAA,IAZFC,cAYE,QAZFA,cAYE;IAAA,IAXFC,QAWE,QAXFA,QAWE;IAAA,IAVFC,qBAUE,QAVFA,qBAUE;IAAA,IATFC,sBASE,QATFA,sBASE;IAAA,IARFC,0BAQE,QARFA,0BAQE;IAAA,IAPFC,2BAOE,QAPFA,2BAO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A1NmBtB,M;AA6NrB,IAAMgC,iCAAiC,GAAG,GAA1C"}
@@ -0,0 +1,36 @@
1
+ export default function createColumnsHelpers(_ref) {
2
+ var _this = this;
3
+
4
+ var getColumnsCount = _ref.getColumnsCount;
5
+
6
+ if (getColumnsCount) {
7
+ var scrollableContainerArgument = {
8
+ getWidth: function getWidth() {
9
+ return _this.scrollableContainer.getWidth();
10
+ }
11
+ };
12
+
13
+ this.getActualColumnsCountForState = function () {
14
+ var columnsCount = getColumnsCount(scrollableContainerArgument); // `columnsCount: 1` is effectively same as `columnsCount: undefined`
15
+ // from the code's point of view. This makes one less property in `state`
16
+ // which makes `state` a bit less cluttered (easier for inspection).
17
+
18
+ if (columnsCount !== 1) {
19
+ return columnsCount;
20
+ }
21
+ };
22
+ } else {
23
+ this.getActualColumnsCountForState = function () {
24
+ return undefined;
25
+ };
26
+ }
27
+
28
+ this.getActualColumnsCount = function () {
29
+ return _this.getActualColumnsCountForState() || 1;
30
+ };
31
+
32
+ this.getColumnsCount = function () {
33
+ return _this.getState() && _this.getState().columnsCount || 1;
34
+ };
35
+ }
36
+ //# sourceMappingURL=VirtualScroller.columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VirtualScroller.columns.js","names":["createColumnsHelpers","getColumnsCount","scrollableContainerArgument","getWidth","scrollableContainer","getActualColumnsCountForState","columnsCount","undefined","getActualColumnsCount","getState"],"sources":["../source/VirtualScroller.columns.js"],"sourcesContent":["export default function createColumnsHelpers({ getColumnsCount }) {\r\n\tif (getColumnsCount) {\r\n\t\tconst scrollableContainerArgument = {\r\n\t\t\tgetWidth: () => this.scrollableContainer.getWidth()\r\n\t\t}\r\n\t\tthis.getActualColumnsCountForState = () => {\r\n\t\t\tconst columnsCount = getColumnsCount(scrollableContainerArgument)\r\n\t\t\t// `columnsCount: 1` is effectively same as `columnsCount: undefined`\r\n\t\t\t// from the code's point of view. This makes one less property in `state`\r\n\t\t\t// which makes `state` a bit less cluttered (easier for inspection).\r\n\t\t\tif (columnsCount !== 1) {\r\n\t\t\t\treturn columnsCount\r\n\t\t\t}\r\n\t\t}\r\n\t} else {\r\n\t\tthis.getActualColumnsCountForState = () => undefined\r\n\t}\r\n\r\n\tthis.getActualColumnsCount = () => {\r\n\t\treturn this.getActualColumnsCountForState() || 1\r\n\t}\r\n\r\n\tthis.getColumnsCount = () => {\r\n\t\treturn this.getState() && this.getState().columnsCount || 1\r\n\t}\r\n}"],"mappings":"AAAA,eAAe,SAASA,oBAAT,OAAmD;EAAA;;EAAA,IAAnBC,eAAmB,QAAnBA,eAAmB;;EACjE,IAAIA,eAAJ,EAAqB;IACpB,IAAMC,2BAA2B,GAAG;MACnCC,QAAQ,EAAE;QAAA,OAAM,KAAI,CAACC,mBAAL,CAAyBD,QAAzB,EAAN;MAAA;IADyB,CAApC;;IAGA,KAAKE,6BAAL,GAAqC,YAAM;MAC1C,IAAMC,YAAY,GAAGL,eAAe,CAACC,2BAAD,CAApC,CAD0C,CAE1C;MACA;MACA;;MACA,IAAII,YAAY,KAAK,CAArB,EAAwB;QACvB,OAAOA,YAAP;MACA;IACD,CARD;EASA,CAbD,MAaO;IACN,KAAKD,6BAAL,GAAqC;MAAA,OAAME,SAAN;IAAA,CAArC;EACA;;EAED,KAAKC,qBAAL,GAA6B,YAAM;IAClC,OAAO,KAAI,CAACH,6BAAL,MAAwC,CAA/C;EACA,CAFD;;EAIA,KAAKJ,eAAL,GAAuB,YAAM;IAC5B,OAAO,KAAI,CAACQ,QAAL,MAAmB,KAAI,CAACA,QAAL,GAAgBH,YAAnC,IAAmD,CAA1D;EACA,CAFD;AAGA"}