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/commonjs/Scroll.js
CHANGED
|
@@ -7,7 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _requestAnimationFrameTimeout = require("request-animation-frame-timeout");
|
|
9
9
|
|
|
10
|
-
var _debug = _interopRequireDefault(require("./utility/debug"));
|
|
10
|
+
var _debug = _interopRequireDefault(require("./utility/debug.js"));
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
13
|
|
|
@@ -15,7 +15,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
15
15
|
|
|
16
16
|
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); } }
|
|
17
17
|
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
18
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
19
19
|
|
|
20
20
|
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; }
|
|
21
21
|
|
|
@@ -114,7 +114,7 @@ var Scroll = /*#__PURE__*/function () {
|
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
_this.
|
|
117
|
+
_this.shouldCallOnScrollListenerWhenStopsScrolling = true;
|
|
118
118
|
|
|
119
119
|
_this.watchOnStopScrolling();
|
|
120
120
|
});
|
|
@@ -136,10 +136,11 @@ var Scroll = /*#__PURE__*/function () {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
_createClass(Scroll, [{
|
|
139
|
-
key: "
|
|
140
|
-
value: function
|
|
139
|
+
key: "start",
|
|
140
|
+
value: function start() {
|
|
141
141
|
if (this.initialScrollPosition !== undefined) {
|
|
142
142
|
this.scrollToY(this.initialScrollPosition);
|
|
143
|
+
this.initialScrollPosition = undefined;
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
if (this.onScrollPositionChange) {
|
|
@@ -151,24 +152,10 @@ var Scroll = /*#__PURE__*/function () {
|
|
|
151
152
|
}, {
|
|
152
153
|
key: "stop",
|
|
153
154
|
value: function stop() {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
this.stopReportingScrollPositionChange = undefined;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (this.stopListeningToScroll) {
|
|
160
|
-
this.stopListeningToScroll();
|
|
161
|
-
this.stopListeningToScroll = undefined;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (this.onStopScrollingListener) {
|
|
165
|
-
this.onStopScrollingListener = undefined;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (this.onScrollOnStopScrolling) {
|
|
169
|
-
this.onScrollOnStopScrolling = undefined;
|
|
170
|
-
}
|
|
155
|
+
this.stopListeningToScroll();
|
|
156
|
+
this.stopListeningToScroll = undefined; // this.onStopScrollingListener = undefined
|
|
171
157
|
|
|
158
|
+
this.shouldCallOnScrollListenerWhenStopsScrolling = undefined;
|
|
172
159
|
this.cancelOnStopScrollingTimer();
|
|
173
160
|
}
|
|
174
161
|
}, {
|
|
@@ -205,24 +192,24 @@ var Scroll = /*#__PURE__*/function () {
|
|
|
205
192
|
this.onStopScrollingTimer = (0, _requestAnimationFrameTimeout.setTimeout)(function () {
|
|
206
193
|
_this2.onStopScrollingTimer = undefined;
|
|
207
194
|
|
|
208
|
-
if (_this2.
|
|
209
|
-
_this2.
|
|
195
|
+
if (_this2.shouldCallOnScrollListenerWhenStopsScrolling) {
|
|
196
|
+
_this2.shouldCallOnScrollListenerWhenStopsScrolling = undefined;
|
|
210
197
|
|
|
211
198
|
_this2.onScroll({
|
|
212
199
|
delayed: true
|
|
213
200
|
});
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
201
|
+
} // `onStopScrolling()` feature is not currently used.
|
|
202
|
+
// if (this.onStopScrollingListener) {
|
|
203
|
+
// const onStopScrollingListener = this.onStopScrollingListener
|
|
204
|
+
// this.onStopScrollingListener = undefined
|
|
205
|
+
// // `onStopScrollingListener()` may hypothetically schedule
|
|
206
|
+
// // another `onStopScrolling()` listener, so set
|
|
207
|
+
// // `this.onStopScrollingListener` to `undefined` before
|
|
208
|
+
// // calling it rather than after.
|
|
209
|
+
// log('~ The user has stopped scrolling ~')
|
|
210
|
+
// onStopScrollingListener()
|
|
211
|
+
// }
|
|
222
212
|
|
|
223
|
-
(0, _debug["default"])('~ The user has stopped scrolling ~');
|
|
224
|
-
onStopScrollingListener();
|
|
225
|
-
}
|
|
226
213
|
}, // "scroll" events are usually dispatched every 16 milliseconds
|
|
227
214
|
// for 60fps refresh rate, so waiting for 100 milliseconds feels
|
|
228
215
|
// reasonable: that would be about 6 frames of inactivity period,
|
|
@@ -233,16 +220,13 @@ var Scroll = /*#__PURE__*/function () {
|
|
|
233
220
|
// refreshed (cancelled and then re-created).
|
|
234
221
|
ON_STOP_SCROLLING_INACTIVE_PERIOD);
|
|
235
222
|
} // (this function isn't currently used)
|
|
223
|
+
// onStopScrolling(onStopScrollingListener) {
|
|
224
|
+
// this.onStopScrollingListener = onStopScrollingListener
|
|
225
|
+
// if (!this.onStopScrollingTimer) {
|
|
226
|
+
// this.watchOnStopScrolling()
|
|
227
|
+
// }
|
|
228
|
+
// }
|
|
236
229
|
|
|
237
|
-
}, {
|
|
238
|
-
key: "onStopScrolling",
|
|
239
|
-
value: function onStopScrolling(onStopScrollingListener) {
|
|
240
|
-
this.onStopScrollingListener = onStopScrollingListener;
|
|
241
|
-
|
|
242
|
-
if (!this.onStopScrollingTimer) {
|
|
243
|
-
this.watchOnStopScrolling();
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
230
|
/**
|
|
247
231
|
* Returns visible area coordinates relative to the scrollable container.
|
|
248
232
|
* @return {object} `{ top: number, bottom: number }`
|
package/commonjs/Scroll.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../source/Scroll.js"],"names":["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":";;;;;;;AAIA;;AAEA;;;;;;;;;;;;IAEqBA,M;AACpB,wBAeG;AAAA;;AAAA,QAdFC,MAcE,QAdFA,MAcE;AAAA,QAbFC,mBAaE,QAbFA,mBAaE;AAAA,QAZFC,cAYE,QAZFA,cAYE;AAAA,QAXFC,QAWE,QAXFA,QAWE;AAAA,QAVFC,qBAUE,QAVFA,qBAUE;AAAA,QATFC,sBASE,QATFA,sBASE;AAAA,QARFC,0BAQE,QARFA,0BAQE;AAAA,QAPFC,2BAOE,QAPFA,2BAOE;AAAA,QANFC,8BAME,QANFA,8BAME;AAAA,QALFC,0BAKE,QALFA,0BAKE;AAAA,QAJFC,gBAIE,QAJFA,gBAIE;AAAA,QAHFC,kBAGE,QAHFA,kBAGE;AAAA,QAFFC,eAEE,QAFFA,eAEE;AAAA,QADFC,sBACE,QADFA,sBACE;;AAAA;;AAAA,uCAmDS,UAACC,SAAD,EAAe;AAC1B,MAAA,KAAI,CAACC,SAAL,CAAe,KAAI,CAACC,UAAL,KAAoBF,SAAnC;AACA,KArDE;;AAAA,8CAuEgB,YAAM;AACxB,UAAI,KAAI,CAACT,sBAAT,EAAiC;AAChC,QAAA,KAAI,CAACA,sBAAL,CAA4B,KAAI,CAACW,U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AAM,EAAEQ,OAAO,GAAG,KAAK7B,mBAAL,CAAyBoB,SAAzB;AAJZ,OAAP;AAMA;;;;;;;AAGF,IAAMY,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":["Scroll","bypass","scrollableContainer","itemsContainer","onScroll","initialScrollPosition","onScrollPositionChange","isImmediateLayoutScheduled","hasNonRenderedItemsAtTheTop","hasNonRenderedItemsAtTheBottom","getLatestLayoutVisibleArea","getListTopOffset","getPrerenderMargin","onScrolledToTop","waitForScrollingToStop","scrollByY","scrollToY","getScrollY","ignoreScrollEvents","cancelOnStopScrollingTimer","forceUpdate","top","getHeight","bottom","log","shouldCallOnScrollListenerWhenStopsScrolling","watchOnStopScrolling","undefined","stopListeningToScroll","onScrollListener","scrollY","onStopScrollingTimer","clearTimeout","setTimeout","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":";;;;;;;AAIA;;AAEA;;;;;;;;;;;;IAEqBA,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,2BAOE;IAAA,IANFC,8BAME,QANFA,8BAME;IAAA,IALFC,0BAKE,QALFA,0BAKE;IAAA,IAJFC,gBAIE,QAJFA,gBAIE;IAAA,IAHFC,kBAGE,QAHFA,kBAGE;IAAA,IAFFC,eAEE,QAFFA,eAEE;IAAA,IADFC,sBACE,QADFA,sBACE;;IAAA;;IAAA,mCA0CS,UAACC,SAAD,EAAe;MAC1B,KAAI,CAACC,SAAL,CAAe,KAAI,CAACC,UAAL,KAAoBF,SAAnC;IACA,CA5CE;;IAAA,0CA8DgB,YAAM;MACxB,IAAI,KAAI,CAACT,sBAAT,EAAiC;QAChC,KAAI,CAACA,sBAAL,CAA4B,KAAI,CAACW,UAAL,EAA5B;MACA,CAHuB,CAKxB;MACA;;;MACA,IAAI,KAAI,CAACJ,eAAT,EAA0B;QACzB,IAAI,KAAI,CAACI,UAAL,KAAoB,KAAI,CAACN,gBAAL,EAAxB,EAAiD;UAChD,KAAI,CAACE,eAAL;QACA;MACD;;MAED,IAAI,KAAI,CAACZ,MAAT,EAAiB;QAChB;MACA;;MAED,IAAI,KAAI,CAACiB,kBAAT,EAA6B;QAC5B;MACA,CAnBuB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ACF,4CAAT,EAAuD;UACtD,MAAI,CAACA,4CAAL,GAAoDE,SAApD;;UACA,MAAI,CAACvB,QAAL,CAAc;YAAE8B,OAAO,EAAE;UAAX,CAAd;QACA,CANI,CAQL;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;MACA,CApB0B,EAqB3B;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACAC,iCA7B2B,CAA5B;IA+BA,C,CAED;IACA;IACA;IACA;IACA;IACA;IACA;;IAEA;AACD;AACA;AACA;;;;WACC,gCAAuB;MACtB,IAAML,OAAO,GAAG,KAAKb,UAAL,EAAhB;MACA,OAAO;QACN;QACAI,GAAG,EAAES,OAFC;QAGN;QACAP,MAAM,EAAEO,OAAO,GAAG,KAAK5B,mBAAL,CAAyBoB,SAAzB;MAJZ,CAAP;IAMA;;;;;;;AAGF,IAAMa,iCAAiC,GAAG,GAA1C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = createColumnsHelpers;
|
|
7
|
+
|
|
8
|
+
function createColumnsHelpers(_ref) {
|
|
9
|
+
var _this = this;
|
|
10
|
+
|
|
11
|
+
var getColumnsCount = _ref.getColumnsCount;
|
|
12
|
+
|
|
13
|
+
if (getColumnsCount) {
|
|
14
|
+
var scrollableContainerArgument = {
|
|
15
|
+
getWidth: function getWidth() {
|
|
16
|
+
return _this.scrollableContainer.getWidth();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
this.getActualColumnsCountForState = function () {
|
|
21
|
+
var columnsCount = getColumnsCount(scrollableContainerArgument); // `columnsCount: 1` is effectively same as `columnsCount: undefined`
|
|
22
|
+
// from the code's point of view. This makes one less property in `state`
|
|
23
|
+
// which makes `state` a bit less cluttered (easier for inspection).
|
|
24
|
+
|
|
25
|
+
if (columnsCount !== 1) {
|
|
26
|
+
return columnsCount;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
} else {
|
|
30
|
+
this.getActualColumnsCountForState = function () {
|
|
31
|
+
return undefined;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.getActualColumnsCount = function () {
|
|
36
|
+
return _this.getActualColumnsCountForState() || 1;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
this.getColumnsCount = function () {
|
|
40
|
+
return _this.getState() && _this.getState().columnsCount || 1;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# 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":";;;;;;;AAAe,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"}
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = VirtualScrollerConstructor;
|
|
9
|
+
|
|
10
|
+
var _tbody = require("./DOM/tbody.js");
|
|
11
|
+
|
|
12
|
+
var _Engine = _interopRequireDefault(require("./DOM/Engine.js"));
|
|
13
|
+
|
|
14
|
+
var _Layout = _interopRequireWildcard(require("./Layout.js"));
|
|
15
|
+
|
|
16
|
+
var _Resize = _interopRequireDefault(require("./Resize.js"));
|
|
17
|
+
|
|
18
|
+
var _BeforeResize = _interopRequireDefault(require("./BeforeResize.js"));
|
|
19
|
+
|
|
20
|
+
var _Scroll = _interopRequireDefault(require("./Scroll.js"));
|
|
21
|
+
|
|
22
|
+
var _ListHeightMeasurement = _interopRequireDefault(require("./ListHeightMeasurement.js"));
|
|
23
|
+
|
|
24
|
+
var _ItemHeights = _interopRequireDefault(require("./ItemHeights.js"));
|
|
25
|
+
|
|
26
|
+
var _debug = _interopRequireWildcard(require("./utility/debug.js"));
|
|
27
|
+
|
|
28
|
+
var _VirtualScrollerState = _interopRequireDefault(require("./VirtualScroller.state.js"));
|
|
29
|
+
|
|
30
|
+
var _VirtualScrollerVerticalSpacing = _interopRequireDefault(require("./VirtualScroller.verticalSpacing.js"));
|
|
31
|
+
|
|
32
|
+
var _VirtualScrollerColumns = _interopRequireDefault(require("./VirtualScroller.columns.js"));
|
|
33
|
+
|
|
34
|
+
var _VirtualScrollerLayout = _interopRequireDefault(require("./VirtualScroller.layout.js"));
|
|
35
|
+
|
|
36
|
+
var _VirtualScrollerOnRender = _interopRequireDefault(require("./VirtualScroller.onRender.js"));
|
|
37
|
+
|
|
38
|
+
var _VirtualScrollerResize = _interopRequireDefault(require("./VirtualScroller.resize.js"));
|
|
39
|
+
|
|
40
|
+
var _VirtualScrollerItems = _interopRequireDefault(require("./VirtualScroller.items.js"));
|
|
41
|
+
|
|
42
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
|
+
|
|
44
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
45
|
+
|
|
46
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {function} getItemsContainerElement — Returns the container DOM `Element`.
|
|
50
|
+
* @param {any[]} items — The list of items.
|
|
51
|
+
* @param {Object} [options] — See README.md.
|
|
52
|
+
* @return {VirtualScroller}
|
|
53
|
+
*/
|
|
54
|
+
function VirtualScrollerConstructor(getItemsContainerElement, items) {
|
|
55
|
+
var _this = this;
|
|
56
|
+
|
|
57
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
58
|
+
var render = options.render,
|
|
59
|
+
state = options.state,
|
|
60
|
+
onStateChange = options.onStateChange,
|
|
61
|
+
initialScrollPosition = options.initialScrollPosition,
|
|
62
|
+
onScrollPositionChange = options.onScrollPositionChange,
|
|
63
|
+
scrollableContainer = options.scrollableContainer,
|
|
64
|
+
_options$measureItems = options.measureItemsBatchSize,
|
|
65
|
+
measureItemsBatchSize = _options$measureItems === void 0 ? 50 : _options$measureItems,
|
|
66
|
+
getColumnsCount = options.getColumnsCount,
|
|
67
|
+
getItemId = options.getItemId,
|
|
68
|
+
tbody = options.tbody,
|
|
69
|
+
estimatedItemHeight = options.estimatedItemHeight,
|
|
70
|
+
onItemInitialRender = options.onItemInitialRender,
|
|
71
|
+
onItemFirstRender = options.onItemFirstRender,
|
|
72
|
+
_useTimeoutInRenderLoop = options._useTimeoutInRenderLoop,
|
|
73
|
+
_waitForScrollingToStop = options._waitForScrollingToStop,
|
|
74
|
+
engine = options.engine;
|
|
75
|
+
var bypass = options.bypass,
|
|
76
|
+
getScrollableContainer = options.getScrollableContainer;
|
|
77
|
+
(0, _debug["default"])('~ Initialize ~'); // Could support non-DOM rendering engines.
|
|
78
|
+
// For example, React Native, `<canvas/>`, etc.
|
|
79
|
+
|
|
80
|
+
this.engine = engine || _Engine["default"]; // `scrollableContainer` option is deprecated.
|
|
81
|
+
// Use `getScrollableContainer()` option instead.
|
|
82
|
+
|
|
83
|
+
if (!getScrollableContainer && scrollableContainer) {
|
|
84
|
+
getScrollableContainer = function getScrollableContainer() {
|
|
85
|
+
return scrollableContainer;
|
|
86
|
+
};
|
|
87
|
+
} // Sometimes, when `new VirtualScroller()` instance is created,
|
|
88
|
+
// `getItemsContainerElement()` might not be ready to return the "container" DOM Element yet
|
|
89
|
+
// (for example, because it's not rendered yet). That's the reason why it's a getter function.
|
|
90
|
+
// For example, in React `<VirtualScroller/>` component, a `VirtualScroller`
|
|
91
|
+
// instance is created in the React component's `constructor()`, and at that time
|
|
92
|
+
// the container Element is not yet available. The container Element is available
|
|
93
|
+
// in `componentDidMount()`, but `componentDidMount()` is not executed on server,
|
|
94
|
+
// which would mean that React `<VirtualScroller/>` wouldn't render at all
|
|
95
|
+
// on server side, while with the `getItemsContainerElement()` approach, on server side,
|
|
96
|
+
// it still "renders" a list with a predefined amount of items in it by default.
|
|
97
|
+
// (`initiallyRenderedItemsCount`, or `1`).
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
this.getItemsContainerElement = getItemsContainerElement; // if (prerenderMargin === undefined) {
|
|
101
|
+
// // Renders items which are outside of the screen by this "prerender margin".
|
|
102
|
+
// // Is the screen height by default: seems to be the optimal value
|
|
103
|
+
// // for "Page Up" / "Page Down" navigation and optimized mouse wheel scrolling.
|
|
104
|
+
// prerenderMargin = this.scrollableContainer ? this.scrollableContainer.getHeight() : 0
|
|
105
|
+
// }
|
|
106
|
+
|
|
107
|
+
if (options.getState || options.setState) {
|
|
108
|
+
throw new Error('[virtual-scroller] `getState`/`setState` options usage has changed in the new version. See the readme for more details.');
|
|
109
|
+
} // Work around `<tbody/>` not being able to have `padding`.
|
|
110
|
+
// https://gitlab.com/catamphetamine/virtual-scroller/-/issues/1
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
if (tbody) {
|
|
114
|
+
if (this.engine !== _Engine["default"]) {
|
|
115
|
+
throw new Error('[virtual-scroller] `tbody` option is only supported for DOM rendering engine');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
(0, _debug["default"])('~ <tbody/> detected ~');
|
|
119
|
+
this.tbody = true;
|
|
120
|
+
|
|
121
|
+
if (!(0, _tbody.supportsTbody)()) {
|
|
122
|
+
(0, _debug["default"])('~ <tbody/> not supported ~');
|
|
123
|
+
(0, _debug.reportError)(_tbody.BROWSER_NOT_SUPPORTED_ERROR);
|
|
124
|
+
bypass = true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (bypass) {
|
|
129
|
+
(0, _debug["default"])('~ "bypass" mode ~');
|
|
130
|
+
} // In `bypass` mode, `VirtualScroller` doesn't wait
|
|
131
|
+
// for the user to scroll down to render all items:
|
|
132
|
+
// instead, it renders all items right away, as if
|
|
133
|
+
// the list is rendered without using `VirtualScroller`.
|
|
134
|
+
// It was added just to measure how much is the
|
|
135
|
+
// performance difference between using a `VirtualScroller`
|
|
136
|
+
// and not using a `VirtualScroller`.
|
|
137
|
+
// It turned out that unmounting large React component trees
|
|
138
|
+
// is a very long process, so `VirtualScroller` does seem to
|
|
139
|
+
// make sense when used in a React application.
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
this.bypass = bypass; // this.bypassBatchSize = bypassBatchSize || 10
|
|
143
|
+
// Using `setTimeout()` in render loop is a workaround
|
|
144
|
+
// for avoiding a React error message:
|
|
145
|
+
// "Maximum update depth exceeded.
|
|
146
|
+
// This can happen when a component repeatedly calls
|
|
147
|
+
// `.setState()` inside `componentWillUpdate()` or `componentDidUpdate()`.
|
|
148
|
+
// React limits the number of nested updates to prevent infinite loops."
|
|
149
|
+
|
|
150
|
+
this._useTimeoutInRenderLoop = _useTimeoutInRenderLoop;
|
|
151
|
+
|
|
152
|
+
if (getItemId) {
|
|
153
|
+
this.isItemEqual = function (a, b) {
|
|
154
|
+
return getItemId(a) === getItemId(b);
|
|
155
|
+
};
|
|
156
|
+
} else {
|
|
157
|
+
this.isItemEqual = function (a, b) {
|
|
158
|
+
return a === b;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (onItemInitialRender) {
|
|
163
|
+
this.onItemInitialRender = onItemInitialRender;
|
|
164
|
+
} // `onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.
|
|
165
|
+
else if (onItemFirstRender) {
|
|
166
|
+
this.onItemInitialRender = function (item) {
|
|
167
|
+
(0, _debug.warn)('`onItemFirstRender(i)` is deprecated, use `onItemInitialRender(item)` instead.');
|
|
168
|
+
|
|
169
|
+
var _this$getState = _this.getState(),
|
|
170
|
+
items = _this$getState.items;
|
|
171
|
+
|
|
172
|
+
var i = items.indexOf(item); // The `item` could also be non-found due to the inconsistency bug:
|
|
173
|
+
// The reason is that `i` can be non-consistent with the `items`
|
|
174
|
+
// passed to `<VirtualScroller/>` in React due to `updateState()` not being
|
|
175
|
+
// instanteneous: when new `items` are passed to `<VirtualScroller/>`,
|
|
176
|
+
// `VirtualScroller.updateState({ items })` is called, and if `onItemFirstRender(i)`
|
|
177
|
+
// is called after the aforementioned `updateState()` is called but before it finishes,
|
|
178
|
+
// `i` would point to an index in "previous" `items` while the application
|
|
179
|
+
// would assume that `i` points to an index in the "new" `items`,
|
|
180
|
+
// resulting in an incorrect item being assumed by the application
|
|
181
|
+
// or even in an "array index out of bounds" error.
|
|
182
|
+
|
|
183
|
+
if (i >= 0) {
|
|
184
|
+
onItemFirstRender(i);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
} // If initial `state` is passed then use `items` from `state`
|
|
188
|
+
// instead of the `items` argument.
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
if (state) {
|
|
192
|
+
items = state.items;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
(0, _debug["default"])('Items count', items.length);
|
|
196
|
+
|
|
197
|
+
if (estimatedItemHeight) {
|
|
198
|
+
(0, _debug["default"])('Estimated item height', estimatedItemHeight);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
_VirtualScrollerState["default"].call(this, {
|
|
202
|
+
state: state,
|
|
203
|
+
onStateChange: onStateChange,
|
|
204
|
+
render: render,
|
|
205
|
+
items: items
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
_VirtualScrollerVerticalSpacing["default"].call(this);
|
|
209
|
+
|
|
210
|
+
_VirtualScrollerColumns["default"].call(this, {
|
|
211
|
+
getColumnsCount: getColumnsCount
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
_VirtualScrollerLayout["default"].call(this);
|
|
215
|
+
|
|
216
|
+
_VirtualScrollerOnRender["default"].call(this);
|
|
217
|
+
|
|
218
|
+
_VirtualScrollerResize["default"].call(this);
|
|
219
|
+
|
|
220
|
+
_VirtualScrollerItems["default"].call(this);
|
|
221
|
+
|
|
222
|
+
createHelpers.call(this, {
|
|
223
|
+
getScrollableContainer: getScrollableContainer,
|
|
224
|
+
estimatedItemHeight: estimatedItemHeight,
|
|
225
|
+
measureItemsBatchSize: measureItemsBatchSize,
|
|
226
|
+
initialScrollPosition: initialScrollPosition,
|
|
227
|
+
onScrollPositionChange: onScrollPositionChange,
|
|
228
|
+
waitForScrollingToStop: _waitForScrollingToStop
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
if (state) {
|
|
232
|
+
// Initialize `ItemHeights` from previously measured `state.itemHeights`.
|
|
233
|
+
this.itemHeights.readItemHeightsFromState(state); // Initialize some `BeforeResize` internal flags from a previously saved state.
|
|
234
|
+
|
|
235
|
+
this.beforeResize.initializeFromState(state);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function createHelpers(_ref) {
|
|
240
|
+
var _this2 = this;
|
|
241
|
+
|
|
242
|
+
var getScrollableContainer = _ref.getScrollableContainer,
|
|
243
|
+
estimatedItemHeight = _ref.estimatedItemHeight,
|
|
244
|
+
measureItemsBatchSize = _ref.measureItemsBatchSize,
|
|
245
|
+
initialScrollPosition = _ref.initialScrollPosition,
|
|
246
|
+
onScrollPositionChange = _ref.onScrollPositionChange,
|
|
247
|
+
waitForScrollingToStop = _ref.waitForScrollingToStop;
|
|
248
|
+
this.itemsContainer = this.engine.createItemsContainer(this.getItemsContainerElement); // If the items "container" element is mounted at this stage,
|
|
249
|
+
// remove any accidental text nodes from it (like whitespace).
|
|
250
|
+
//
|
|
251
|
+
// Also, this guards against cases when someone accidentally tries
|
|
252
|
+
// using `VirtualScroller` on a non-empty element.
|
|
253
|
+
//
|
|
254
|
+
|
|
255
|
+
if (this.getItemsContainerElement()) {
|
|
256
|
+
this.itemsContainer.clear();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
this.scrollableContainer = this.engine.createScrollableContainer(getScrollableContainer, this.getItemsContainerElement); // Create `ItemHeights` instance.
|
|
260
|
+
|
|
261
|
+
this.itemHeights = new _ItemHeights["default"]({
|
|
262
|
+
container: this.itemsContainer,
|
|
263
|
+
getItemHeight: function getItemHeight(i) {
|
|
264
|
+
return _this2.getState().itemHeights[i];
|
|
265
|
+
},
|
|
266
|
+
setItemHeight: function setItemHeight(i, height) {
|
|
267
|
+
return _this2.getState().itemHeights[i] = height;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
this.layout = new _Layout["default"]({
|
|
271
|
+
bypass: this.bypass,
|
|
272
|
+
estimatedItemHeight: estimatedItemHeight,
|
|
273
|
+
measureItemsBatchSize: measureItemsBatchSize,
|
|
274
|
+
getPrerenderMargin: function getPrerenderMargin() {
|
|
275
|
+
return _this2.getPrerenderMargin();
|
|
276
|
+
},
|
|
277
|
+
getVerticalSpacing: function getVerticalSpacing() {
|
|
278
|
+
return _this2.getVerticalSpacing();
|
|
279
|
+
},
|
|
280
|
+
getVerticalSpacingBeforeResize: function getVerticalSpacingBeforeResize() {
|
|
281
|
+
return _this2.getVerticalSpacingBeforeResize();
|
|
282
|
+
},
|
|
283
|
+
getColumnsCount: function getColumnsCount() {
|
|
284
|
+
return _this2.getColumnsCount();
|
|
285
|
+
},
|
|
286
|
+
getColumnsCountBeforeResize: function getColumnsCountBeforeResize() {
|
|
287
|
+
return _this2.getState().beforeResize && _this2.getState().beforeResize.columnsCount;
|
|
288
|
+
},
|
|
289
|
+
getItemHeight: function getItemHeight(i) {
|
|
290
|
+
return _this2.getState().itemHeights[i];
|
|
291
|
+
},
|
|
292
|
+
getItemHeightBeforeResize: function getItemHeightBeforeResize(i) {
|
|
293
|
+
return _this2.getState().beforeResize && _this2.getState().beforeResize.itemHeights[i];
|
|
294
|
+
},
|
|
295
|
+
getBeforeResizeItemsCount: function getBeforeResizeItemsCount() {
|
|
296
|
+
return _this2.getState().beforeResize ? _this2.getState().beforeResize.itemHeights.length : 0;
|
|
297
|
+
},
|
|
298
|
+
getAverageItemHeight: function getAverageItemHeight() {
|
|
299
|
+
return _this2.itemHeights.getAverage();
|
|
300
|
+
},
|
|
301
|
+
getMaxVisibleAreaHeight: function getMaxVisibleAreaHeight() {
|
|
302
|
+
return _this2.scrollableContainer && _this2.scrollableContainer.getHeight();
|
|
303
|
+
},
|
|
304
|
+
//
|
|
305
|
+
// The "previously calculated layout" feature is not currently used.
|
|
306
|
+
//
|
|
307
|
+
// The current layout snapshot could be stored as a "previously calculated layout" variable
|
|
308
|
+
// so that it could theoretically be used when calculating new layout incrementally
|
|
309
|
+
// rather than from scratch, which would be an optimization.
|
|
310
|
+
//
|
|
311
|
+
getPreviouslyCalculatedLayout: function getPreviouslyCalculatedLayout() {
|
|
312
|
+
return _this2.previouslyCalculatedLayout;
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
this.resize = new _Resize["default"]({
|
|
316
|
+
bypass: this.bypass,
|
|
317
|
+
getWidth: function getWidth() {
|
|
318
|
+
return _this2.scrollableContainer.getWidth();
|
|
319
|
+
},
|
|
320
|
+
getHeight: function getHeight() {
|
|
321
|
+
return _this2.scrollableContainer.getHeight();
|
|
322
|
+
},
|
|
323
|
+
listenForResize: function listenForResize(listener) {
|
|
324
|
+
return _this2.scrollableContainer.onResize(listener);
|
|
325
|
+
},
|
|
326
|
+
onResizeStart: function onResizeStart() {
|
|
327
|
+
(0, _debug["default"])('~ Scrollable container resize started ~');
|
|
328
|
+
_this2._isResizing = true;
|
|
329
|
+
},
|
|
330
|
+
onResizeStop: function onResizeStop() {
|
|
331
|
+
(0, _debug["default"])('~ Scrollable container resize finished ~');
|
|
332
|
+
_this2._isResizing = undefined;
|
|
333
|
+
},
|
|
334
|
+
onNoChange: function onNoChange() {
|
|
335
|
+
// There might have been some missed `this.onUpdateShownItemIndexes()` calls
|
|
336
|
+
// due to setting `this._isResizing` flag to `true` during the resize.
|
|
337
|
+
// So, update shown item indexes just in case.
|
|
338
|
+
_this2.onUpdateShownItemIndexes({
|
|
339
|
+
reason: _Layout.LAYOUT_REASON.VIEWPORT_SIZE_UNCHANGED
|
|
340
|
+
});
|
|
341
|
+
},
|
|
342
|
+
onHeightChange: function onHeightChange() {
|
|
343
|
+
return _this2.onUpdateShownItemIndexes({
|
|
344
|
+
reason: _Layout.LAYOUT_REASON.VIEWPORT_HEIGHT_CHANGED
|
|
345
|
+
});
|
|
346
|
+
},
|
|
347
|
+
onWidthChange: function onWidthChange(prevWidth, newWidth) {
|
|
348
|
+
(0, _debug["default"])('~ Scrollable container width changed from', prevWidth, 'to', newWidth, '~');
|
|
349
|
+
|
|
350
|
+
_this2.onResize();
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
this.scroll = new _Scroll["default"]({
|
|
354
|
+
bypass: this.bypass,
|
|
355
|
+
scrollableContainer: this.scrollableContainer,
|
|
356
|
+
itemsContainer: this.itemsContainer,
|
|
357
|
+
waitForScrollingToStop: waitForScrollingToStop,
|
|
358
|
+
onScroll: function onScroll() {
|
|
359
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
360
|
+
delayed = _ref2.delayed;
|
|
361
|
+
|
|
362
|
+
_this2.onUpdateShownItemIndexes({
|
|
363
|
+
reason: delayed ? _Layout.LAYOUT_REASON.STOPPED_SCROLLING : _Layout.LAYOUT_REASON.SCROLL
|
|
364
|
+
});
|
|
365
|
+
},
|
|
366
|
+
initialScrollPosition: initialScrollPosition,
|
|
367
|
+
onScrollPositionChange: onScrollPositionChange,
|
|
368
|
+
isImmediateLayoutScheduled: function isImmediateLayoutScheduled() {
|
|
369
|
+
return Boolean(_this2.layoutTimer);
|
|
370
|
+
},
|
|
371
|
+
hasNonRenderedItemsAtTheTop: function hasNonRenderedItemsAtTheTop() {
|
|
372
|
+
return _this2.getState().firstShownItemIndex > 0;
|
|
373
|
+
},
|
|
374
|
+
hasNonRenderedItemsAtTheBottom: function hasNonRenderedItemsAtTheBottom() {
|
|
375
|
+
return _this2.getState().lastShownItemIndex < _this2.getItemsCount() - 1;
|
|
376
|
+
},
|
|
377
|
+
getLatestLayoutVisibleArea: function getLatestLayoutVisibleArea() {
|
|
378
|
+
return _this2.latestLayoutVisibleArea;
|
|
379
|
+
},
|
|
380
|
+
getListTopOffset: this.getListTopOffsetInsideScrollableContainer,
|
|
381
|
+
getPrerenderMargin: function getPrerenderMargin() {
|
|
382
|
+
return _this2.getPrerenderMargin();
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
this.listHeightMeasurement = new _ListHeightMeasurement["default"]({
|
|
386
|
+
itemsContainer: this.itemsContainer,
|
|
387
|
+
getListTopOffset: this.getListTopOffsetInsideScrollableContainer
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
if (this.engine.watchListTopOffset) {
|
|
391
|
+
this.listTopOffsetWatcher = this.engine.watchListTopOffset({
|
|
392
|
+
getListTopOffset: this.getListTopOffsetInsideScrollableContainer,
|
|
393
|
+
onListTopOffsetChange: function onListTopOffsetChange(_ref3) {
|
|
394
|
+
var reason = _ref3.reason;
|
|
395
|
+
return _this2.onUpdateShownItemIndexes({
|
|
396
|
+
reason: _Layout.LAYOUT_REASON.TOP_OFFSET_CHANGED
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
this.beforeResize = new _BeforeResize["default"]({
|
|
403
|
+
getState: this.getState,
|
|
404
|
+
getVerticalSpacing: this.getVerticalSpacing,
|
|
405
|
+
getColumnsCount: this.getColumnsCount
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
//# sourceMappingURL=VirtualScroller.constructor.js.map
|