virtual-scroller 1.7.9 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +1 -1
- package/CHANGELOG.md +71 -1
- package/README.md +434 -151
- package/bundle/index-bypass.html +1 -1
- package/bundle/index-dom.html +1 -1
- package/bundle/index-grid.html +1 -2
- package/bundle/index-scrollableContainer.html +1 -1
- package/bundle/index-tbody-scrollableContainer.html +2 -0
- package/bundle/index-tbody.html +2 -0
- 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 +315 -0
- package/commonjs/BeforeResize.js.map +1 -0
- package/commonjs/DOM/Engine.js +46 -0
- package/commonjs/DOM/Engine.js.map +1 -0
- package/commonjs/DOM/ItemsContainer.js +78 -0
- package/commonjs/DOM/ItemsContainer.js.map +1 -0
- package/commonjs/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +71 -44
- package/commonjs/DOM/ListTopOffsetWatcher.js.map +1 -0
- package/commonjs/DOM/ScrollableContainer.js +69 -101
- package/commonjs/DOM/ScrollableContainer.js.map +1 -1
- package/commonjs/DOM/VirtualScroller.js +37 -29
- package/commonjs/DOM/VirtualScroller.js.map +1 -1
- package/commonjs/DOM/tbody.js +17 -11
- package/commonjs/DOM/tbody.js.map +1 -1
- package/commonjs/ItemHeights.js +33 -34
- package/commonjs/ItemHeights.js.map +1 -1
- package/commonjs/Layout.js +591 -216
- package/commonjs/Layout.js.map +1 -1
- package/commonjs/Layout.test.js +196 -0
- package/commonjs/Layout.test.js.map +1 -0
- package/commonjs/ListHeightMeasurement.js +124 -0
- package/commonjs/ListHeightMeasurement.js.map +1 -0
- package/commonjs/Resize.js +50 -39
- package/commonjs/Resize.js.map +1 -1
- package/commonjs/Scroll.js +139 -95
- 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 +160 -1021
- 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 +8 -8
- package/commonjs/getVerticalSpacing.js.map +1 -1
- package/commonjs/package.json +5 -0
- package/commonjs/react/VirtualScroller.js +182 -628
- 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 +28 -6
- package/commonjs/utility/debounce.js.map +1 -1
- package/commonjs/utility/debug.js +51 -12
- package/commonjs/utility/debug.js.map +1 -1
- package/commonjs/utility/getStateSnapshot.js +50 -0
- package/commonjs/utility/getStateSnapshot.js.map +1 -0
- package/commonjs/utility/px.js +1 -1
- package/commonjs/utility/px.js.map +1 -1
- package/commonjs/utility/px.test.js +14 -0
- package/commonjs/utility/px.test.js.map +1 -0
- 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 +25 -0
- 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 +99 -0
- package/index.js +1 -1
- package/modules/BeforeResize.js +305 -0
- package/modules/BeforeResize.js.map +1 -0
- package/modules/DOM/Engine.js +27 -0
- package/modules/DOM/Engine.js.map +1 -0
- package/modules/DOM/ItemsContainer.js +71 -0
- package/modules/DOM/ItemsContainer.js.map +1 -0
- package/modules/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +72 -44
- package/modules/DOM/ListTopOffsetWatcher.js.map +1 -0
- package/modules/DOM/ScrollableContainer.js +68 -100
- package/modules/DOM/ScrollableContainer.js.map +1 -1
- package/modules/DOM/VirtualScroller.js +32 -28
- 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 +28 -33
- package/modules/ItemHeights.js.map +1 -1
- package/modules/Layout.js +585 -214
- package/modules/Layout.js.map +1 -1
- package/modules/Layout.test.js +190 -0
- package/modules/Layout.test.js.map +1 -0
- package/modules/ListHeightMeasurement.js +117 -0
- package/modules/ListHeightMeasurement.js.map +1 -0
- package/modules/Resize.js +50 -39
- package/modules/Resize.js.map +1 -1
- package/modules/Scroll.js +139 -94
- 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 +159 -1014
- 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 +8 -8
- package/modules/getVerticalSpacing.js.map +1 -1
- package/modules/react/VirtualScroller.js +179 -634
- 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 +28 -6
- package/modules/utility/debounce.js.map +1 -1
- package/modules/utility/debug.js +47 -10
- package/modules/utility/debug.js.map +1 -1
- package/modules/utility/getStateSnapshot.js +43 -0
- package/modules/utility/getStateSnapshot.js.map +1 -0
- package/modules/utility/px.js +1 -1
- package/modules/utility/px.js.map +1 -1
- package/modules/utility/px.test.js +9 -0
- package/modules/utility/px.test.js.map +1 -0
- 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 +54 -29
- package/react/index.cjs +4 -0
- package/react/index.cjs.js +9 -0
- package/react/index.d.ts +28 -0
- 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 +312 -0
- package/source/DOM/Engine.js +30 -0
- package/source/DOM/ItemsContainer.js +48 -0
- package/source/DOM/{WaitForStylesToLoad.js → ListTopOffsetWatcher.js} +61 -30
- package/source/DOM/ScrollableContainer.js +51 -73
- package/source/DOM/VirtualScroller.js +33 -18
- package/source/DOM/tbody.js +30 -21
- package/source/ItemHeights.js +27 -27
- package/source/Layout.js +629 -252
- package/source/Layout.test.js +176 -0
- package/source/ListHeightMeasurement.js +95 -0
- package/source/Resize.js +56 -32
- package/source/Scroll.js +135 -82
- 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 +162 -936
- 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/getVerticalSpacing.js +7 -7
- package/source/react/VirtualScroller.js +243 -603
- 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 +22 -5
- package/source/utility/debug.js +34 -3
- package/source/utility/getStateSnapshot.js +36 -0
- package/source/utility/px.js +1 -1
- package/source/utility/px.test.js +9 -0
- package/website/index-bypass.html +195 -0
- package/website/index-grid.html +0 -1
- package/website/index-scrollableContainer.html +208 -0
- package/website/index-tbody-scrollableContainer.html +68 -0
- package/website/index-tbody.html +55 -0
- package/commonjs/DOM/RenderingEngine.js +0 -33
- package/commonjs/DOM/RenderingEngine.js.map +0 -1
- package/commonjs/DOM/Screen.js +0 -87
- package/commonjs/DOM/Screen.js.map +0 -1
- package/commonjs/DOM/WaitForStylesToLoad.js.map +0 -1
- package/commonjs/RestoreScroll.js +0 -118
- package/commonjs/RestoreScroll.js.map +0 -1
- package/dom/index.commonjs.js +0 -4
- package/index.commonjs.js +0 -4
- package/modules/DOM/RenderingEngine.js +0 -19
- package/modules/DOM/RenderingEngine.js.map +0 -1
- package/modules/DOM/Screen.js +0 -80
- package/modules/DOM/Screen.js.map +0 -1
- package/modules/DOM/WaitForStylesToLoad.js.map +0 -1
- package/modules/RestoreScroll.js +0 -111
- package/modules/RestoreScroll.js.map +0 -1
- package/react/index.commonjs.js +0 -4
- package/source/DOM/RenderingEngine.js +0 -22
- package/source/DOM/Screen.js +0 -51
- package/source/RestoreScroll.js +0 -86
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _VirtualScroller = _interopRequireDefault(require("../VirtualScroller.js"));
|
|
9
|
+
|
|
10
|
+
var _Engine = _interopRequireDefault(require("./Engine.js"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
+
|
|
22
|
+
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); } }
|
|
23
|
+
|
|
24
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
|
+
|
|
26
|
+
var DEBUG = false;
|
|
27
|
+
|
|
28
|
+
var TestVirtualScroller = /*#__PURE__*/function () {
|
|
29
|
+
function TestVirtualScroller(_ref) {
|
|
30
|
+
var _this = this;
|
|
31
|
+
|
|
32
|
+
var scrollableContainerWidth = _ref.screenWidth,
|
|
33
|
+
scrollableContainerHeight = _ref.screenHeight,
|
|
34
|
+
columnsCount = _ref.columnsCount,
|
|
35
|
+
verticalSpacing = _ref.verticalSpacing,
|
|
36
|
+
items = _ref.items,
|
|
37
|
+
initialState = _ref.state;
|
|
38
|
+
|
|
39
|
+
_classCallCheck(this, TestVirtualScroller);
|
|
40
|
+
|
|
41
|
+
this.expectedStateUpdates = [];
|
|
42
|
+
var scrollableContainerElement = {
|
|
43
|
+
width: scrollableContainerWidth,
|
|
44
|
+
height: scrollableContainerHeight
|
|
45
|
+
};
|
|
46
|
+
var containerElement = {
|
|
47
|
+
paddingTop: 0,
|
|
48
|
+
paddingBottom: 0,
|
|
49
|
+
width: scrollableContainerElement.width,
|
|
50
|
+
children: []
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
this.setScrollableContainerWidth = function (width) {
|
|
54
|
+
scrollableContainerElement.width = width;
|
|
55
|
+
containerElement.width = width;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
this.setScrollableContainerHeight = function (height) {
|
|
59
|
+
scrollableContainerElement.height = height;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var getItemsContainerElement = function getItemsContainerElement() {
|
|
63
|
+
return containerElement;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
this.__columnsCount = columnsCount;
|
|
67
|
+
|
|
68
|
+
var getColumnsCount = function getColumnsCount() {
|
|
69
|
+
return _this.__columnsCount;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
var getItemWidth = function getItemWidth() {
|
|
73
|
+
return scrollableContainerElement.width / getColumnsCount();
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
this.hasPausedStateUpdates = undefined;
|
|
77
|
+
this.pausedStateUpdate = undefined;
|
|
78
|
+
this.pausedStateUpdateAction = undefined;
|
|
79
|
+
|
|
80
|
+
var onBeforeUpdateState = function onBeforeUpdateState(stateUpdate) {
|
|
81
|
+
if (_this.expectedStateUpdates.length > 0) {
|
|
82
|
+
var expectedStateUpdate = _this.expectedStateUpdates.shift();
|
|
83
|
+
|
|
84
|
+
expect(stateUpdate).to.deep.equal(expectedStateUpdate.stateUpdate);
|
|
85
|
+
|
|
86
|
+
if (expectedStateUpdate.callback) {
|
|
87
|
+
expectedStateUpdate.callback();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
var render = function render() {
|
|
93
|
+
var _this$virtualScroller = _this.virtualScroller.getState(),
|
|
94
|
+
items = _this$virtualScroller.items,
|
|
95
|
+
beforeItemsHeight = _this$virtualScroller.beforeItemsHeight,
|
|
96
|
+
afterItemsHeight = _this$virtualScroller.afterItemsHeight,
|
|
97
|
+
firstShownItemIndex = _this$virtualScroller.firstShownItemIndex,
|
|
98
|
+
lastShownItemIndex = _this$virtualScroller.lastShownItemIndex;
|
|
99
|
+
|
|
100
|
+
console.log('~ Render List ~');
|
|
101
|
+
containerElement.paddingTop = beforeItemsHeight;
|
|
102
|
+
containerElement.paddingBottom = afterItemsHeight;
|
|
103
|
+
containerElement.children = items.slice(firstShownItemIndex, lastShownItemIndex + 1).map(function (item) {
|
|
104
|
+
return {
|
|
105
|
+
width: getItemWidth(),
|
|
106
|
+
height: item.area / getItemWidth(),
|
|
107
|
+
marginTop: verticalSpacing
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
this.virtualScroller = new _VirtualScroller["default"](getItemsContainerElement, items, {
|
|
113
|
+
scrollableContainer: scrollableContainerElement,
|
|
114
|
+
engine: _Engine["default"],
|
|
115
|
+
_waitForScrollingToStop: false,
|
|
116
|
+
getColumnsCount: getColumnsCount,
|
|
117
|
+
state: initialState,
|
|
118
|
+
onStateChange: function onStateChange(state) {
|
|
119
|
+
if (DEBUG) {
|
|
120
|
+
console.log('~ Updated State ~');
|
|
121
|
+
console.log(state);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
var state = this.virtualScroller.getInitialState();
|
|
126
|
+
this.virtualScroller.useState({
|
|
127
|
+
getState: function getState() {
|
|
128
|
+
return state;
|
|
129
|
+
},
|
|
130
|
+
updateState: function updateState(stateUpdate) {
|
|
131
|
+
var stateUpdateAction = function stateUpdateAction(stateUpdate) {
|
|
132
|
+
// Is only used in tests.
|
|
133
|
+
if (onBeforeUpdateState) {
|
|
134
|
+
onBeforeUpdateState(stateUpdate);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
state = _objectSpread(_objectSpread({}, state), stateUpdate);
|
|
138
|
+
render();
|
|
139
|
+
|
|
140
|
+
_this.virtualScroller.onRender();
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
if (_this.hasPausedStateUpdates) {
|
|
144
|
+
_this.pausedStateUpdate = _objectSpread(_objectSpread({}, _this.pausedStateUpdate), stateUpdate);
|
|
145
|
+
_this.pausedStateUpdateAction = stateUpdateAction;
|
|
146
|
+
} else {
|
|
147
|
+
stateUpdateAction(stateUpdate);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
render();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_createClass(TestVirtualScroller, [{
|
|
155
|
+
key: "pauseStateUpdates",
|
|
156
|
+
value: function pauseStateUpdates() {
|
|
157
|
+
if (this.hasPausedStateUpdates) {
|
|
158
|
+
throw new Error('[virtual-scroller] State updates have already been paused');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
this.hasPausedStateUpdates = true;
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "resumeStateUpdates",
|
|
165
|
+
value: function resumeStateUpdates() {
|
|
166
|
+
if (this.pausedStateUpdate) {
|
|
167
|
+
this.pausedStateUpdateAction(this.pausedStateUpdate);
|
|
168
|
+
this.pausedStateUpdate = undefined;
|
|
169
|
+
this.pausedStateUpdateAction = undefined;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
this.hasPausedStateUpdates = false;
|
|
173
|
+
}
|
|
174
|
+
}, {
|
|
175
|
+
key: "verifyState",
|
|
176
|
+
value: function verifyState(expectedState) {
|
|
177
|
+
// `mocha`/`chai`.
|
|
178
|
+
this.virtualScroller.getState().should.deep.include(expectedState);
|
|
179
|
+
}
|
|
180
|
+
}, {
|
|
181
|
+
key: "expectStateUpdate",
|
|
182
|
+
value: function expectStateUpdate(stateUpdate, callback) {
|
|
183
|
+
this.expectedStateUpdates.push({
|
|
184
|
+
stateUpdate: stateUpdate,
|
|
185
|
+
callback: callback
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "getFirstNonMeasuredItemIndex",
|
|
190
|
+
value: function getFirstNonMeasuredItemIndex() {
|
|
191
|
+
return this.virtualScroller.firstNonMeasuredItemIndex;
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "getScrollY",
|
|
195
|
+
value: function getScrollY() {
|
|
196
|
+
return this.virtualScroller.scrollableContainer.getScrollY();
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
key: "scrollTo",
|
|
200
|
+
value: function scrollTo(scrollPosition) {
|
|
201
|
+
this.virtualScroller.scrollableContainer.scrollToY(scrollPosition);
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
key: "resize",
|
|
205
|
+
value: function resize(_ref2) {
|
|
206
|
+
var scrollableContainerWidth = _ref2.screenWidth,
|
|
207
|
+
scrollableContainerHeight = _ref2.screenHeight,
|
|
208
|
+
columnsCount = _ref2.columnsCount;
|
|
209
|
+
// Resize scrollable container.
|
|
210
|
+
this.setScrollableContainerWidth(scrollableContainerWidth);
|
|
211
|
+
this.setScrollableContainerHeight(scrollableContainerHeight); // Update columns count.
|
|
212
|
+
|
|
213
|
+
this.__columnsCount = columnsCount;
|
|
214
|
+
} // Returns a `Promise`.
|
|
215
|
+
|
|
216
|
+
}, {
|
|
217
|
+
key: "triggerResize",
|
|
218
|
+
value: function triggerResize(_ref3) {
|
|
219
|
+
var screenWidth = _ref3.screenWidth,
|
|
220
|
+
screenHeight = _ref3.screenHeight,
|
|
221
|
+
columnsCount = _ref3.columnsCount,
|
|
222
|
+
verticalSpacing = _ref3.verticalSpacing;
|
|
223
|
+
this.resize({
|
|
224
|
+
screenWidth: screenWidth,
|
|
225
|
+
screenHeight: screenHeight,
|
|
226
|
+
columnsCount: columnsCount,
|
|
227
|
+
verticalSpacing: verticalSpacing
|
|
228
|
+
}); // Call "on resize" listener.
|
|
229
|
+
|
|
230
|
+
return this.virtualScroller.scrollableContainer._triggerResizeListener();
|
|
231
|
+
}
|
|
232
|
+
}, {
|
|
233
|
+
key: "stop",
|
|
234
|
+
value: function stop() {
|
|
235
|
+
if (this.expectedStateUpdates.length > 0) {
|
|
236
|
+
throw new Error("[virtual-scroller] Expected ".concat(this.expectedStateUpdates.length, " state updates which didn't happen:\n").concat(JSON.stringify(this.expectedStateUpdates, null, 2)));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (this.pausedStateUpdate) {
|
|
240
|
+
throw new Error('[virtual-scroller] State updates were paused and haven\'t been resumed afterwards');
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
this.virtualScroller.stop();
|
|
244
|
+
}
|
|
245
|
+
}, {
|
|
246
|
+
key: "start",
|
|
247
|
+
value: function start() {
|
|
248
|
+
this.virtualScroller.start();
|
|
249
|
+
}
|
|
250
|
+
}, {
|
|
251
|
+
key: "getState",
|
|
252
|
+
value: function getState() {
|
|
253
|
+
return this.virtualScroller.getState();
|
|
254
|
+
}
|
|
255
|
+
}, {
|
|
256
|
+
key: "updateLayout",
|
|
257
|
+
value: function updateLayout() {
|
|
258
|
+
this.virtualScroller.updateLayout();
|
|
259
|
+
}
|
|
260
|
+
}, {
|
|
261
|
+
key: "getItemScrollPosition",
|
|
262
|
+
value: function getItemScrollPosition(i) {
|
|
263
|
+
return this.virtualScroller.getItemScrollPosition(i);
|
|
264
|
+
}
|
|
265
|
+
}, {
|
|
266
|
+
key: "getAverageItemHeight",
|
|
267
|
+
value: function getAverageItemHeight() {
|
|
268
|
+
return this.virtualScroller.itemHeights.getAverage();
|
|
269
|
+
}
|
|
270
|
+
}, {
|
|
271
|
+
key: "setItems",
|
|
272
|
+
value: function setItems(newItems, options) {
|
|
273
|
+
this.virtualScroller.setItems(newItems, options);
|
|
274
|
+
}
|
|
275
|
+
}]);
|
|
276
|
+
|
|
277
|
+
return TestVirtualScroller;
|
|
278
|
+
}();
|
|
279
|
+
|
|
280
|
+
exports["default"] = TestVirtualScroller;
|
|
281
|
+
//# sourceMappingURL=VirtualScroller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualScroller.js","names":["DEBUG","TestVirtualScroller","scrollableContainerWidth","screenWidth","scrollableContainerHeight","screenHeight","columnsCount","verticalSpacing","items","initialState","state","expectedStateUpdates","scrollableContainerElement","width","height","containerElement","paddingTop","paddingBottom","children","setScrollableContainerWidth","setScrollableContainerHeight","getItemsContainerElement","__columnsCount","getColumnsCount","getItemWidth","hasPausedStateUpdates","undefined","pausedStateUpdate","pausedStateUpdateAction","onBeforeUpdateState","stateUpdate","length","expectedStateUpdate","shift","expect","to","deep","equal","callback","render","virtualScroller","getState","beforeItemsHeight","afterItemsHeight","firstShownItemIndex","lastShownItemIndex","console","log","slice","map","item","area","marginTop","VirtualScroller","scrollableContainer","engine","Engine","_waitForScrollingToStop","onStateChange","getInitialState","useState","updateState","stateUpdateAction","onRender","Error","expectedState","should","include","push","firstNonMeasuredItemIndex","getScrollY","scrollPosition","scrollToY","resize","_triggerResizeListener","JSON","stringify","stop","start","updateLayout","i","getItemScrollPosition","itemHeights","getAverage","newItems","options","setItems"],"sources":["../../source/test/VirtualScroller.js"],"sourcesContent":["import VirtualScroller from '../VirtualScroller.js'\r\nimport Engine from './Engine.js'\r\n\r\nconst DEBUG = false\r\n\r\nexport default class TestVirtualScroller {\r\n\tconstructor({\r\n\t\tscreenWidth: scrollableContainerWidth,\r\n\t\tscreenHeight: scrollableContainerHeight,\r\n\t\tcolumnsCount,\r\n\t\tverticalSpacing,\r\n\t\titems,\r\n\t\tstate: initialState\r\n\t}) {\r\n\t\tthis.expectedStateUpdates = []\r\n\r\n\t\tconst scrollableContainerElement = {\r\n\t\t\twidth: scrollableContainerWidth,\r\n\t\t\theight: scrollableContainerHeight\r\n\t\t}\r\n\r\n\t\tconst containerElement = {\r\n\t\t\tpaddingTop: 0,\r\n\t\t\tpaddingBottom: 0,\r\n\t\t\twidth: scrollableContainerElement.width,\r\n\t\t\tchildren: []\r\n\t\t}\r\n\r\n\t\tthis.setScrollableContainerWidth = (width) => {\r\n\t\t\tscrollableContainerElement.width = width\r\n\t\t\tcontainerElement.width = width\r\n\t\t}\r\n\r\n\t\tthis.setScrollableContainerHeight = (height) => {\r\n\t\t\tscrollableContainerElement.height = height\r\n\t\t}\r\n\r\n\t\tconst getItemsContainerElement = () => containerElement\r\n\r\n\t\tthis.__columnsCount = columnsCount\r\n\r\n\t\tconst getColumnsCount = () => this.__columnsCount\r\n\t\tconst getItemWidth = () => scrollableContainerElement.width / getColumnsCount()\r\n\r\n\t\tthis.hasPausedStateUpdates = undefined\r\n\t\tthis.pausedStateUpdate = undefined\r\n\t\tthis.pausedStateUpdateAction = undefined\r\n\r\n\t\tconst onBeforeUpdateState = (stateUpdate) => {\r\n\t\t\tif (this.expectedStateUpdates.length > 0) {\r\n\t\t\t\tconst expectedStateUpdate = this.expectedStateUpdates.shift()\r\n\t\t\t\texpect(stateUpdate).to.deep.equal(expectedStateUpdate.stateUpdate)\r\n\t\t\t\tif (expectedStateUpdate.callback) {\r\n\t\t\t\t\texpectedStateUpdate.callback()\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst render = () => {\r\n\t\t\tconst {\r\n\t\t\t\titems,\r\n\t\t\t\tbeforeItemsHeight,\r\n\t\t\t\tafterItemsHeight,\r\n\t\t\t\tfirstShownItemIndex,\r\n\t\t\t\tlastShownItemIndex\r\n\t\t\t} = this.virtualScroller.getState()\r\n\r\n\t\t\tconsole.log('~ Render List ~')\r\n\r\n\t\t\tcontainerElement.paddingTop = beforeItemsHeight\r\n\t\t\tcontainerElement.paddingBottom = afterItemsHeight\r\n\r\n\t\t\tcontainerElement.children = items\r\n\t\t\t\t.slice(firstShownItemIndex, lastShownItemIndex + 1)\r\n\t\t\t\t.map((item) => ({\r\n\t\t\t\t\twidth: getItemWidth(),\r\n\t\t\t\t\theight: item.area / getItemWidth(),\r\n\t\t\t\t\tmarginTop: verticalSpacing\r\n\t\t\t\t}))\r\n\t\t}\r\n\r\n\t\tthis.virtualScroller = new VirtualScroller(getItemsContainerElement, items, {\r\n\t\t\tscrollableContainer: scrollableContainerElement,\r\n\t\t\tengine: Engine,\r\n\t\t\t_waitForScrollingToStop: false,\r\n\t\t\tgetColumnsCount,\r\n\t\t\tstate: initialState,\r\n\t\t\tonStateChange(state) {\r\n\t\t\t\tif (DEBUG) {\r\n\t\t\t\t\tconsole.log('~ Updated State ~')\r\n\t\t\t\t\tconsole.log(state)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\tlet state = this.virtualScroller.getInitialState()\r\n\r\n\t\tthis.virtualScroller.useState({\r\n\t\t\tgetState: () => state,\r\n\t\t\tupdateState: (stateUpdate) => {\r\n\t\t\t\tconst stateUpdateAction = (stateUpdate) => {\r\n\t\t\t\t\t// Is only used in tests.\r\n\t\t\t\t\tif (onBeforeUpdateState) {\r\n\t\t\t\t\t\tonBeforeUpdateState(stateUpdate)\r\n\t\t\t\t\t}\r\n\t\t\t\t\tstate = {\r\n\t\t\t\t\t\t...state,\r\n\t\t\t\t\t\t...stateUpdate\r\n\t\t\t\t\t}\r\n\t\t\t\t\trender()\r\n\t\t\t\t\tthis.virtualScroller.onRender()\r\n\t\t\t\t}\r\n\t\t\t\tif (this.hasPausedStateUpdates) {\r\n\t\t\t\t\tthis.pausedStateUpdate = {\r\n\t\t\t\t\t\t...this.pausedStateUpdate,\r\n\t\t\t\t\t\t...stateUpdate\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.pausedStateUpdateAction = stateUpdateAction\r\n\t\t\t\t} else {\r\n\t\t\t\t\tstateUpdateAction(stateUpdate)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\trender()\r\n\t}\r\n\r\n\tpauseStateUpdates() {\r\n\t\tif (this.hasPausedStateUpdates) {\r\n\t\t\tthrow new Error('[virtual-scroller] State updates have already been paused')\r\n\t\t}\r\n\t\tthis.hasPausedStateUpdates = true\r\n\t}\r\n\r\n\tresumeStateUpdates() {\r\n\t\tif (this.pausedStateUpdate) {\r\n\t\t\tthis.pausedStateUpdateAction(this.pausedStateUpdate)\r\n\t\t\tthis.pausedStateUpdate = undefined\r\n\t\t\tthis.pausedStateUpdateAction = undefined\r\n\t\t}\r\n\t\tthis.hasPausedStateUpdates = false\r\n\t}\r\n\r\n\tverifyState(expectedState) {\r\n\t\t// `mocha`/`chai`.\r\n\t\tthis.virtualScroller.getState().should.deep.include(expectedState)\r\n\t}\r\n\r\n\texpectStateUpdate(stateUpdate, callback) {\r\n\t\tthis.expectedStateUpdates.push({\r\n\t\t\tstateUpdate,\r\n\t\t\tcallback\r\n\t\t})\r\n\t}\r\n\r\n\tgetFirstNonMeasuredItemIndex() {\r\n\t\treturn this.virtualScroller.firstNonMeasuredItemIndex\r\n\t}\r\n\r\n\tgetScrollY() {\r\n\t\treturn this.virtualScroller.scrollableContainer.getScrollY()\r\n\t}\r\n\r\n\tscrollTo(scrollPosition) {\r\n\t\tthis.virtualScroller.scrollableContainer.scrollToY(scrollPosition)\r\n\t}\r\n\r\n\tresize({\r\n\t\tscreenWidth: scrollableContainerWidth,\r\n\t\tscreenHeight: scrollableContainerHeight,\r\n\t\tcolumnsCount\r\n\t}) {\r\n\t\t// Resize scrollable container.\r\n\t\tthis.setScrollableContainerWidth(scrollableContainerWidth)\r\n\t\tthis.setScrollableContainerHeight(scrollableContainerHeight)\r\n\r\n\t\t// Update columns count.\r\n\t\tthis.__columnsCount = columnsCount\r\n\t}\r\n\r\n\t// Returns a `Promise`.\r\n\ttriggerResize({\r\n\t\tscreenWidth,\r\n\t\tscreenHeight,\r\n\t\tcolumnsCount,\r\n\t\tverticalSpacing\r\n\t}) {\r\n\t\tthis.resize({\r\n\t\t\tscreenWidth,\r\n\t\t\tscreenHeight,\r\n\t\t\tcolumnsCount,\r\n\t\t\tverticalSpacing\r\n\t\t})\r\n\r\n\t\t// Call \"on resize\" listener.\r\n\t\treturn this.virtualScroller.scrollableContainer._triggerResizeListener()\r\n\t}\r\n\r\n\tstop() {\r\n\t\tif (this.expectedStateUpdates.length > 0) {\r\n\t\t\tthrow new Error(`[virtual-scroller] Expected ${this.expectedStateUpdates.length} state updates which didn't happen:\\n${JSON.stringify(this.expectedStateUpdates, null, 2)}`)\r\n\t\t}\r\n\t\tif (this.pausedStateUpdate) {\r\n\t\t\tthrow new Error('[virtual-scroller] State updates were paused and haven\\'t been resumed afterwards')\r\n\t\t}\r\n\t\tthis.virtualScroller.stop()\r\n\t}\r\n\r\n\tstart() {\r\n\t\tthis.virtualScroller.start()\r\n\t}\r\n\r\n\tgetState() {\r\n\t\treturn this.virtualScroller.getState()\r\n\t}\r\n\r\n\tupdateLayout() {\r\n\t\tthis.virtualScroller.updateLayout()\r\n\t}\r\n\r\n\tgetItemScrollPosition(i) {\r\n\t\treturn this.virtualScroller.getItemScrollPosition(i)\r\n\t}\r\n\r\n\tgetAverageItemHeight() {\r\n\t\treturn this.virtualScroller.itemHeights.getAverage()\r\n\t}\r\n\r\n\tsetItems(newItems, options) {\r\n\t\tthis.virtualScroller.setItems(newItems, options)\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;;;;;;;;;;;AAEA,IAAMA,KAAK,GAAG,KAAd;;IAEqBC,mB;EACpB,mCAOG;IAAA;;IAAA,IANWC,wBAMX,QANFC,WAME;IAAA,IALYC,yBAKZ,QALFC,YAKE;IAAA,IAJFC,YAIE,QAJFA,YAIE;IAAA,IAHFC,eAGE,QAHFA,eAGE;IAAA,IAFFC,KAEE,QAFFA,KAEE;IAAA,IADKC,YACL,QADFC,KACE;;IAAA;;IACF,KAAKC,oBAAL,GAA4B,EAA5B;IAEA,IAAMC,0BAA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T,EAA4B;QAC3B,MAAM,IAAIqC,KAAJ,CAAU,mFAAV,CAAN;MACA;;MACD,KAAKxB,eAAL,CAAqBqC,IAArB;IACA;;;WAED,iBAAQ;MACP,KAAKrC,eAAL,CAAqBsC,KAArB;IACA;;;WAED,oBAAW;MACV,OAAO,KAAKtC,eAAL,CAAqBC,QAArB,EAAP;IACA;;;WAED,wBAAe;MACd,KAAKD,eAAL,CAAqBuC,YAArB;IACA;;;WAED,+BAAsBC,CAAtB,EAAyB;MACxB,OAAO,KAAKxC,eAAL,CAAqByC,qBAArB,CAA2CD,CAA3C,CAAP;IACA;;;WAED,gCAAuB;MACtB,OAAO,KAAKxC,eAAL,CAAqB0C,WAArB,CAAiCC,UAAjC,EAAP;IACA;;;WAED,kBAASC,QAAT,EAAmBC,OAAnB,EAA4B;MAC3B,KAAK7C,eAAL,CAAqB8C,QAArB,CAA8BF,QAA9B,EAAwCC,OAAxC;IACA"}
|
|
@@ -14,11 +14,17 @@ var _requestAnimationFrameTimeout = require("request-animation-frame-timeout");
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Same as `lodash`'s `debounce()` for functions with no arguments.
|
|
17
|
-
* @param {function} func
|
|
17
|
+
* @param {function} func — The function.
|
|
18
18
|
* @param {number} interval
|
|
19
|
-
* @
|
|
19
|
+
* @param {function} [options.onStart]
|
|
20
|
+
* @param {function} [options.onStop]
|
|
21
|
+
* @return {function} A function that returns a `Promise` which resolves when the underlying (original) function gets executed.
|
|
20
22
|
*/
|
|
21
23
|
function debounce(func, interval) {
|
|
24
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
25
|
+
onStart = _ref.onStart,
|
|
26
|
+
onStop = _ref.onStop;
|
|
27
|
+
|
|
22
28
|
var timeout;
|
|
23
29
|
return function () {
|
|
24
30
|
var _this = this;
|
|
@@ -27,10 +33,26 @@ function debounce(func, interval) {
|
|
|
27
33
|
args[_key] = arguments[_key];
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
return new Promise(function (resolve) {
|
|
37
|
+
if (timeout) {
|
|
38
|
+
(0, _requestAnimationFrameTimeout.clearTimeout)(timeout);
|
|
39
|
+
} else {
|
|
40
|
+
if (onStart) {
|
|
41
|
+
onStart();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
timeout = (0, _requestAnimationFrameTimeout.setTimeout)(function () {
|
|
46
|
+
timeout = undefined;
|
|
47
|
+
|
|
48
|
+
if (onStop) {
|
|
49
|
+
onStop();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
func.apply(_this, args);
|
|
53
|
+
resolve();
|
|
54
|
+
}, interval);
|
|
55
|
+
});
|
|
34
56
|
};
|
|
35
57
|
}
|
|
36
58
|
//# sourceMappingURL=debounce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"debounce.js","names":["debounce","func","interval","onStart","onStop","timeout","args","Promise","resolve","clearTimeout","setTimeout","undefined","apply"],"sources":["../../source/utility/debounce.js"],"sourcesContent":["// For some weird reason, in Chrome, `setTimeout()` would lag up to a second (or more) behind.\r\n// Turns out, Chrome developers have deprecated `setTimeout()` API entirely without asking anyone.\r\n// Replacing `setTimeout()` with `requestAnimationFrame()` can work around that Chrome bug.\r\n// https://github.com/bvaughn/react-virtualized/issues/722\r\nimport { setTimeout, clearTimeout } from 'request-animation-frame-timeout'\r\n\r\n/**\r\n * Same as `lodash`'s `debounce()` for functions with no arguments.\r\n * @param {function} func — The function.\r\n * @param {number} interval\r\n * @param {function} [options.onStart]\r\n * @param {function} [options.onStop]\r\n * @return {function} A function that returns a `Promise` which resolves when the underlying (original) function gets executed.\r\n */\r\nexport default function debounce(func, interval, { onStart, onStop } = {}) {\r\n\tlet timeout\r\n\treturn function(...args) {\r\n\t\treturn new Promise((resolve) => {\r\n\t\t\tif (timeout) {\r\n\t\t\t\tclearTimeout(timeout)\r\n\t\t\t} else {\r\n\t\t\t\tif (onStart) {\r\n\t\t\t\t\tonStart()\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\ttimeout = setTimeout(() => {\r\n\t\t\t\ttimeout = undefined\r\n\t\t\t\tif (onStop) {\r\n\t\t\t\t\tonStop()\r\n\t\t\t\t}\r\n\t\t\t\tfunc.apply(this, args)\r\n\t\t\t\tresolve()\r\n\t\t\t}, interval)\r\n\t\t})\r\n\t}\r\n}\r\n"],"mappings":";;;;;;;AAIA;;AAJA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,QAAT,CAAkBC,IAAlB,EAAwBC,QAAxB,EAA4D;EAAA,+EAAJ,EAAI;EAAA,IAAxBC,OAAwB,QAAxBA,OAAwB;EAAA,IAAfC,MAAe,QAAfA,MAAe;;EAC1E,IAAIC,OAAJ;EACA,OAAO,YAAkB;IAAA;;IAAA,kCAANC,IAAM;MAANA,IAAM;IAAA;;IACxB,OAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;MAC/B,IAAIH,OAAJ,EAAa;QACZ,IAAAI,0CAAA,EAAaJ,OAAb;MACA,CAFD,MAEO;QACN,IAAIF,OAAJ,EAAa;UACZA,OAAO;QACP;MACD;;MACDE,OAAO,GAAG,IAAAK,wCAAA,EAAW,YAAM;QAC1BL,OAAO,GAAGM,SAAV;;QACA,IAAIP,MAAJ,EAAY;UACXA,MAAM;QACN;;QACDH,IAAI,CAACW,KAAL,CAAW,KAAX,EAAiBN,IAAjB;QACAE,OAAO;MACP,CAPS,EAOPN,QAPO,CAAV;IAQA,CAhBM,CAAP;EAiBA,CAlBD;AAmBA"}
|
|
@@ -4,17 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = log;
|
|
7
|
-
exports.warn = warn;
|
|
8
|
-
exports.reportError = reportError;
|
|
9
7
|
exports.isDebug = isDebug;
|
|
8
|
+
exports.isWarn = isWarn;
|
|
9
|
+
exports.reportError = reportError;
|
|
10
|
+
exports.warn = warn;
|
|
11
|
+
|
|
12
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
|
+
|
|
14
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
15
|
|
|
11
|
-
function
|
|
16
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
17
|
|
|
13
|
-
function
|
|
18
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
19
|
|
|
15
|
-
function
|
|
20
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
21
|
|
|
17
|
-
function
|
|
22
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
18
23
|
|
|
19
24
|
function log() {
|
|
20
25
|
if (isDebug()) {
|
|
@@ -29,13 +34,19 @@ function log() {
|
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
function warn() {
|
|
32
|
-
|
|
37
|
+
if (isWarn()) {
|
|
38
|
+
var _console2;
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
41
|
+
args[_key2] = arguments[_key2];
|
|
42
|
+
}
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
if (warningsAreErrors()) {
|
|
45
|
+
return reportError.apply(this, args);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
(_console2 = console).warn.apply(_console2, _toConsumableArray(['[virtual-scroller]'].concat(args)));
|
|
49
|
+
}
|
|
39
50
|
}
|
|
40
51
|
|
|
41
52
|
function reportError() {
|
|
@@ -66,8 +77,36 @@ function reportError() {
|
|
|
66
77
|
}
|
|
67
78
|
|
|
68
79
|
function isDebug() {
|
|
80
|
+
var debug = getDebug();
|
|
81
|
+
|
|
82
|
+
if (debug !== undefined) {
|
|
83
|
+
return debug === true || debug === 'debug';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isWarn() {
|
|
88
|
+
// const debug = getDebug()
|
|
89
|
+
// return debug === undefined
|
|
90
|
+
// || debug === true
|
|
91
|
+
// || debug === 'debug'
|
|
92
|
+
// || debug === 'warn'
|
|
93
|
+
//
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function getDebug() {
|
|
98
|
+
return getGlobalVariable('VirtualScrollerDebug');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function warningsAreErrors() {
|
|
102
|
+
return getGlobalVariable('VirtualScrollerWarningsAreErrors');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function getGlobalVariable(name) {
|
|
69
106
|
if (typeof window !== 'undefined') {
|
|
70
|
-
return window
|
|
107
|
+
return window[name];
|
|
108
|
+
} else if (typeof global !== 'undefined') {
|
|
109
|
+
return global[name];
|
|
71
110
|
}
|
|
72
111
|
}
|
|
73
112
|
//# sourceMappingURL=debug.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"debug.js","names":["log","isDebug","args","console","concat","warn","isWarn","warningsAreErrors","reportError","apply","window","setTimeout","Error","join","error","debug","getDebug","undefined","getGlobalVariable","name","global"],"sources":["../../source/utility/debug.js"],"sourcesContent":["export default function log(...args) {\r\n\tif (isDebug()) {\r\n\t\tconsole.log(...['[virtual-scroller]'].concat(args))\r\n\t}\r\n}\r\n\r\nexport function warn(...args) {\r\n\tif (isWarn()) {\r\n\t\tif (warningsAreErrors()) {\r\n\t\t\treturn reportError.apply(this, args)\r\n\t\t}\r\n\t\tconsole.warn(...['[virtual-scroller]'].concat(args))\r\n\t}\r\n}\r\n\r\nexport function reportError(...args) {\r\n\tif (typeof window !== 'undefined') {\r\n\t\t// In a web browser.\r\n\t\t// Output a debug message immediately so that it's known\r\n\t\t// at which point did the error occur between other debug logs.\r\n\t\tlog.apply(this, ['ERROR'].concat(args))\r\n\t\tsetTimeout(() => {\r\n\t\t\t// Throw an error in a timeout so that it doesn't interrupt the application's flow.\r\n\t\t\t// At the same time, by throwing a client-side error, such error could be spotted\r\n\t\t\t// in some error monitoring software like `sentry.io`, while also being visible\r\n\t\t\t// in the console.\r\n\t\t\t// The `.join(' ')` part doesn't support stringifying JSON objects,\r\n\t\t\t// but those don't seem to be used in any of the error messages.\r\n\t\t\tthrow new Error(['[virtual-scroller]'].concat(args).join(' '))\r\n\t\t}, 0)\r\n\t} else {\r\n\t\t// On a server.\r\n\t\tconsole.error(...['[virtual-scroller]'].concat(args))\r\n\t}\r\n}\r\n\r\nexport function isDebug() {\r\n\tconst debug = getDebug()\r\n\tif (debug !== undefined) {\r\n\t\treturn debug === true || debug === 'debug'\r\n\t}\r\n}\r\n\r\nexport function isWarn() {\r\n\t// const debug = getDebug()\r\n\t// return debug === undefined\r\n\t// \t|| debug === true\r\n\t// \t|| debug === 'debug'\r\n\t// \t|| debug === 'warn'\r\n\t//\r\n\treturn true\r\n}\r\n\r\nfunction getDebug() {\r\n\treturn getGlobalVariable('VirtualScrollerDebug')\r\n}\r\n\r\nfunction warningsAreErrors() {\r\n\treturn getGlobalVariable('VirtualScrollerWarningsAreErrors')\r\n}\r\n\r\nfunction getGlobalVariable(name) {\r\n\tif (typeof window !== 'undefined') {\r\n\t\treturn window[name]\r\n\t} else if (typeof global !== 'undefined') {\r\n\t\treturn global[name]\r\n\t}\r\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAe,SAASA,GAAT,GAAsB;EACpC,IAAIC,OAAO,EAAX,EAAe;IAAA;;IAAA,kCADeC,IACf;MADeA,IACf;IAAA;;IACd,YAAAC,OAAO,EAACH,GAAR,oCAAe,CAAC,oBAAD,EAAuBI,MAAvB,CAA8BF,IAA9B,CAAf;EACA;AACD;;AAEM,SAASG,IAAT,GAAuB;EAC7B,IAAIC,MAAM,EAAV,EAAc;IAAA;;IAAA,mCADSJ,IACT;MADSA,IACT;IAAA;;IACb,IAAIK,iBAAiB,EAArB,EAAyB;MACxB,OAAOC,WAAW,CAACC,KAAZ,CAAkB,IAAlB,EAAwBP,IAAxB,CAAP;IACA;;IACD,aAAAC,OAAO,EAACE,IAAR,qCAAgB,CAAC,oBAAD,EAAuBD,MAAvB,CAA8BF,IAA9B,CAAhB;EACA;AACD;;AAEM,SAASM,WAAT,GAA8B;EAAA,mCAANN,IAAM;IAANA,IAAM;EAAA;;EACpC,IAAI,OAAOQ,MAAP,KAAkB,WAAtB,EAAmC;IAClC;IACA;IACA;IACAV,GAAG,CAACS,KAAJ,CAAU,IAAV,EAAgB,CAAC,OAAD,EAAUL,MAAV,CAAiBF,IAAjB,CAAhB;IACAS,UAAU,CAAC,YAAM;MAChB;MACA;MACA;MACA;MACA;MACA;MACA,MAAM,IAAIC,KAAJ,CAAU,CAAC,oBAAD,EAAuBR,MAAvB,CAA8BF,IAA9B,EAAoCW,IAApC,CAAyC,GAAzC,CAAV,CAAN;IACA,CARS,EAQP,CARO,CAAV;EASA,CAdD,MAcO;IAAA;;IACN;IACA,aAAAV,OAAO,EAACW,KAAR,qCAAiB,CAAC,oBAAD,EAAuBV,MAAvB,CAA8BF,IAA9B,CAAjB;EACA;AACD;;AAEM,SAASD,OAAT,GAAmB;EACzB,IAAMc,KAAK,GAAGC,QAAQ,EAAtB;;EACA,IAAID,KAAK,KAAKE,SAAd,EAAyB;IACxB,OAAOF,KAAK,KAAK,IAAV,IAAkBA,KAAK,KAAK,OAAnC;EACA;AACD;;AAEM,SAAST,MAAT,GAAkB;EACxB;EACA;EACA;EACA;EACA;EACA;EACA,OAAO,IAAP;AACA;;AAED,SAASU,QAAT,GAAoB;EACnB,OAAOE,iBAAiB,CAAC,sBAAD,CAAxB;AACA;;AAED,SAASX,iBAAT,GAA6B;EAC5B,OAAOW,iBAAiB,CAAC,kCAAD,CAAxB;AACA;;AAED,SAASA,iBAAT,CAA2BC,IAA3B,EAAiC;EAChC,IAAI,OAAOT,MAAP,KAAkB,WAAtB,EAAmC;IAClC,OAAOA,MAAM,CAACS,IAAD,CAAb;EACA,CAFD,MAEO,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;IACzC,OAAOA,MAAM,CAACD,IAAD,CAAb;EACA;AACD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = getStateSnapshot;
|
|
7
|
+
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
// Creates a snapshot of a `state` or a partial update of a `state`.
|
|
15
|
+
// Is only used for logging state snapshots for later debug.
|
|
16
|
+
//
|
|
17
|
+
// When `state` is output to the browser console via `console.log()`,
|
|
18
|
+
// it is explorable in real time. That also means that if that `state`
|
|
19
|
+
// is modified later, the user will see the modified state, not the
|
|
20
|
+
// original one. In the current implementation, `state` is not strictly
|
|
21
|
+
// "immutable": things like individual item heights (including "before resize" ones)
|
|
22
|
+
// or states are updated in-place — `state.itemHeights[i] = newItemHeight` or
|
|
23
|
+
// `state.itemStates[i] = newItemState`. That's because those `state` properties
|
|
24
|
+
// are the ones that don’t affect the presentation, so there's no need to re-render
|
|
25
|
+
// the list when those do change — updating those properties is just an effect of
|
|
26
|
+
// some change rather than cause for one.
|
|
27
|
+
//
|
|
28
|
+
// So, when outputting `state` via `console.log()` for debug, it makes sense to
|
|
29
|
+
// snapshot it so that the developer, while debugging later, sees the correct
|
|
30
|
+
// item heights or item states.
|
|
31
|
+
//
|
|
32
|
+
function getStateSnapshot(state) {
|
|
33
|
+
var stateSnapshot = _objectSpread({}, state);
|
|
34
|
+
|
|
35
|
+
if (state.itemHeights) {
|
|
36
|
+
stateSnapshot.itemHeights = state.itemHeights.slice();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (state.itemStates) {
|
|
40
|
+
stateSnapshot.itemStates = state.itemStates.slice();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (state.beforeResize) {
|
|
44
|
+
stateSnapshot.beforeResize = _objectSpread({}, state.beforeResize);
|
|
45
|
+
stateSnapshot.beforeResize.itemHeights = state.beforeResize.itemHeights.slice();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return stateSnapshot;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=getStateSnapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStateSnapshot.js","names":["getStateSnapshot","state","stateSnapshot","itemHeights","slice","itemStates","beforeResize"],"sources":["../../source/utility/getStateSnapshot.js"],"sourcesContent":["// Creates a snapshot of a `state` or a partial update of a `state`.\r\n// Is only used for logging state snapshots for later debug.\r\n//\r\n// When `state` is output to the browser console via `console.log()`,\r\n// it is explorable in real time. That also means that if that `state`\r\n// is modified later, the user will see the modified state, not the\r\n// original one. In the current implementation, `state` is not strictly\r\n// \"immutable\": things like individual item heights (including \"before resize\" ones)\r\n// or states are updated in-place — `state.itemHeights[i] = newItemHeight` or\r\n// `state.itemStates[i] = newItemState`. That's because those `state` properties\r\n// are the ones that don’t affect the presentation, so there's no need to re-render\r\n// the list when those do change — updating those properties is just an effect of\r\n// some change rather than cause for one.\r\n//\r\n// So, when outputting `state` via `console.log()` for debug, it makes sense to\r\n// snapshot it so that the developer, while debugging later, sees the correct\r\n// item heights or item states.\r\n//\r\nexport default function getStateSnapshot(state) {\r\n\tlet stateSnapshot = {\r\n\t\t...state\r\n\t}\r\n\tif (state.itemHeights) {\r\n\t\tstateSnapshot.itemHeights = state.itemHeights.slice()\r\n\t}\r\n\tif (state.itemStates) {\r\n\t\tstateSnapshot.itemStates = state.itemStates.slice()\r\n\t}\r\n\tif (state.beforeResize) {\r\n\t\tstateSnapshot.beforeResize = {\r\n\t\t\t...state.beforeResize\r\n\t\t}\r\n\t\tstateSnapshot.beforeResize.itemHeights = state.beforeResize.itemHeights.slice()\r\n\t}\r\n\treturn stateSnapshot\r\n}"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,gBAAT,CAA0BC,KAA1B,EAAiC;EAC/C,IAAIC,aAAa,qBACbD,KADa,CAAjB;;EAGA,IAAIA,KAAK,CAACE,WAAV,EAAuB;IACtBD,aAAa,CAACC,WAAd,GAA4BF,KAAK,CAACE,WAAN,CAAkBC,KAAlB,EAA5B;EACA;;EACD,IAAIH,KAAK,CAACI,UAAV,EAAsB;IACrBH,aAAa,CAACG,UAAd,GAA2BJ,KAAK,CAACI,UAAN,CAAiBD,KAAjB,EAA3B;EACA;;EACD,IAAIH,KAAK,CAACK,YAAV,EAAwB;IACvBJ,aAAa,CAACI,YAAd,qBACIL,KAAK,CAACK,YADV;IAGAJ,aAAa,CAACI,YAAd,CAA2BH,WAA3B,GAAyCF,KAAK,CAACK,YAAN,CAAmBH,WAAnB,CAA+BC,KAA/B,EAAzC;EACA;;EACD,OAAOF,aAAP;AACA"}
|
package/commonjs/utility/px.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"px.js","names":["px","number","toFixed"],"sources":["../../source/utility/px.js"],"sourcesContent":["/**\r\n * Rounds coordinates upto 4th decimal place (after dot) and appends \"px\".\r\n * Small numbers could be printed as `\"1.2345e-50\"` unless rounded:\r\n * that would be invalid \"px\" value in CSS.\r\n * @param {number}\r\n * @return {string}\r\n */\r\nexport default function px(number) {\r\n\t// Fractional pixels are used on \"retina\" screens.\r\n return (number % 1 === 0 ? number : number.toFixed(2)) + 'px'\r\n}"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,EAAT,CAAYC,MAAZ,EAAoB;EAClC;EACC,OAAO,CAACA,MAAM,GAAG,CAAT,KAAe,CAAf,GAAmBA,MAAnB,GAA4BA,MAAM,CAACC,OAAP,CAAe,CAAf,CAA7B,IAAkD,IAAzD;AACD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _px = _interopRequireDefault(require("./px.js"));
|
|
4
|
+
|
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
+
|
|
7
|
+
describe('utility/px', function () {
|
|
8
|
+
it('should truncate px values', function () {
|
|
9
|
+
(0, _px["default"])(0).should.equal('0px');
|
|
10
|
+
(0, _px["default"])(1).should.equal('1px');
|
|
11
|
+
(0, _px["default"])(1.2345).should.equal('1.23px');
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=px.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"px.test.js","names":["describe","it","px","should","equal"],"sources":["../../source/utility/px.test.js"],"sourcesContent":["import px from './px.js'\r\n\r\ndescribe('utility/px', function() {\r\n\tit('should truncate px values', function() {\r\n\t\tpx(0).should.equal('0px')\r\n\t\tpx(1).should.equal('1px')\r\n\t\tpx(1.2345).should.equal('1.23px')\r\n\t})\r\n})"],"mappings":";;AAAA;;;;AAEAA,QAAQ,CAAC,YAAD,EAAe,YAAW;EACjCC,EAAE,CAAC,2BAAD,EAA8B,YAAW;IAC1C,IAAAC,cAAA,EAAG,CAAH,EAAMC,MAAN,CAAaC,KAAb,CAAmB,KAAnB;IACA,IAAAF,cAAA,EAAG,CAAH,EAAMC,MAAN,CAAaC,KAAb,CAAmB,KAAnB;IACA,IAAAF,cAAA,EAAG,MAAH,EAAWC,MAAX,CAAkBC,KAAlB,CAAwB,QAAxB;EACA,CAJC,CAAF;AAKA,CANO,CAAR"}
|
|
@@ -20,7 +20,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
20
20
|
});
|
|
21
21
|
exports["default"] = shallowEqual;
|
|
22
22
|
|
|
23
|
-
function _typeof(obj) {
|
|
23
|
+
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); }
|
|
24
24
|
|
|
25
25
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
26
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"shallowEqual.js","names":["hasOwnProperty","Object","prototype","is","x","y","shallowEqual","objA","objB","keysA","keys","keysB","length","i","call"],"sources":["../../source/utility/shallowEqual.js"],"sourcesContent":["// https://github.com/lodash/lodash/issues/2340\r\n// https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/shallowEqual.js\r\n\r\n/**\r\n * Copyright (c) 2013-present, Facebook, Inc.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n * @providesModule shallowEqual\r\n * @typechecks\r\n * @flow\r\n */\r\n\r\n/*eslint-disable no-self-compare */\r\n\r\n'use strict';\r\n\r\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\r\n\r\n/**\r\n * inlined Object.is polyfill to avoid requiring consumers ship their own\r\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\r\n */\r\nfunction is(x, y) {\r\n // SameValue algorithm\r\n if (x === y) { // Steps 1-5, 7-10\r\n // Steps 6.b-6.e: +0 != -0\r\n // Added the nonzero y check to make Flow happy, but it is redundant\r\n return x !== 0 || y !== 0 || 1 / x === 1 / y;\r\n } else {\r\n // Step 6.a: NaN == NaN\r\n return x !== x && y !== y;\r\n }\r\n}\r\n\r\n/**\r\n * Performs equality by iterating through keys on an object and returning false\r\n * when any key has values which are not strictly equal between the arguments.\r\n * Returns true when the values of all keys are strictly equal.\r\n */\r\nexport default function shallowEqual(objA, objB) {\r\n if (is(objA, objB)) {\r\n return true;\r\n }\r\n\r\n if (typeof objA !== 'object' || objA === null ||\r\n typeof objB !== 'object' || objB === null) {\r\n return false;\r\n }\r\n\r\n const keysA = Object.keys(objA);\r\n const keysB = Object.keys(objB);\r\n\r\n if (keysA.length !== keysB.length) {\r\n return false;\r\n }\r\n\r\n // Test for A's keys different from B.\r\n for (let i = 0; i < keysA.length; i++) {\r\n if (\r\n !hasOwnProperty.call(objB, keysA[i]) ||\r\n !is(objA[keysA[i]], objB[keysA[i]])\r\n ) {\r\n return false;\r\n }\r\n }\r\n\r\n return true;\r\n}"],"mappings":"AAAA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAEA;;;;;;;;;AAEA,IAAMA,cAAc,GAAGC,MAAM,CAACC,SAAP,CAAiBF,cAAxC;AAEA;AACA;AACA;AACA;;AACA,SAASG,EAAT,CAAYC,CAAZ,EAAeC,CAAf,EAAkB;EAChB;EACA,IAAID,CAAC,KAAKC,CAAV,EAAa;IAAE;IACb;IACA;IACA,OAAOD,CAAC,KAAK,CAAN,IAAWC,CAAC,KAAK,CAAjB,IAAsB,IAAID,CAAJ,KAAU,IAAIC,CAA3C;EACD,CAJD,MAIO;IACL;IACA,OAAOD,CAAC,KAAKA,CAAN,IAAWC,CAAC,KAAKA,CAAxB;EACD;AACF;AAED;AACA;AACA;AACA;AACA;;;AACe,SAASC,YAAT,CAAsBC,IAAtB,EAA4BC,IAA5B,EAAkC;EAC/C,IAAIL,EAAE,CAACI,IAAD,EAAOC,IAAP,CAAN,EAAoB;IAClB,OAAO,IAAP;EACD;;EAED,IAAI,QAAOD,IAAP,MAAgB,QAAhB,IAA4BA,IAAI,KAAK,IAArC,IACA,QAAOC,IAAP,MAAgB,QADhB,IAC4BA,IAAI,KAAK,IADzC,EAC+C;IAC7C,OAAO,KAAP;EACD;;EAED,IAAMC,KAAK,GAAGR,MAAM,CAACS,IAAP,CAAYH,IAAZ,CAAd;EACA,IAAMI,KAAK,GAAGV,MAAM,CAACS,IAAP,CAAYF,IAAZ,CAAd;;EAEA,IAAIC,KAAK,CAACG,MAAN,KAAiBD,KAAK,CAACC,MAA3B,EAAmC;IACjC,OAAO,KAAP;EACD,CAf8C,CAiB/C;;;EACA,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGJ,KAAK,CAACG,MAA1B,EAAkCC,CAAC,EAAnC,EAAuC;IACrC,IACE,CAACb,cAAc,CAACc,IAAf,CAAoBN,IAApB,EAA0BC,KAAK,CAACI,CAAD,CAA/B,CAAD,IACA,CAACV,EAAE,CAACI,IAAI,CAACE,KAAK,CAACI,CAAD,CAAN,CAAL,EAAiBL,IAAI,CAACC,KAAK,CAACI,CAAD,CAAN,CAArB,CAFL,EAGE;MACA,OAAO,KAAP;IACD;EACF;;EAED,OAAO,IAAP;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"throttle.js","names":["throttle","func","interval","timeout","executedAt","scheduled","undefined","Date","now","remaining","clearTimeout","setTimeout"],"sources":["../../source/utility/throttle.js"],"sourcesContent":["// For some weird reason, in Chrome, `setTimeout()` would lag up to a second (or more) behind.\r\n// Turns out, Chrome developers have deprecated `setTimeout()` API entirely without asking anyone.\r\n// Replacing `setTimeout()` with `requestAnimationFrame()` can work around that Chrome bug.\r\n// https://github.com/bvaughn/react-virtualized/issues/722\r\nimport { setTimeout, clearTimeout } from 'request-animation-frame-timeout'\r\n\r\n/**\r\n * Same as `lodash`'s `throttle()` for functions with no arguments.\r\n * @param {function} func\r\n * @param {number} interval\r\n * @return {function}\r\n */\r\nexport default function throttle(func, interval) {\r\n\tlet timeout\r\n\tlet executedAt = 0\r\n\tlet scheduled = function() {\r\n\t\ttimeout = undefined\r\n\t\texecutedAt = Date.now()\r\n\t\tfunc()\r\n\t}\r\n\treturn function() {\r\n\t\tconst now = Date.now()\r\n\t\tconst remaining = interval - (now - executedAt)\r\n\t\tif (remaining <= 0) {\r\n\t\t\tif (timeout) {\r\n\t\t\t\tclearTimeout(timeout)\r\n\t\t\t\ttimeout = undefined\r\n\t\t\t}\r\n\t\t\texecutedAt = now\r\n\t\t\tfunc()\r\n\t\t} else if (!timeout) {\r\n\t\t\ttimeout = setTimeout(scheduled, remaining)\r\n\t\t}\r\n\t}\r\n}"],"mappings":";;;;;;;AAIA;;AAJA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,QAAT,CAAkBC,IAAlB,EAAwBC,QAAxB,EAAkC;EAChD,IAAIC,OAAJ;EACA,IAAIC,UAAU,GAAG,CAAjB;;EACA,IAAIC,SAAS,GAAG,SAAZA,SAAY,GAAW;IAC1BF,OAAO,GAAGG,SAAV;IACAF,UAAU,GAAGG,IAAI,CAACC,GAAL,EAAb;IACAP,IAAI;EACJ,CAJD;;EAKA,OAAO,YAAW;IACjB,IAAMO,GAAG,GAAGD,IAAI,CAACC,GAAL,EAAZ;IACA,IAAMC,SAAS,GAAGP,QAAQ,IAAIM,GAAG,GAAGJ,UAAV,CAA1B;;IACA,IAAIK,SAAS,IAAI,CAAjB,EAAoB;MACnB,IAAIN,OAAJ,EAAa;QACZ,IAAAO,0CAAA,EAAaP,OAAb;QACAA,OAAO,GAAGG,SAAV;MACA;;MACDF,UAAU,GAAGI,GAAb;MACAP,IAAI;IACJ,CAPD,MAOO,IAAI,CAACE,OAAL,EAAc;MACpBA,OAAO,GAAG,IAAAQ,wCAAA,EAAWN,SAAX,EAAsBI,SAAtB,CAAV;IACA;EACD,CAbD;AAcA"}
|
package/dom/index.cjs
ADDED