@deephaven/grid 0.5.2-beta.0 → 0.6.1-demo.8
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/dist/CellInputField.js +40 -88
- package/dist/CellInputField.js.map +1 -1
- package/dist/Grid.js +1449 -1484
- package/dist/Grid.js.map +1 -1
- package/dist/GridColorUtils.js +18 -51
- package/dist/GridColorUtils.js.map +1 -1
- package/dist/GridMetricCalculator.d.ts +8 -1
- package/dist/GridMetricCalculator.d.ts.map +1 -1
- package/dist/GridMetricCalculator.js +1031 -994
- package/dist/GridMetricCalculator.js.map +1 -1
- package/dist/GridModel.d.ts +4 -1
- package/dist/GridModel.d.ts.map +1 -1
- package/dist/GridModel.js +175 -286
- package/dist/GridModel.js.map +1 -1
- package/dist/GridMouseHandler.js +39 -59
- package/dist/GridMouseHandler.js.map +1 -1
- package/dist/GridRange.js +572 -630
- package/dist/GridRange.js.map +1 -1
- package/dist/GridRenderer.js +1650 -1564
- package/dist/GridRenderer.js.map +1 -1
- package/dist/GridTestUtils.js +15 -29
- package/dist/GridTestUtils.js.map +1 -1
- package/dist/GridUtils.js +679 -717
- package/dist/GridUtils.js.map +1 -1
- package/dist/KeyHandler.js +6 -18
- package/dist/KeyHandler.js.map +1 -1
- package/dist/MockGridModel.js +105 -210
- package/dist/MockGridModel.js.map +1 -1
- package/dist/MockTreeGridModel.js +113 -183
- package/dist/MockTreeGridModel.js.map +1 -1
- package/dist/errors/PasteError.js +5 -44
- package/dist/errors/PasteError.js.map +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/key-handlers/EditKeyHandler.js +42 -75
- package/dist/key-handlers/EditKeyHandler.js.map +1 -1
- package/dist/key-handlers/PasteKeyHandler.js +42 -78
- package/dist/key-handlers/PasteKeyHandler.js.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.d.ts.map +1 -1
- package/dist/key-handlers/SelectionKeyHandler.js +239 -229
- package/dist/key-handlers/SelectionKeyHandler.js.map +1 -1
- package/dist/key-handlers/TreeKeyHandler.js +42 -72
- package/dist/key-handlers/TreeKeyHandler.js.map +1 -1
- package/dist/key-handlers/index.js +4 -4
- package/dist/key-handlers/index.js.map +1 -1
- package/dist/memoizeClear.js +1 -1
- package/dist/memoizeClear.js.map +1 -1
- package/dist/mouse-handlers/EditMouseHandler.js +18 -50
- package/dist/mouse-handlers/EditMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.d.ts.map +1 -1
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js +141 -163
- package/dist/mouse-handlers/GridColumnMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js +47 -86
- package/dist/mouse-handlers/GridColumnSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js +145 -171
- package/dist/mouse-handlers/GridHorizontalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js +125 -147
- package/dist/mouse-handlers/GridRowMoveMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js +47 -86
- package/dist/mouse-handlers/GridRowSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js +46 -76
- package/dist/mouse-handlers/GridRowTreeMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js +31 -62
- package/dist/mouse-handlers/GridScrollBarCornerMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSelectionMouseHandler.js +200 -222
- package/dist/mouse-handlers/GridSelectionMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js +206 -253
- package/dist/mouse-handlers/GridSeparatorMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js +146 -172
- package/dist/mouse-handlers/GridVerticalScrollBarMouseHandler.js.map +1 -1
- package/dist/mouse-handlers/index.js +10 -10
- package/dist/mouse-handlers/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -10
|
@@ -1,263 +1,241 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
-
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
|
|
5
|
-
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); } }
|
|
6
|
-
|
|
7
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
8
|
-
|
|
9
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
|
-
|
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
|
|
13
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
-
|
|
15
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
16
|
-
|
|
17
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
|
|
19
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
20
|
-
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
|
|
23
1
|
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; }
|
|
24
2
|
|
|
25
|
-
import GridMouseHandler from
|
|
26
|
-
import GridUtils from
|
|
3
|
+
import GridMouseHandler from "../GridMouseHandler.js";
|
|
4
|
+
import GridUtils from "../GridUtils.js";
|
|
27
5
|
var DEFAULT_INTERVAL_MS = 100;
|
|
28
6
|
|
|
29
|
-
|
|
30
|
-
|
|
7
|
+
class GridSelectionMouseHandler extends GridMouseHandler {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
31
10
|
|
|
32
|
-
|
|
11
|
+
_defineProperty(this, "startPoint", null);
|
|
33
12
|
|
|
34
|
-
|
|
35
|
-
var _this;
|
|
13
|
+
_defineProperty(this, "hasExtendedFloating", false);
|
|
36
14
|
|
|
37
|
-
|
|
15
|
+
_defineProperty(this, "timer", null);
|
|
38
16
|
|
|
39
|
-
|
|
40
|
-
args[_key] = arguments[_key];
|
|
41
|
-
}
|
|
17
|
+
_defineProperty(this, "lastTriggerTime", null);
|
|
42
18
|
|
|
43
|
-
|
|
19
|
+
_defineProperty(this, "dragBounds", null);
|
|
20
|
+
}
|
|
44
21
|
|
|
45
|
-
|
|
22
|
+
onDown(gridPoint, grid, event) {
|
|
23
|
+
var {
|
|
24
|
+
x,
|
|
25
|
+
y,
|
|
26
|
+
column,
|
|
27
|
+
row
|
|
28
|
+
} = gridPoint;
|
|
29
|
+
var {
|
|
30
|
+
metrics
|
|
31
|
+
} = grid;
|
|
32
|
+
var {
|
|
33
|
+
gridX,
|
|
34
|
+
gridY,
|
|
35
|
+
maxX,
|
|
36
|
+
maxY
|
|
37
|
+
} = metrics;
|
|
38
|
+
var gridMouseX = x - gridX;
|
|
39
|
+
var gridMouseY = y - gridY;
|
|
40
|
+
|
|
41
|
+
if (gridMouseX < 0 || gridMouseY < 0 || column == null && gridMouseX > maxX || row == null && gridMouseY > maxY) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
var isModifierKey = GridUtils.isModifierKeyDown(event);
|
|
46
|
+
var isShiftKey = event.shiftKey;
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
if (!isModifierKey) {
|
|
49
|
+
if (isShiftKey) {
|
|
50
|
+
grid.trimSelectedRanges();
|
|
51
|
+
} else {
|
|
52
|
+
grid.clearSelectedRanges();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
50
55
|
|
|
51
|
-
|
|
56
|
+
var theme = grid.getTheme();
|
|
57
|
+
var {
|
|
58
|
+
autoSelectRow,
|
|
59
|
+
autoSelectColumn
|
|
60
|
+
} = theme; // If they click a column/row header, don't want to select the whole table if auto select column/row is on
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
if ((column !== null || !autoSelectColumn) && (row !== null || !autoSelectRow)) {
|
|
63
|
+
grid.focus();
|
|
64
|
+
grid.moveCursorToPosition(column, row, isShiftKey, true, isShiftKey && isModifierKey);
|
|
65
|
+
}
|
|
54
66
|
|
|
55
|
-
|
|
67
|
+
this.startPoint = gridPoint;
|
|
68
|
+
this.hasExtendedFloating = false;
|
|
69
|
+
this.dragBounds = GridUtils.getScrollDragBounds(metrics, row, column);
|
|
70
|
+
return true;
|
|
56
71
|
}
|
|
57
72
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
y = gridPoint.y,
|
|
63
|
-
column = gridPoint.column,
|
|
64
|
-
row = gridPoint.row;
|
|
65
|
-
var metrics = grid.metrics;
|
|
66
|
-
var gridX = metrics.gridX,
|
|
67
|
-
gridY = metrics.gridY,
|
|
68
|
-
maxX = metrics.maxX,
|
|
69
|
-
maxY = metrics.maxY;
|
|
70
|
-
var gridMouseX = x - gridX;
|
|
71
|
-
var gridMouseY = y - gridY;
|
|
72
|
-
|
|
73
|
-
if (gridMouseX < 0 || gridMouseY < 0 || column == null && gridMouseX > maxX || row == null && gridMouseY > maxY) {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
var isModifierKey = GridUtils.isModifierKeyDown(event);
|
|
78
|
-
var isShiftKey = event.shiftKey;
|
|
73
|
+
onDrag(gridPoint, grid) {
|
|
74
|
+
if (this.startPoint === null) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
this.stopTimer();
|
|
79
|
+
var {
|
|
80
|
+
row: startRow,
|
|
81
|
+
column: startColumn
|
|
82
|
+
} = this.startPoint;
|
|
83
|
+
var {
|
|
84
|
+
x,
|
|
85
|
+
y
|
|
86
|
+
} = gridPoint;
|
|
87
|
+
var {
|
|
88
|
+
row,
|
|
89
|
+
column
|
|
90
|
+
} = gridPoint;
|
|
91
|
+
var {
|
|
92
|
+
metrics
|
|
93
|
+
} = grid;
|
|
94
|
+
var {
|
|
95
|
+
left,
|
|
96
|
+
lastLeft,
|
|
97
|
+
top,
|
|
98
|
+
lastTop,
|
|
99
|
+
columnWidth,
|
|
100
|
+
rowHeight
|
|
101
|
+
} = metrics;
|
|
102
|
+
var dragBounds = GridUtils.getScrollDragBounds(metrics, startRow, startColumn); // If we're dragging outside of the grid entirely, then we should start scrolling
|
|
103
|
+
|
|
104
|
+
var deltaX = 0;
|
|
105
|
+
var deltaY = 0;
|
|
106
|
+
|
|
107
|
+
if (left < lastLeft) {
|
|
108
|
+
if (x < dragBounds.x) {
|
|
109
|
+
deltaX = x - dragBounds.x;
|
|
110
|
+
} else if (x > dragBounds.x2) {
|
|
111
|
+
deltaX = x - dragBounds.x2;
|
|
86
112
|
}
|
|
113
|
+
}
|
|
87
114
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
grid.focus();
|
|
94
|
-
grid.moveCursorToPosition(column, row, isShiftKey, true, isShiftKey && isModifierKey);
|
|
115
|
+
if (top < lastTop) {
|
|
116
|
+
if (y < dragBounds.y) {
|
|
117
|
+
deltaY = y - dragBounds.y;
|
|
118
|
+
} else if (y > dragBounds.y2) {
|
|
119
|
+
deltaY = y - dragBounds.y2;
|
|
95
120
|
}
|
|
96
|
-
|
|
97
|
-
this.startPoint = gridPoint;
|
|
98
|
-
this.hasExtendedFloating = false;
|
|
99
|
-
this.dragBounds = GridUtils.getScrollDragBounds(metrics, row, column);
|
|
100
|
-
return true;
|
|
101
121
|
}
|
|
102
|
-
}, {
|
|
103
|
-
key: "onDrag",
|
|
104
|
-
value: function onDrag(gridPoint, grid) {
|
|
105
|
-
if (this.startPoint === null) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
122
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
123
|
+
if (deltaX !== 0 || deltaY !== 0) {
|
|
124
|
+
// Have it go faster depending on how far out they've dragged
|
|
125
|
+
this.startTimer(grid, gridPoint, deltaX > 0 ? Math.ceil(deltaX / columnWidth) : Math.floor(deltaX / columnWidth), deltaY > 0 ? Math.ceil(deltaY / rowHeight) : Math.floor(deltaY / rowHeight));
|
|
126
|
+
} else if (row != null && column != null) {
|
|
127
|
+
var {
|
|
128
|
+
floatingTopRowCount,
|
|
129
|
+
floatingBottomRowCount,
|
|
130
|
+
floatingLeftColumnCount,
|
|
131
|
+
floatingRightColumnCount,
|
|
132
|
+
columnCount,
|
|
133
|
+
rowCount,
|
|
134
|
+
bottom,
|
|
135
|
+
right,
|
|
136
|
+
topVisible,
|
|
137
|
+
bottomVisible,
|
|
138
|
+
leftVisible,
|
|
139
|
+
rightVisible
|
|
140
|
+
} = metrics; // When selection crosses from a floating area to a non floating area, we need to scroll instead of jumping to the floating area
|
|
141
|
+
// So when that happens, just adjust the point to be past the new boundary
|
|
142
|
+
|
|
143
|
+
if (!this.hasExtendedFloating) {
|
|
144
|
+
if (startRow < floatingTopRowCount && row >= floatingTopRowCount) {
|
|
145
|
+
// Extending from floating top into the view
|
|
146
|
+
row = floatingTopRowCount;
|
|
147
|
+
this.hasExtendedFloating = true;
|
|
148
|
+
} else if (startRow >= rowCount - floatingBottomRowCount && row < rowCount - floatingBottomRowCount) {
|
|
149
|
+
// Extending from floating bottom into the view
|
|
150
|
+
row = rowCount - floatingBottomRowCount - 1;
|
|
151
|
+
this.hasExtendedFloating = true;
|
|
134
152
|
}
|
|
135
|
-
}
|
|
136
153
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
154
|
+
if (startColumn < floatingLeftColumnCount && column >= floatingLeftColumnCount) {
|
|
155
|
+
// Extending from floating left into the view
|
|
156
|
+
column = floatingLeftColumnCount;
|
|
157
|
+
this.hasExtendedFloating = true;
|
|
158
|
+
} else if (startColumn >= columnCount - floatingRightColumnCount && column < columnCount - floatingRightColumnCount) {
|
|
159
|
+
// Extending from floating right into the view
|
|
160
|
+
column = columnCount - floatingRightColumnCount - 1;
|
|
161
|
+
this.hasExtendedFloating = true;
|
|
142
162
|
}
|
|
143
|
-
}
|
|
163
|
+
} // When a selection is dragging from within the main area to over a floating area, scroll.
|
|
144
164
|
|
|
145
|
-
if (deltaX !== 0 || deltaY !== 0) {
|
|
146
|
-
// Have it go faster depending on how far out they've dragged
|
|
147
|
-
this.startTimer(grid, gridPoint, deltaX > 0 ? Math.ceil(deltaX / columnWidth) : Math.floor(deltaX / columnWidth), deltaY > 0 ? Math.ceil(deltaY / rowHeight) : Math.floor(deltaY / rowHeight));
|
|
148
|
-
} else if (row != null && column != null) {
|
|
149
|
-
var floatingTopRowCount = metrics.floatingTopRowCount,
|
|
150
|
-
floatingBottomRowCount = metrics.floatingBottomRowCount,
|
|
151
|
-
floatingLeftColumnCount = metrics.floatingLeftColumnCount,
|
|
152
|
-
floatingRightColumnCount = metrics.floatingRightColumnCount,
|
|
153
|
-
columnCount = metrics.columnCount,
|
|
154
|
-
rowCount = metrics.rowCount,
|
|
155
|
-
bottom = metrics.bottom,
|
|
156
|
-
right = metrics.right,
|
|
157
|
-
topVisible = metrics.topVisible,
|
|
158
|
-
bottomVisible = metrics.bottomVisible,
|
|
159
|
-
leftVisible = metrics.leftVisible,
|
|
160
|
-
rightVisible = metrics.rightVisible; // When selection crosses from a floating area to a non floating area, we need to scroll instead of jumping to the floating area
|
|
161
|
-
// So when that happens, just adjust the point to be past the new boundary
|
|
162
|
-
|
|
163
|
-
if (!this.hasExtendedFloating) {
|
|
164
|
-
if (startRow < floatingTopRowCount && row >= floatingTopRowCount) {
|
|
165
|
-
// Extending from floating top into the view
|
|
166
|
-
row = floatingTopRowCount;
|
|
167
|
-
this.hasExtendedFloating = true;
|
|
168
|
-
} else if (startRow >= rowCount - floatingBottomRowCount && row < rowCount - floatingBottomRowCount) {
|
|
169
|
-
// Extending from floating bottom into the view
|
|
170
|
-
row = rowCount - floatingBottomRowCount - 1;
|
|
171
|
-
this.hasExtendedFloating = true;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (startColumn < floatingLeftColumnCount && column >= floatingLeftColumnCount) {
|
|
175
|
-
// Extending from floating left into the view
|
|
176
|
-
column = floatingLeftColumnCount;
|
|
177
|
-
this.hasExtendedFloating = true;
|
|
178
|
-
} else if (startColumn >= columnCount - floatingRightColumnCount && column < columnCount - floatingRightColumnCount) {
|
|
179
|
-
// Extending from floating right into the view
|
|
180
|
-
column = columnCount - floatingRightColumnCount - 1;
|
|
181
|
-
this.hasExtendedFloating = true;
|
|
182
|
-
}
|
|
183
|
-
} // When a selection is dragging from within the main area to over a floating area, scroll.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (!GridUtils.isFloatingRow(startRow, metrics) && GridUtils.isFloatingRow(row, metrics)) {
|
|
187
|
-
// Need to scroll
|
|
188
|
-
if (startRow > row && row < top) {
|
|
189
|
-
row = topVisible - 1;
|
|
190
|
-
} else if (startRow < row && row > bottom) {
|
|
191
|
-
row = bottomVisible + 1;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
165
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
166
|
+
if (!GridUtils.isFloatingRow(startRow, metrics) && GridUtils.isFloatingRow(row, metrics)) {
|
|
167
|
+
// Need to scroll
|
|
168
|
+
if (startRow > row && row < top) {
|
|
169
|
+
row = topVisible - 1;
|
|
170
|
+
} else if (startRow < row && row > bottom) {
|
|
171
|
+
row = bottomVisible + 1;
|
|
201
172
|
}
|
|
202
|
-
|
|
203
|
-
grid.moveCursorToPosition(column, row, true, true);
|
|
204
173
|
}
|
|
205
174
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
this.startPoint = null;
|
|
213
|
-
this.dragBounds = null;
|
|
214
|
-
this.stopTimer();
|
|
215
|
-
grid.commitSelection();
|
|
175
|
+
if (!GridUtils.isFloatingColumn(startColumn, metrics) && GridUtils.isFloatingColumn(column, metrics)) {
|
|
176
|
+
if (startColumn > column && column < left) {
|
|
177
|
+
column = leftVisible - 1;
|
|
178
|
+
} else if (startColumn < column && column > right) {
|
|
179
|
+
column = rightVisible + 1;
|
|
180
|
+
}
|
|
216
181
|
}
|
|
217
182
|
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
}, {
|
|
221
|
-
key: "moveSelection",
|
|
222
|
-
value: function moveSelection(grid, gridPoint, deltaX, deltaY) {
|
|
223
|
-
var row = gridPoint.row,
|
|
224
|
-
column = gridPoint.column;
|
|
225
|
-
var metrics = grid.metrics;
|
|
226
|
-
var _grid$state = grid.state,
|
|
227
|
-
selectionEndRow = _grid$state.selectionEndRow,
|
|
228
|
-
selectionEndColumn = _grid$state.selectionEndColumn;
|
|
229
|
-
var rowCount = metrics.rowCount,
|
|
230
|
-
columnCount = metrics.columnCount;
|
|
231
|
-
var minX = deltaX < 0 && column != null ? column : 0;
|
|
232
|
-
var maxX = deltaX > 0 && column != null ? column : columnCount - 1;
|
|
233
|
-
var minY = deltaY < 0 && row != null ? row : 0;
|
|
234
|
-
var maxY = deltaY > 0 && row != null ? row : rowCount - 1;
|
|
235
|
-
grid.moveCursorToPosition(Math.min(Math.max(minX, selectionEndColumn + deltaX), maxX), Math.min(Math.max(minY, selectionEndRow + deltaY), maxY), true);
|
|
236
|
-
this.lastTriggerTime = Date.now();
|
|
183
|
+
grid.moveCursorToPosition(column, row, true, true);
|
|
237
184
|
}
|
|
238
|
-
}, {
|
|
239
|
-
key: "startTimer",
|
|
240
|
-
value: function startTimer(grid, gridPoint, deltaX, deltaY) {
|
|
241
|
-
var _this2 = this;
|
|
242
185
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
this.timer = setTimeout(function () {
|
|
246
|
-
_this2.moveSelection(grid, gridPoint, deltaX, deltaY);
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
247
188
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
clearTimeout(this.timer);
|
|
255
|
-
this.timer = null;
|
|
189
|
+
onUp(gridPoint, grid) {
|
|
190
|
+
if (this.startPoint !== null) {
|
|
191
|
+
this.startPoint = null;
|
|
192
|
+
this.dragBounds = null;
|
|
193
|
+
this.stopTimer();
|
|
194
|
+
grid.commitSelection();
|
|
256
195
|
}
|
|
257
|
-
}]);
|
|
258
196
|
|
|
259
|
-
|
|
260
|
-
}
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
moveSelection(grid, gridPoint, deltaX, deltaY) {
|
|
201
|
+
var {
|
|
202
|
+
row,
|
|
203
|
+
column
|
|
204
|
+
} = gridPoint;
|
|
205
|
+
var {
|
|
206
|
+
metrics
|
|
207
|
+
} = grid;
|
|
208
|
+
var {
|
|
209
|
+
selectionEndRow,
|
|
210
|
+
selectionEndColumn
|
|
211
|
+
} = grid.state;
|
|
212
|
+
var {
|
|
213
|
+
rowCount,
|
|
214
|
+
columnCount
|
|
215
|
+
} = metrics;
|
|
216
|
+
var minX = deltaX < 0 && column != null ? column : 0;
|
|
217
|
+
var maxX = deltaX > 0 && column != null ? column : columnCount - 1;
|
|
218
|
+
var minY = deltaY < 0 && row != null ? row : 0;
|
|
219
|
+
var maxY = deltaY > 0 && row != null ? row : rowCount - 1;
|
|
220
|
+
grid.moveCursorToPosition(Math.min(Math.max(minX, selectionEndColumn + deltaX), maxX), Math.min(Math.max(minY, selectionEndRow + deltaY), maxY), true);
|
|
221
|
+
this.lastTriggerTime = Date.now();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
startTimer(grid, gridPoint, deltaX, deltaY) {
|
|
225
|
+
this.stopTimer();
|
|
226
|
+
var timeout = this.lastTriggerTime != null ? DEFAULT_INTERVAL_MS - Math.min(DEFAULT_INTERVAL_MS, Date.now() - this.lastTriggerTime) : 0;
|
|
227
|
+
this.timer = setTimeout(() => {
|
|
228
|
+
this.moveSelection(grid, gridPoint, deltaX, deltaY);
|
|
229
|
+
this.startTimer(grid, gridPoint, deltaX, deltaY);
|
|
230
|
+
}, timeout);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
stopTimer() {
|
|
234
|
+
clearTimeout(this.timer);
|
|
235
|
+
this.timer = null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
}
|
|
261
239
|
|
|
262
240
|
export default GridSelectionMouseHandler;
|
|
263
241
|
//# sourceMappingURL=GridSelectionMouseHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mouse-handlers/GridSelectionMouseHandler.js"],"names":["GridMouseHandler","GridUtils","DEFAULT_INTERVAL_MS","GridSelectionMouseHandler","gridPoint","grid","event","x","y","column","row","metrics","gridX","gridY","maxX","maxY","gridMouseX","gridMouseY","isModifierKey","isModifierKeyDown","isShiftKey","shiftKey","trimSelectedRanges","clearSelectedRanges","theme","getTheme","autoSelectRow","autoSelectColumn","focus","moveCursorToPosition","startPoint","hasExtendedFloating","dragBounds","getScrollDragBounds","stopTimer","startRow","startColumn","left","lastLeft","top","lastTop","columnWidth","rowHeight","deltaX","deltaY","x2","y2","startTimer","Math","ceil","floor","floatingTopRowCount","floatingBottomRowCount","floatingLeftColumnCount","floatingRightColumnCount","columnCount","rowCount","bottom","right","topVisible","bottomVisible","leftVisible","rightVisible","isFloatingRow","isFloatingColumn","commitSelection","state","selectionEndRow","selectionEndColumn","minX","minY","min","max","lastTriggerTime","Date","now","timeout","timer","setTimeout","move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IAAI,IAArB,GAA4BA,GAA5B,GAAkC8C,QAAQ,GAAG,CAA1D;AACAnD,MAAAA,IAAI,CAACwB,oBAAL,CACEmB,IAAI,CAACuB,GAAL,CAASvB,IAAI,CAACwB,GAAL,CAASH,IAAT,EAAeD,kBAAkB,GAAGzB,MAApC,CAAT,EAAsD7B,IAAtD,CADF,EAEEkC,IAAI,CAACuB,GAAL,CAASvB,IAAI,CAACwB,GAAL,CAASF,IAAT,EAAeH,eAAe,GAAGvB,MAAjC,CAAT,EAAmD7B,IAAnD,CAFF,EAGE,IAHF;AAKA,WAAK0D,eAAL,GAAuBC,IAAI,CAACC,GAAL,EAAvB;AACD;;;WAED,oBAAWtE,IAAX,EAAiBD,SAAjB,EAA4BuC,MAA5B,EAAoCC,MAApC,EAA4C;AAAA;;AAC1C,WAAKV,SAAL;AAEA,UAAM0C,OAAO,GACX,KAAKH,eAAL,IAAwB,IAAxB,GACIvE,mBAAmB,GACnB8C,IAAI,CAACuB,GAAL,CAASrE,mBAAT,EAA8BwE,IAAI,CAACC,GAAL,KAAa,KAAKF,eAAhD,CAFJ,GAGI,CAJN;AAKA,WAAKI,KAAL,GAAaC,UAAU,CAAC,YAAM;AAC5B,QAAA,MAAI,CAACC,aAAL,CAAmB1E,IAAnB,EAAyBD,SAAzB,EAAoCuC,MAApC,EAA4CC,MAA5C;;AACA,QAAA,MAAI,CAACG,UAAL,CAAgB1C,IAAhB,EAAsBD,SAAtB,EAAiCuC,MAAjC,EAAyCC,MAAzC;AACD,OAHsB,EAGpBgC,OAHoB,CAAvB;AAID;;;WAED,qBAAY;AACVI,MAAAA,YAAY,CAAC,KAAKH,KAAN,CAAZ;AACA,WAAKA,KAAL,GAAa,IAAb;AACD;;;;EArOqC7E,gB;;AAwOxC,eAAeG,yBAAf","sourcesContent":["import GridMouseHandler from '../GridMouseHandler';\nimport GridUtils from '../GridUtils';\n\nconst DEFAULT_INTERVAL_MS = 100;\n\nclass GridSelectionMouseHandler extends GridMouseHandler {\n startPoint = null;\n\n hasExtendedFloating = false;\n\n // Timer used when holding a drag past the end of the grid\n timer = null;\n\n lastTriggerTime = null;\n\n dragBounds = null;\n\n onDown(gridPoint, grid, event) {\n const { x, y, column, row } = gridPoint;\n const { metrics } = grid;\n const { gridX, gridY, maxX, maxY } = metrics;\n const gridMouseX = x - gridX;\n const gridMouseY = y - gridY;\n if (\n gridMouseX < 0 ||\n gridMouseY < 0 ||\n (column == null && gridMouseX > maxX) ||\n (row == null && gridMouseY > maxY)\n ) {\n return false;\n }\n\n const isModifierKey = GridUtils.isModifierKeyDown(event);\n const isShiftKey = event.shiftKey;\n if (!isModifierKey) {\n if (isShiftKey) {\n grid.trimSelectedRanges();\n } else {\n grid.clearSelectedRanges();\n }\n }\n\n const theme = grid.getTheme();\n const { autoSelectRow, autoSelectColumn } = theme;\n // If they click a column/row header, don't want to select the whole table if auto select column/row is on\n if (\n (column !== null || !autoSelectColumn) &&\n (row !== null || !autoSelectRow)\n ) {\n grid.focus();\n grid.moveCursorToPosition(\n column,\n row,\n isShiftKey,\n true,\n isShiftKey && isModifierKey\n );\n }\n\n this.startPoint = gridPoint;\n this.hasExtendedFloating = false;\n this.dragBounds = GridUtils.getScrollDragBounds(metrics, row, column);\n\n return true;\n }\n\n onDrag(gridPoint, grid) {\n if (this.startPoint === null) {\n return false;\n }\n\n this.stopTimer();\n\n const { row: startRow, column: startColumn } = this.startPoint;\n const { x, y } = gridPoint;\n let { row, column } = gridPoint;\n const { metrics } = grid;\n const { left, lastLeft, top, lastTop, columnWidth, rowHeight } = metrics;\n const dragBounds = GridUtils.getScrollDragBounds(\n metrics,\n startRow,\n startColumn\n );\n\n // If we're dragging outside of the grid entirely, then we should start scrolling\n let deltaX = 0;\n let deltaY = 0;\n if (left < lastLeft) {\n if (x < dragBounds.x) {\n deltaX = x - dragBounds.x;\n } else if (x > dragBounds.x2) {\n deltaX = x - dragBounds.x2;\n }\n }\n if (top < lastTop) {\n if (y < dragBounds.y) {\n deltaY = y - dragBounds.y;\n } else if (y > dragBounds.y2) {\n deltaY = y - dragBounds.y2;\n }\n }\n\n if (deltaX !== 0 || deltaY !== 0) {\n // Have it go faster depending on how far out they've dragged\n this.startTimer(\n grid,\n gridPoint,\n deltaX > 0\n ? Math.ceil(deltaX / columnWidth)\n : Math.floor(deltaX / columnWidth),\n deltaY > 0\n ? Math.ceil(deltaY / rowHeight)\n : Math.floor(deltaY / rowHeight)\n );\n } else if (row != null && column != null) {\n const {\n floatingTopRowCount,\n floatingBottomRowCount,\n floatingLeftColumnCount,\n floatingRightColumnCount,\n columnCount,\n rowCount,\n bottom,\n right,\n topVisible,\n bottomVisible,\n leftVisible,\n rightVisible,\n } = metrics;\n // When selection crosses from a floating area to a non floating area, we need to scroll instead of jumping to the floating area\n // So when that happens, just adjust the point to be past the new boundary\n if (!this.hasExtendedFloating) {\n if (startRow < floatingTopRowCount && row >= floatingTopRowCount) {\n // Extending from floating top into the view\n row = floatingTopRowCount;\n this.hasExtendedFloating = true;\n } else if (\n startRow >= rowCount - floatingBottomRowCount &&\n row < rowCount - floatingBottomRowCount\n ) {\n // Extending from floating bottom into the view\n row = rowCount - floatingBottomRowCount - 1;\n this.hasExtendedFloating = true;\n }\n\n if (\n startColumn < floatingLeftColumnCount &&\n column >= floatingLeftColumnCount\n ) {\n // Extending from floating left into the view\n column = floatingLeftColumnCount;\n this.hasExtendedFloating = true;\n } else if (\n startColumn >= columnCount - floatingRightColumnCount &&\n column < columnCount - floatingRightColumnCount\n ) {\n // Extending from floating right into the view\n column = columnCount - floatingRightColumnCount - 1;\n this.hasExtendedFloating = true;\n }\n }\n\n // When a selection is dragging from within the main area to over a floating area, scroll.\n if (\n !GridUtils.isFloatingRow(startRow, metrics) &&\n GridUtils.isFloatingRow(row, metrics)\n ) {\n // Need to scroll\n if (startRow > row && row < top) {\n row = topVisible - 1;\n } else if (startRow < row && row > bottom) {\n row = bottomVisible + 1;\n }\n }\n if (\n !GridUtils.isFloatingColumn(startColumn, metrics) &&\n GridUtils.isFloatingColumn(column, metrics)\n ) {\n if (startColumn > column && column < left) {\n column = leftVisible - 1;\n } else if (startColumn < column && column > right) {\n column = rightVisible + 1;\n }\n }\n grid.moveCursorToPosition(column, row, true, true);\n }\n return true;\n }\n\n onUp(gridPoint, grid) {\n if (this.startPoint !== null) {\n this.startPoint = null;\n this.dragBounds = null;\n this.stopTimer();\n grid.commitSelection();\n }\n\n return false;\n }\n\n moveSelection(grid, gridPoint, deltaX, deltaY) {\n const { row, column } = gridPoint;\n const { metrics } = grid;\n const { selectionEndRow, selectionEndColumn } = grid.state;\n const { rowCount, columnCount } = metrics;\n const minX = deltaX < 0 && column != null ? column : 0;\n const maxX = deltaX > 0 && column != null ? column : columnCount - 1;\n const minY = deltaY < 0 && row != null ? row : 0;\n const maxY = deltaY > 0 && row != null ? row : rowCount - 1;\n grid.moveCursorToPosition(\n Math.min(Math.max(minX, selectionEndColumn + deltaX), maxX),\n Math.min(Math.max(minY, selectionEndRow + deltaY), maxY),\n true\n );\n this.lastTriggerTime = Date.now();\n }\n\n startTimer(grid, gridPoint, deltaX, deltaY) {\n this.stopTimer();\n\n const timeout =\n this.lastTriggerTime != null\n ? DEFAULT_INTERVAL_MS -\n Math.min(DEFAULT_INTERVAL_MS, Date.now() - this.lastTriggerTime)\n : 0;\n this.timer = setTimeout(() => {\n this.moveSelection(grid, gridPoint, deltaX, deltaY);\n this.startTimer(grid, gridPoint, deltaX, deltaY);\n }, timeout);\n }\n\n stopTimer() {\n clearTimeout(this.timer);\n this.timer = null;\n }\n}\n\nexport default GridSelectionMouseHandler;\n"],"file":"GridSelectionMouseHandler.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/mouse-handlers/GridSelectionMouseHandler.js"],"names":["GridMouseHandler","GridUtils","DEFAULT_INTERVAL_MS","GridSelectionMouseHandler","onDown","gridPoint","grid","event","x","y","column","row","metrics","gridX","gridY","maxX","maxY","gridMouseX","gridMouseY","isModifierKey","isModifierKeyDown","isShiftKey","shiftKey","trimSelectedRanges","clearSelectedRanges","theme","getTheme","autoSelectRow","autoSelectColumn","focus","moveCursorToPosition","startPoint","hasExtendedFloating","dragBounds","getScrollDragBounds","onDrag","stopTimer","startRow","startColumn","left","lastLeft","top","lastTop","columnWidth","rowHeight","deltaX","deltaY","x2","y2","startTimer","Math","ceil","floor","floatingTopRowCount","floatingBottomRowCount","floatingLeftColumnCount","floatingRightColumnCount","columnCount","rowCount","bottom","right","topVisible","bottomVisible","leftVisible","rightVisible","isFloatingRow","isFloatingColumn","onUp","commitSelection","moveSelection","selectionEndRow","selectionEndColumn","state","minX","minY","min","max","lastTriggerTime","Date","now","timeout","timer","setTimeout","clearTimeout"],"mappings":";;OAAOA,gB;OACAC,S;AAEP,IAAMC,mBAAmB,GAAG,GAA5B;;AAEA,MAAMC,yBAAN,SAAwCH,gBAAxC,CAAyD;AAAA;AAAA;;AAAA,wCAC1C,IAD0C;;AAAA,iDAGjC,KAHiC;;AAAA,mCAM/C,IAN+C;;AAAA,6CAQrC,IARqC;;AAAA,wCAU1C,IAV0C;AAAA;;AAYvDI,EAAAA,MAAM,CAACC,SAAD,EAAYC,IAAZ,EAAkBC,KAAlB,EAAyB;AAC7B,QAAM;AAAEC,MAAAA,CAAF;AAAKC,MAAAA,CAAL;AAAQC,MAAAA,MAAR;AAAgBC,MAAAA;AAAhB,QAAwBN,SAA9B;AACA,QAAM;AAAEO,MAAAA;AAAF,QAAcN,IAApB;AACA,QAAM;AAAEO,MAAAA,KAAF;AAASC,MAAAA,KAAT;AAAgBC,MAAAA,IAAhB;AAAsBC,MAAAA;AAAtB,QAA+BJ,OAArC;AACA,QAAMK,UAAU,GAAGT,CAAC,GAAGK,KAAvB;AACA,QAAMK,UAAU,GAAGT,CAAC,GAAGK,KAAvB;;AACA,QACEG,UAAU,GAAG,CAAb,IACAC,UAAU,GAAG,CADb,IAECR,MAAM,IAAI,IAAV,IAAkBO,UAAU,GAAGF,IAFhC,IAGCJ,GAAG,IAAI,IAAP,IAAeO,UAAU,GA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AAK6D,eAAL,GAAuBC,IAAI,CAACC,GAAL,EAAvB;AACD;;AAED9B,EAAAA,UAAU,CAAC3C,IAAD,EAAOD,SAAP,EAAkBwC,MAAlB,EAA0BC,MAA1B,EAAkC;AAC1C,SAAKV,SAAL;AAEA,QAAM4C,OAAO,GACX,KAAKH,eAAL,IAAwB,IAAxB,GACI3E,mBAAmB,GACnBgD,IAAI,CAACyB,GAAL,CAASzE,mBAAT,EAA8B4E,IAAI,CAACC,GAAL,KAAa,KAAKF,eAAhD,CAFJ,GAGI,CAJN;AAKA,SAAKI,KAAL,GAAaC,UAAU,CAAC,MAAM;AAC5B,WAAKb,aAAL,CAAmB/D,IAAnB,EAAyBD,SAAzB,EAAoCwC,MAApC,EAA4CC,MAA5C;AACA,WAAKG,UAAL,CAAgB3C,IAAhB,EAAsBD,SAAtB,EAAiCwC,MAAjC,EAAyCC,MAAzC;AACD,KAHsB,EAGpBkC,OAHoB,CAAvB;AAID;;AAED5C,EAAAA,SAAS,GAAG;AACV+C,IAAAA,YAAY,CAAC,KAAKF,KAAN,CAAZ;AACA,SAAKA,KAAL,GAAa,IAAb;AACD;;AArOsD;;AAwOzD,eAAe9E,yBAAf","sourcesContent":["import GridMouseHandler from '../GridMouseHandler';\nimport GridUtils from '../GridUtils';\n\nconst DEFAULT_INTERVAL_MS = 100;\n\nclass GridSelectionMouseHandler extends GridMouseHandler {\n startPoint = null;\n\n hasExtendedFloating = false;\n\n // Timer used when holding a drag past the end of the grid\n timer = null;\n\n lastTriggerTime = null;\n\n dragBounds = null;\n\n onDown(gridPoint, grid, event) {\n const { x, y, column, row } = gridPoint;\n const { metrics } = grid;\n const { gridX, gridY, maxX, maxY } = metrics;\n const gridMouseX = x - gridX;\n const gridMouseY = y - gridY;\n if (\n gridMouseX < 0 ||\n gridMouseY < 0 ||\n (column == null && gridMouseX > maxX) ||\n (row == null && gridMouseY > maxY)\n ) {\n return false;\n }\n\n const isModifierKey = GridUtils.isModifierKeyDown(event);\n const isShiftKey = event.shiftKey;\n if (!isModifierKey) {\n if (isShiftKey) {\n grid.trimSelectedRanges();\n } else {\n grid.clearSelectedRanges();\n }\n }\n\n const theme = grid.getTheme();\n const { autoSelectRow, autoSelectColumn } = theme;\n // If they click a column/row header, don't want to select the whole table if auto select column/row is on\n if (\n (column !== null || !autoSelectColumn) &&\n (row !== null || !autoSelectRow)\n ) {\n grid.focus();\n grid.moveCursorToPosition(\n column,\n row,\n isShiftKey,\n true,\n isShiftKey && isModifierKey\n );\n }\n\n this.startPoint = gridPoint;\n this.hasExtendedFloating = false;\n this.dragBounds = GridUtils.getScrollDragBounds(metrics, row, column);\n\n return true;\n }\n\n onDrag(gridPoint, grid) {\n if (this.startPoint === null) {\n return false;\n }\n\n this.stopTimer();\n\n const { row: startRow, column: startColumn } = this.startPoint;\n const { x, y } = gridPoint;\n let { row, column } = gridPoint;\n const { metrics } = grid;\n const { left, lastLeft, top, lastTop, columnWidth, rowHeight } = metrics;\n const dragBounds = GridUtils.getScrollDragBounds(\n metrics,\n startRow,\n startColumn\n );\n\n // If we're dragging outside of the grid entirely, then we should start scrolling\n let deltaX = 0;\n let deltaY = 0;\n if (left < lastLeft) {\n if (x < dragBounds.x) {\n deltaX = x - dragBounds.x;\n } else if (x > dragBounds.x2) {\n deltaX = x - dragBounds.x2;\n }\n }\n if (top < lastTop) {\n if (y < dragBounds.y) {\n deltaY = y - dragBounds.y;\n } else if (y > dragBounds.y2) {\n deltaY = y - dragBounds.y2;\n }\n }\n\n if (deltaX !== 0 || deltaY !== 0) {\n // Have it go faster depending on how far out they've dragged\n this.startTimer(\n grid,\n gridPoint,\n deltaX > 0\n ? Math.ceil(deltaX / columnWidth)\n : Math.floor(deltaX / columnWidth),\n deltaY > 0\n ? Math.ceil(deltaY / rowHeight)\n : Math.floor(deltaY / rowHeight)\n );\n } else if (row != null && column != null) {\n const {\n floatingTopRowCount,\n floatingBottomRowCount,\n floatingLeftColumnCount,\n floatingRightColumnCount,\n columnCount,\n rowCount,\n bottom,\n right,\n topVisible,\n bottomVisible,\n leftVisible,\n rightVisible,\n } = metrics;\n // When selection crosses from a floating area to a non floating area, we need to scroll instead of jumping to the floating area\n // So when that happens, just adjust the point to be past the new boundary\n if (!this.hasExtendedFloating) {\n if (startRow < floatingTopRowCount && row >= floatingTopRowCount) {\n // Extending from floating top into the view\n row = floatingTopRowCount;\n this.hasExtendedFloating = true;\n } else if (\n startRow >= rowCount - floatingBottomRowCount &&\n row < rowCount - floatingBottomRowCount\n ) {\n // Extending from floating bottom into the view\n row = rowCount - floatingBottomRowCount - 1;\n this.hasExtendedFloating = true;\n }\n\n if (\n startColumn < floatingLeftColumnCount &&\n column >= floatingLeftColumnCount\n ) {\n // Extending from floating left into the view\n column = floatingLeftColumnCount;\n this.hasExtendedFloating = true;\n } else if (\n startColumn >= columnCount - floatingRightColumnCount &&\n column < columnCount - floatingRightColumnCount\n ) {\n // Extending from floating right into the view\n column = columnCount - floatingRightColumnCount - 1;\n this.hasExtendedFloating = true;\n }\n }\n\n // When a selection is dragging from within the main area to over a floating area, scroll.\n if (\n !GridUtils.isFloatingRow(startRow, metrics) &&\n GridUtils.isFloatingRow(row, metrics)\n ) {\n // Need to scroll\n if (startRow > row && row < top) {\n row = topVisible - 1;\n } else if (startRow < row && row > bottom) {\n row = bottomVisible + 1;\n }\n }\n if (\n !GridUtils.isFloatingColumn(startColumn, metrics) &&\n GridUtils.isFloatingColumn(column, metrics)\n ) {\n if (startColumn > column && column < left) {\n column = leftVisible - 1;\n } else if (startColumn < column && column > right) {\n column = rightVisible + 1;\n }\n }\n grid.moveCursorToPosition(column, row, true, true);\n }\n return true;\n }\n\n onUp(gridPoint, grid) {\n if (this.startPoint !== null) {\n this.startPoint = null;\n this.dragBounds = null;\n this.stopTimer();\n grid.commitSelection();\n }\n\n return false;\n }\n\n moveSelection(grid, gridPoint, deltaX, deltaY) {\n const { row, column } = gridPoint;\n const { metrics } = grid;\n const { selectionEndRow, selectionEndColumn } = grid.state;\n const { rowCount, columnCount } = metrics;\n const minX = deltaX < 0 && column != null ? column : 0;\n const maxX = deltaX > 0 && column != null ? column : columnCount - 1;\n const minY = deltaY < 0 && row != null ? row : 0;\n const maxY = deltaY > 0 && row != null ? row : rowCount - 1;\n grid.moveCursorToPosition(\n Math.min(Math.max(minX, selectionEndColumn + deltaX), maxX),\n Math.min(Math.max(minY, selectionEndRow + deltaY), maxY),\n true\n );\n this.lastTriggerTime = Date.now();\n }\n\n startTimer(grid, gridPoint, deltaX, deltaY) {\n this.stopTimer();\n\n const timeout =\n this.lastTriggerTime != null\n ? DEFAULT_INTERVAL_MS -\n Math.min(DEFAULT_INTERVAL_MS, Date.now() - this.lastTriggerTime)\n : 0;\n this.timer = setTimeout(() => {\n this.moveSelection(grid, gridPoint, deltaX, deltaY);\n this.startTimer(grid, gridPoint, deltaX, deltaY);\n }, timeout);\n }\n\n stopTimer() {\n clearTimeout(this.timer);\n this.timer = null;\n }\n}\n\nexport default GridSelectionMouseHandler;\n"],"file":"GridSelectionMouseHandler.js"}
|