virtual-scroller 1.8.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +1 -1
- package/CHANGELOG.md +57 -0
- package/README.md +337 -160
- package/bundle/virtual-scroller-dom.js +1 -1
- package/bundle/virtual-scroller-dom.js.map +1 -1
- package/bundle/virtual-scroller-react.js +1 -1
- package/bundle/virtual-scroller-react.js.map +1 -1
- package/bundle/virtual-scroller.js +1 -1
- package/bundle/virtual-scroller.js.map +1 -1
- package/commonjs/BeforeResize.js +23 -27
- package/commonjs/BeforeResize.js.map +1 -1
- package/commonjs/DOM/Engine.js +7 -7
- package/commonjs/DOM/Engine.js.map +1 -1
- package/commonjs/DOM/ItemsContainer.js +1 -1
- package/commonjs/DOM/ItemsContainer.js.map +1 -1
- package/commonjs/DOM/ListTopOffsetWatcher.js +15 -9
- package/commonjs/DOM/ListTopOffsetWatcher.js.map +1 -1
- package/commonjs/DOM/ScrollableContainer.js +28 -28
- package/commonjs/DOM/ScrollableContainer.js.map +1 -1
- package/commonjs/DOM/VirtualScroller.js +20 -17
- package/commonjs/DOM/VirtualScroller.js.map +1 -1
- package/commonjs/DOM/tbody.js +16 -10
- package/commonjs/DOM/tbody.js.map +1 -1
- package/commonjs/ItemHeights.js +23 -17
- package/commonjs/ItemHeights.js.map +1 -1
- package/commonjs/Layout.js +15 -13
- package/commonjs/Layout.js.map +1 -1
- package/commonjs/Layout.test.js +8 -3
- package/commonjs/Layout.test.js.map +1 -1
- package/commonjs/{ListHeightChangeWatcher.js → ListHeightMeasurement.js} +26 -28
- package/commonjs/ListHeightMeasurement.js.map +1 -0
- package/commonjs/Resize.js +38 -28
- package/commonjs/Resize.js.map +1 -1
- package/commonjs/Scroll.js +28 -44
- package/commonjs/Scroll.js.map +1 -1
- package/commonjs/VirtualScroller.columns.js +43 -0
- package/commonjs/VirtualScroller.columns.js.map +1 -0
- package/commonjs/VirtualScroller.constructor.js +408 -0
- package/commonjs/VirtualScroller.constructor.js.map +1 -0
- package/commonjs/VirtualScroller.items.js +305 -0
- package/commonjs/VirtualScroller.items.js.map +1 -0
- package/commonjs/VirtualScroller.js +132 -1872
- package/commonjs/VirtualScroller.js.map +1 -1
- package/commonjs/VirtualScroller.layout.js +562 -0
- package/commonjs/VirtualScroller.layout.js.map +1 -0
- package/commonjs/VirtualScroller.onRender.js +357 -0
- package/commonjs/VirtualScroller.onRender.js.map +1 -0
- package/commonjs/VirtualScroller.resize.js +186 -0
- package/commonjs/VirtualScroller.resize.js.map +1 -0
- package/commonjs/VirtualScroller.state.js +301 -0
- package/commonjs/VirtualScroller.state.js.map +1 -0
- package/commonjs/VirtualScroller.verticalSpacing.js +65 -0
- package/commonjs/VirtualScroller.verticalSpacing.js.map +1 -0
- package/commonjs/getItemCoordinates.js.map +1 -1
- package/commonjs/getItemsDiff.js.map +1 -1
- package/commonjs/getVerticalSpacing.js.map +1 -1
- package/commonjs/package.json +5 -0
- package/commonjs/react/VirtualScroller.js +184 -618
- package/commonjs/react/VirtualScroller.js.map +1 -1
- package/commonjs/react/useClassName.js +26 -0
- package/commonjs/react/useClassName.js.map +1 -0
- package/commonjs/react/useHandleItemsChange.js +116 -0
- package/commonjs/react/useHandleItemsChange.js.map +1 -0
- package/commonjs/react/useInstanceMethods.js +37 -0
- package/commonjs/react/useInstanceMethods.js.map +1 -0
- package/commonjs/react/useItemKeys.js +60 -0
- package/commonjs/react/useItemKeys.js.map +1 -0
- package/commonjs/react/useOnItemHeightChange.js +32 -0
- package/commonjs/react/useOnItemHeightChange.js.map +1 -0
- package/commonjs/react/useOnItemStateChange.js +32 -0
- package/commonjs/react/useOnItemStateChange.js.map +1 -0
- package/commonjs/react/useState.js +140 -0
- package/commonjs/react/useState.js.map +1 -0
- package/commonjs/react/useStyle.js +29 -0
- package/commonjs/react/useStyle.js.map +1 -0
- package/commonjs/react/useVirtualScroller.js +62 -0
- package/commonjs/react/useVirtualScroller.js.map +1 -0
- package/commonjs/react/useVirtualScrollerStartStop.js +20 -0
- package/commonjs/react/useVirtualScrollerStartStop.js.map +1 -0
- package/commonjs/test/Engine.js +23 -0
- package/commonjs/test/Engine.js.map +1 -0
- package/commonjs/test/ItemsContainer.js +127 -0
- package/commonjs/test/ItemsContainer.js.map +1 -0
- package/commonjs/test/ScrollableContainer.js +130 -0
- package/commonjs/test/ScrollableContainer.js.map +1 -0
- package/commonjs/test/VirtualScroller.js +281 -0
- package/commonjs/test/VirtualScroller.js.map +1 -0
- package/commonjs/utility/debounce.js +2 -2
- package/commonjs/utility/debounce.js.map +1 -1
- package/commonjs/utility/debug.js.map +1 -1
- package/commonjs/utility/getStateSnapshot.js +2 -2
- package/commonjs/utility/getStateSnapshot.js.map +1 -1
- package/commonjs/utility/px.js.map +1 -1
- package/commonjs/utility/px.test.js +1 -1
- package/commonjs/utility/px.test.js.map +1 -1
- package/commonjs/utility/shallowEqual.js +1 -1
- package/commonjs/utility/shallowEqual.js.map +1 -1
- package/commonjs/utility/throttle.js.map +1 -1
- package/dom/index.cjs +4 -0
- package/dom/index.cjs.js +9 -0
- package/dom/index.d.ts +6 -4
- package/dom/index.js +1 -1
- package/dom/package.json +10 -4
- package/index.cjs +4 -0
- package/index.cjs.js +9 -0
- package/index.d.ts +30 -15
- package/index.js +1 -1
- package/modules/BeforeResize.js +22 -27
- package/modules/BeforeResize.js.map +1 -1
- package/modules/DOM/Engine.js +6 -6
- package/modules/DOM/Engine.js.map +1 -1
- package/modules/DOM/ItemsContainer.js +1 -1
- package/modules/DOM/ItemsContainer.js.map +1 -1
- package/modules/DOM/ListTopOffsetWatcher.js +15 -9
- package/modules/DOM/ListTopOffsetWatcher.js.map +1 -1
- package/modules/DOM/ScrollableContainer.js +28 -28
- package/modules/DOM/ScrollableContainer.js.map +1 -1
- package/modules/DOM/VirtualScroller.js +19 -16
- package/modules/DOM/VirtualScroller.js.map +1 -1
- package/modules/DOM/tbody.js +11 -9
- package/modules/DOM/tbody.js.map +1 -1
- package/modules/ItemHeights.js +22 -16
- package/modules/ItemHeights.js.map +1 -1
- package/modules/Layout.js +14 -12
- package/modules/Layout.js.map +1 -1
- package/modules/Layout.test.js +8 -3
- package/modules/Layout.test.js.map +1 -1
- package/modules/{ListHeightChangeWatcher.js → ListHeightMeasurement.js} +25 -27
- package/modules/ListHeightMeasurement.js.map +1 -0
- package/modules/Resize.js +38 -28
- package/modules/Resize.js.map +1 -1
- package/modules/Scroll.js +28 -44
- package/modules/Scroll.js.map +1 -1
- package/modules/VirtualScroller.columns.js +36 -0
- package/modules/VirtualScroller.columns.js.map +1 -0
- package/modules/VirtualScroller.constructor.js +371 -0
- package/modules/VirtualScroller.constructor.js.map +1 -0
- package/modules/VirtualScroller.items.js +288 -0
- package/modules/VirtualScroller.items.js.map +1 -0
- package/modules/VirtualScroller.js +132 -1860
- package/modules/VirtualScroller.js.map +1 -1
- package/modules/VirtualScroller.layout.js +549 -0
- package/modules/VirtualScroller.layout.js.map +1 -0
- package/modules/VirtualScroller.onRender.js +337 -0
- package/modules/VirtualScroller.onRender.js.map +1 -0
- package/modules/VirtualScroller.resize.js +176 -0
- package/modules/VirtualScroller.resize.js.map +1 -0
- package/modules/VirtualScroller.state.js +283 -0
- package/modules/VirtualScroller.state.js.map +1 -0
- package/modules/VirtualScroller.verticalSpacing.js +54 -0
- package/modules/VirtualScroller.verticalSpacing.js.map +1 -0
- package/modules/getItemCoordinates.js.map +1 -1
- package/modules/getItemsDiff.js.map +1 -1
- package/modules/getVerticalSpacing.js.map +1 -1
- package/modules/react/VirtualScroller.js +176 -625
- package/modules/react/VirtualScroller.js.map +1 -1
- package/modules/react/useClassName.js +18 -0
- package/modules/react/useClassName.js.map +1 -0
- package/modules/react/useHandleItemsChange.js +108 -0
- package/modules/react/useHandleItemsChange.js.map +1 -0
- package/modules/react/useInstanceMethods.js +28 -0
- package/modules/react/useInstanceMethods.js.map +1 -0
- package/modules/react/useItemKeys.js +52 -0
- package/modules/react/useItemKeys.js.map +1 -0
- package/modules/react/useOnItemHeightChange.js +24 -0
- package/modules/react/useOnItemHeightChange.js.map +1 -0
- package/modules/react/useOnItemStateChange.js +24 -0
- package/modules/react/useOnItemStateChange.js.map +1 -0
- package/modules/react/useState.js +132 -0
- package/modules/react/useState.js.map +1 -0
- package/modules/react/useStyle.js +19 -0
- package/modules/react/useStyle.js.map +1 -0
- package/modules/react/useVirtualScroller.js +51 -0
- package/modules/react/useVirtualScroller.js.map +1 -0
- package/modules/react/useVirtualScrollerStartStop.js +12 -0
- package/modules/react/useVirtualScrollerStartStop.js.map +1 -0
- package/modules/test/Engine.js +11 -0
- package/modules/test/Engine.js.map +1 -0
- package/modules/test/ItemsContainer.js +120 -0
- package/modules/test/ItemsContainer.js.map +1 -0
- package/modules/test/ScrollableContainer.js +123 -0
- package/modules/test/ScrollableContainer.js.map +1 -0
- package/modules/test/VirtualScroller.js +270 -0
- package/modules/test/VirtualScroller.js.map +1 -0
- package/modules/utility/debounce.js +2 -2
- package/modules/utility/debounce.js.map +1 -1
- package/modules/utility/debug.js.map +1 -1
- package/modules/utility/getStateSnapshot.js +2 -2
- package/modules/utility/getStateSnapshot.js.map +1 -1
- package/modules/utility/px.js.map +1 -1
- package/modules/utility/px.test.js +1 -1
- package/modules/utility/px.test.js.map +1 -1
- package/modules/utility/shallowEqual.js +1 -1
- package/modules/utility/shallowEqual.js.map +1 -1
- package/modules/utility/throttle.js.map +1 -1
- package/package.json +46 -23
- package/react/index.cjs +4 -0
- package/react/index.cjs.js +9 -0
- package/react/index.d.ts +10 -9
- package/react/index.js +1 -1
- package/react/package.json +10 -4
- package/rollup.config.mjs +62 -0
- package/runnable/create-commonjs-package-json.js +11 -0
- package/source/BeforeResize.js +16 -21
- package/source/DOM/Engine.js +8 -10
- package/source/DOM/ListTopOffsetWatcher.js +13 -8
- package/source/DOM/ScrollableContainer.js +23 -21
- package/source/DOM/VirtualScroller.js +27 -11
- package/source/DOM/tbody.js +30 -21
- package/source/ItemHeights.js +19 -14
- package/source/Layout.js +12 -9
- package/source/Layout.test.js +8 -3
- package/source/{ListHeightChangeWatcher.js → ListHeightMeasurement.js} +21 -20
- package/source/Resize.js +41 -25
- package/source/Scroll.js +27 -35
- package/source/VirtualScroller.columns.js +26 -0
- package/source/VirtualScroller.constructor.js +336 -0
- package/source/VirtualScroller.items.js +302 -0
- package/source/VirtualScroller.js +144 -1872
- package/source/VirtualScroller.layout.js +539 -0
- package/source/VirtualScroller.onRender.js +345 -0
- package/source/VirtualScroller.resize.js +189 -0
- package/source/VirtualScroller.state.js +284 -0
- package/source/VirtualScroller.verticalSpacing.js +51 -0
- package/source/react/VirtualScroller.js +243 -587
- package/source/react/useClassName.js +14 -0
- package/source/react/useHandleItemsChange.js +115 -0
- package/source/react/useInstanceMethods.js +25 -0
- package/source/react/useItemKeys.js +59 -0
- package/source/react/useOnItemHeightChange.js +28 -0
- package/source/react/useOnItemStateChange.js +28 -0
- package/source/react/useState.js +114 -0
- package/source/react/useStyle.js +20 -0
- package/source/react/useVirtualScroller.js +59 -0
- package/source/react/useVirtualScrollerStartStop.js +12 -0
- package/source/test/Engine.js +11 -0
- package/source/test/ItemsContainer.js +87 -0
- package/source/test/ScrollableContainer.js +88 -0
- package/source/test/VirtualScroller.js +232 -0
- package/source/utility/debounce.js +2 -2
- package/source/utility/px.test.js +1 -1
- package/babel.config.js +0 -25
- package/babel.js +0 -5
- package/commonjs/ListHeightChangeWatcher.js.map +0 -1
- package/dom/index.commonjs.js +0 -4
- package/index.commonjs.js +0 -4
- package/modules/ListHeightChangeWatcher.js.map +0 -1
- package/react/index.commonjs.js +0 -4
package/modules/Resize.js
CHANGED
|
@@ -2,21 +2,23 @@ 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 debounce from './utility/debounce';
|
|
10
|
-
import log from './utility/debug';
|
|
9
|
+
import debounce from './utility/debounce.js';
|
|
10
|
+
import log from './utility/debug.js';
|
|
11
11
|
|
|
12
12
|
var Resize = /*#__PURE__*/function () {
|
|
13
13
|
function Resize(_ref) {
|
|
14
14
|
var _this = this;
|
|
15
15
|
|
|
16
16
|
var bypass = _ref.bypass,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
getWidth = _ref.getWidth,
|
|
18
|
+
getHeight = _ref.getHeight,
|
|
19
|
+
listenForResize = _ref.listenForResize,
|
|
20
|
+
onResizeStart = _ref.onResizeStart,
|
|
21
|
+
onResizeStop = _ref.onResizeStop,
|
|
20
22
|
onHeightChange = _ref.onHeightChange,
|
|
21
23
|
onWidthChange = _ref.onWidthChange,
|
|
22
24
|
onNoChange = _ref.onNoChange;
|
|
@@ -26,17 +28,20 @@ var Resize = /*#__PURE__*/function () {
|
|
|
26
28
|
_defineProperty(this, "_onResize", function () {
|
|
27
29
|
// If `VirtualScroller` has been unmounted
|
|
28
30
|
// while `debounce()`'s `setTimeout()` was waiting, then exit.
|
|
29
|
-
|
|
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.
|
|
34
|
-
var prevScrollableContainerHeight = _this.
|
|
35
|
-
_this.
|
|
36
|
-
_this.
|
|
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.
|
|
39
|
-
if (_this.
|
|
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
47
|
_this.onNoChange();
|
|
@@ -44,48 +49,53 @@ var Resize = /*#__PURE__*/function () {
|
|
|
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.onHeightChange(prevScrollableContainerHeight, _this.
|
|
52
|
+
_this.onHeightChange(prevScrollableContainerHeight, _this.height);
|
|
48
53
|
}
|
|
49
54
|
} else {
|
|
50
55
|
// Reset item heights, because if scrollable container's width (or height)
|
|
51
56
|
// has changed, then the list width (or height) most likely also has changed,
|
|
52
57
|
// and also some CSS `@media()` rules might have been added or removed.
|
|
53
58
|
// So re-render the list entirely.
|
|
54
|
-
_this.onWidthChange(prevScrollableContainerWidth, _this.
|
|
59
|
+
_this.onWidthChange(prevScrollableContainerWidth, _this.width);
|
|
55
60
|
}
|
|
56
61
|
});
|
|
57
62
|
|
|
58
63
|
this.bypass = bypass;
|
|
59
|
-
this.scrollableContainer = scrollableContainer;
|
|
60
64
|
this.onHeightChange = onHeightChange;
|
|
61
65
|
this.onWidthChange = onWidthChange;
|
|
62
66
|
this.onNoChange = onNoChange;
|
|
67
|
+
this.getWidth = getWidth;
|
|
68
|
+
this.getHeight = getHeight;
|
|
69
|
+
this.listenForResize = listenForResize;
|
|
63
70
|
this.onResize = debounce(this._onResize, SCROLLABLE_CONTAINER_RESIZE_DEBOUNCE_INTERVAL, {
|
|
64
|
-
onStart:
|
|
65
|
-
onStop:
|
|
71
|
+
onStart: onResizeStart,
|
|
72
|
+
onStop: onResizeStop
|
|
66
73
|
});
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
_createClass(Resize, [{
|
|
70
|
-
key: "
|
|
71
|
-
value: function
|
|
77
|
+
key: "start",
|
|
78
|
+
value: function start() {
|
|
79
|
+
this.isActive = true;
|
|
80
|
+
|
|
72
81
|
if (this.bypass) {
|
|
73
82
|
return;
|
|
74
83
|
}
|
|
75
84
|
|
|
76
|
-
this.
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
79
|
-
this.scrollableContainerUnlistenResize = this.scrollableContainer.onResize(this.onResize);
|
|
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.
|
|
92
|
+
this.isActive = false;
|
|
93
|
+
this.width = undefined;
|
|
94
|
+
this.height = undefined;
|
|
85
95
|
|
|
86
|
-
if (this.
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
96
|
+
if (this.unlistenResize) {
|
|
97
|
+
this.unlistenResize();
|
|
98
|
+
this.unlistenResize = undefined;
|
|
89
99
|
}
|
|
90
100
|
}
|
|
91
101
|
/**
|
package/modules/Resize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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;IAA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AKV,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,7 +11,7 @@ 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 log from './utility/debug';
|
|
14
|
+
import log from './utility/debug.js';
|
|
15
15
|
|
|
16
16
|
var Scroll = /*#__PURE__*/function () {
|
|
17
17
|
function Scroll(_ref) {
|
|
@@ -108,7 +108,7 @@ var Scroll = /*#__PURE__*/function () {
|
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
_this.
|
|
111
|
+
_this.shouldCallOnScrollListenerWhenStopsScrolling = true;
|
|
112
112
|
|
|
113
113
|
_this.watchOnStopScrolling();
|
|
114
114
|
});
|
|
@@ -130,10 +130,11 @@ var Scroll = /*#__PURE__*/function () {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
_createClass(Scroll, [{
|
|
133
|
-
key: "
|
|
134
|
-
value: function
|
|
133
|
+
key: "start",
|
|
134
|
+
value: function start() {
|
|
135
135
|
if (this.initialScrollPosition !== undefined) {
|
|
136
136
|
this.scrollToY(this.initialScrollPosition);
|
|
137
|
+
this.initialScrollPosition = undefined;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
if (this.onScrollPositionChange) {
|
|
@@ -145,24 +146,10 @@ var Scroll = /*#__PURE__*/function () {
|
|
|
145
146
|
}, {
|
|
146
147
|
key: "stop",
|
|
147
148
|
value: function stop() {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.stopReportingScrollPositionChange = undefined;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (this.stopListeningToScroll) {
|
|
154
|
-
this.stopListeningToScroll();
|
|
155
|
-
this.stopListeningToScroll = undefined;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (this.onStopScrollingListener) {
|
|
159
|
-
this.onStopScrollingListener = undefined;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (this.onScrollOnStopScrolling) {
|
|
163
|
-
this.onScrollOnStopScrolling = undefined;
|
|
164
|
-
}
|
|
149
|
+
this.stopListeningToScroll();
|
|
150
|
+
this.stopListeningToScroll = undefined; // this.onStopScrollingListener = undefined
|
|
165
151
|
|
|
152
|
+
this.shouldCallOnScrollListenerWhenStopsScrolling = undefined;
|
|
166
153
|
this.cancelOnStopScrollingTimer();
|
|
167
154
|
}
|
|
168
155
|
}, {
|
|
@@ -199,24 +186,24 @@ var Scroll = /*#__PURE__*/function () {
|
|
|
199
186
|
this.onStopScrollingTimer = setTimeout(function () {
|
|
200
187
|
_this2.onStopScrollingTimer = undefined;
|
|
201
188
|
|
|
202
|
-
if (_this2.
|
|
203
|
-
_this2.
|
|
189
|
+
if (_this2.shouldCallOnScrollListenerWhenStopsScrolling) {
|
|
190
|
+
_this2.shouldCallOnScrollListenerWhenStopsScrolling = undefined;
|
|
204
191
|
|
|
205
192
|
_this2.onScroll({
|
|
206
193
|
delayed: true
|
|
207
194
|
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
+
// }
|
|
216
206
|
|
|
217
|
-
log('~ The user has stopped scrolling ~');
|
|
218
|
-
onStopScrollingListener();
|
|
219
|
-
}
|
|
220
207
|
}, // "scroll" events are usually dispatched every 16 milliseconds
|
|
221
208
|
// for 60fps refresh rate, so waiting for 100 milliseconds feels
|
|
222
209
|
// reasonable: that would be about 6 frames of inactivity period,
|
|
@@ -227,16 +214,13 @@ var Scroll = /*#__PURE__*/function () {
|
|
|
227
214
|
// refreshed (cancelled and then re-created).
|
|
228
215
|
ON_STOP_SCROLLING_INACTIVE_PERIOD);
|
|
229
216
|
} // (this function isn't currently used)
|
|
217
|
+
// onStopScrolling(onStopScrollingListener) {
|
|
218
|
+
// this.onStopScrollingListener = onStopScrollingListener
|
|
219
|
+
// if (!this.onStopScrollingTimer) {
|
|
220
|
+
// this.watchOnStopScrolling()
|
|
221
|
+
// }
|
|
222
|
+
// }
|
|
230
223
|
|
|
231
|
-
}, {
|
|
232
|
-
key: "onStopScrolling",
|
|
233
|
-
value: function onStopScrolling(onStopScrollingListener) {
|
|
234
|
-
this.onStopScrollingListener = onStopScrollingListener;
|
|
235
|
-
|
|
236
|
-
if (!this.onStopScrollingTimer) {
|
|
237
|
-
this.watchOnStopScrolling();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
224
|
/**
|
|
241
225
|
* Returns visible area coordinates relative to the scrollable container.
|
|
242
226
|
* @return {object} `{ top: number, bottom: number }`
|
package/modules/Scroll.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../source/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","onScrollOnStopScrolling","watchOnStopScrolling","undefined","stopListeningToScroll","onScrollListener","stopReportingScrollPositionChange","onStopScrollingListener","scrollY","onStopScrollingTimer","delayed","ON_STOP_SCROLLING_INACTIVE_PERIOD"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA,SAASA,UAAT,EAAqBC,YAArB,QAAyC,iCAA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U,CACrC,YAAM;AACL,QAAA,MAAI,CAACmC,oBAAL,GAA4BN,SAA5B;;AAEA,YAAI,MAAI,CAACF,uBAAT,EAAkC;AACjC,UAAA,MAAI,CAACA,uBAAL,GAA+BE,SAA/B;;AACA,UAAA,MAAI,CAACtB,QAAL,CAAc;AAAE6B,YAAAA,OAAO,EAAE;AAAX,WAAd;AACA;;AAED,YAAI,MAAI,CAACH,uBAAT,EAAkC;AACjC,cAAMA,uBAAuB,GAAG,MAAI,CAACA,uBAArC;AACA,UAAA,MAAI,CAACA,uBAAL,GAA+BJ,SAA/B,CAFiC,CAGjC;AACA;AACA;AACA;;AACA3B,UAAAA,GAAG,CAAC,oCAAD,CAAH;AACA+B,UAAAA,uBAAuB;AACvB;AACD,OAnBoC,EAoBrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACAI,MAAAA,iCA5BqC,CAAtC;AA8BA,K,CAED;;;;WACA,yBAAgBJ,uBAAhB,EAAyC;AACxC,WAAKA,uBAAL,GAA+BA,uBAA/B;;AACA,UAAI,CAAC,KAAKE,oBAAV,EAAgC;AAC/B,aAAKP,oBAAL;AACA;AACD;AAED;AACD;AACA;AACA;;;;WACC,gCAAuB;AACtB,UAAMM,OAAO,GAAG,KAAKd,UAAL,EAAhB;AACA,aAAO;AACN;AACAI,QAAAA,GAAG,EAAEU,OAFC;AAGN;AACAR,QAAAA,MAAM,EAAEQ,OAAO,GAAG,KAAK7B,mBAAL,CAAyBoB,SAAzB;AAJZ,OAAP;AAMA;;;;;;SAlOmBtB,M;AAqOrB,IAAMkC,iCAAiC,GAAG,GAA1C","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'\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\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.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\tif (this.stopReportingScrollPositionChange) {\r\n\t\t\tthis.stopReportingScrollPositionChange()\r\n\t\t\tthis.stopReportingScrollPositionChange = undefined\r\n\t\t}\r\n\t\tif (this.stopListeningToScroll) {\r\n\t\t\tthis.stopListeningToScroll()\r\n\t\t\tthis.stopListeningToScroll = undefined\r\n\t\t}\r\n\t\tif (this.onStopScrollingListener) {\r\n\t\t\tthis.onStopScrollingListener = undefined\r\n\t\t}\r\n\t\tif (this.onScrollOnStopScrolling) {\r\n\t\t\tthis.onScrollOnStopScrolling = undefined\r\n\t\t}\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.onScrollOnStopScrolling = 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.onScrollOnStopScrolling) {\r\n\t\t\t\t\tthis.onScrollOnStopScrolling = undefined\r\n\t\t\t\t\tthis.onScroll({ delayed: true })\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (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\tonStopScrolling(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"],"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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ACA;IACA;IACA;;IAEA;AACD;AACA;AACA;;;;WACC,gCAAuB;MACtB,IAAMH,OAAO,GAAG,KAAKZ,UAAL,EAAhB;MACA,OAAO;QACN;QACAI,GAAG,EAAEQ,OAFC;QAGN;QACAN,MAAM,EAAEM,OAAO,GAAG,KAAK3B,mBAAL,CAAyBoB,SAAzB;MAJZ,CAAP;IAMA;;;;;;SA1NmBtB,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"}
|