@deephaven/golden-layout 0.22.3-beta.15 → 0.22.3-beta.21
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/LayoutManager.js +60 -260
- package/dist/LayoutManager.js.map +1 -1
- package/dist/base.js.map +1 -1
- package/dist/config/Config.js.map +1 -1
- package/dist/config/ItemConfig.js.map +1 -1
- package/dist/container/ItemContainer.js +14 -50
- package/dist/container/ItemContainer.js.map +1 -1
- package/dist/container/index.js.map +1 -1
- package/dist/controls/BrowserPopout.js +17 -63
- package/dist/controls/BrowserPopout.js.map +1 -1
- package/dist/controls/DragProxy.js +13 -73
- package/dist/controls/DragProxy.js.map +1 -1
- package/dist/controls/DragSource.js +3 -19
- package/dist/controls/DragSource.js.map +1 -1
- package/dist/controls/DragSourceFromEvent.js +5 -24
- package/dist/controls/DragSourceFromEvent.js.map +1 -1
- package/dist/controls/DropTargetIndicator.js +0 -7
- package/dist/controls/DropTargetIndicator.js.map +1 -1
- package/dist/controls/Header.js +89 -233
- package/dist/controls/Header.js.map +1 -1
- package/dist/controls/HeaderButton.js +0 -9
- package/dist/controls/HeaderButton.js.map +1 -1
- package/dist/controls/Splitter.js +0 -14
- package/dist/controls/Splitter.js.map +1 -1
- package/dist/controls/Tab.js +21 -62
- package/dist/controls/Tab.js.map +1 -1
- package/dist/controls/TransitionIndicator.js +2 -21
- package/dist/controls/TransitionIndicator.js.map +1 -1
- package/dist/controls/index.js.map +1 -1
- package/dist/errors/ConfigurationError.js +0 -5
- package/dist/errors/ConfigurationError.js.map +1 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/items/AbstractContentItem.js +37 -133
- package/dist/items/AbstractContentItem.js.map +1 -1
- package/dist/items/Component.js +2 -27
- package/dist/items/Component.js.map +1 -1
- package/dist/items/Root.js +1 -26
- package/dist/items/Root.js.map +1 -1
- package/dist/items/RowOrColumn.js +32 -128
- package/dist/items/RowOrColumn.js.map +1 -1
- package/dist/items/Stack.js +27 -115
- package/dist/items/Stack.js.map +1 -1
- package/dist/items/index.js.map +1 -1
- package/dist/utils/BubblingEvent.js +0 -6
- package/dist/utils/BubblingEvent.js.map +1 -1
- package/dist/utils/ConfigMinifier.js +13 -26
- package/dist/utils/ConfigMinifier.js.map +1 -1
- package/dist/utils/DragListener.js +8 -47
- package/dist/utils/DragListener.js.map +1 -1
- package/dist/utils/EventEmitter.js +5 -25
- package/dist/utils/EventEmitter.js.map +1 -1
- package/dist/utils/EventHub.js +8 -27
- package/dist/utils/EventHub.js.map +1 -1
- package/dist/utils/ReactComponentHandler.js +6 -35
- package/dist/utils/ReactComponentHandler.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/utils.js +5 -11
- package/dist/utils/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,4 @@
|
|
|
1
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; }
|
|
2
|
-
|
|
3
2
|
import $ from 'jquery';
|
|
4
3
|
import AbstractContentItem from "./AbstractContentItem.js";
|
|
5
4
|
import { animFrame } from "../utils/index.js";
|
|
@@ -7,31 +6,18 @@ import { Splitter } from "../controls/index.js";
|
|
|
7
6
|
export default class RowOrColumn extends AbstractContentItem {
|
|
8
7
|
constructor(isColumn, layoutManager, config, parent) {
|
|
9
8
|
super(layoutManager, config, parent, $('<div class="lm_item lm_' + (isColumn ? 'column' : 'row') + '"></div>'));
|
|
10
|
-
|
|
11
9
|
_defineProperty(this, "isRow", void 0);
|
|
12
|
-
|
|
13
10
|
_defineProperty(this, "isColumn", void 0);
|
|
14
|
-
|
|
15
11
|
_defineProperty(this, "childElementContainer", void 0);
|
|
16
|
-
|
|
17
12
|
_defineProperty(this, "parent", void 0);
|
|
18
|
-
|
|
19
13
|
_defineProperty(this, "_splitter", []);
|
|
20
|
-
|
|
21
14
|
_defineProperty(this, "_splitterSize", void 0);
|
|
22
|
-
|
|
23
15
|
_defineProperty(this, "_splitterGrabSize", void 0);
|
|
24
|
-
|
|
25
16
|
_defineProperty(this, "_isColumn", void 0);
|
|
26
|
-
|
|
27
17
|
_defineProperty(this, "_dimension", void 0);
|
|
28
|
-
|
|
29
18
|
_defineProperty(this, "_splitterPosition", null);
|
|
30
|
-
|
|
31
19
|
_defineProperty(this, "_splitterMinPosition", null);
|
|
32
|
-
|
|
33
20
|
_defineProperty(this, "_splitterMaxPosition", null);
|
|
34
|
-
|
|
35
21
|
this.parent = parent;
|
|
36
22
|
this.isRow = !isColumn;
|
|
37
23
|
this.isColumn = isColumn;
|
|
@@ -44,6 +30,7 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
44
30
|
this._splitterMinPosition = null;
|
|
45
31
|
this._splitterMaxPosition = null;
|
|
46
32
|
}
|
|
33
|
+
|
|
47
34
|
/**
|
|
48
35
|
* Add a new contentItem to the Row or Column
|
|
49
36
|
*
|
|
@@ -54,19 +41,14 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
54
41
|
* an inconsistent state and is only intended to be used if multiple
|
|
55
42
|
* children need to be added in one go and resize is called afterwards
|
|
56
43
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
44
|
addChild(contentItem, index, _$suspendResize) {
|
|
60
45
|
var newItemSize, itemSize, i, splitterElement;
|
|
61
46
|
contentItem = this.layoutManager._$normalizeContentItem(contentItem, this);
|
|
62
|
-
|
|
63
47
|
if (index === undefined) {
|
|
64
48
|
index = this.contentItems.length;
|
|
65
49
|
}
|
|
66
|
-
|
|
67
50
|
if (this.contentItems.length > 0) {
|
|
68
51
|
splitterElement = this._createSplitter(Math.max(0, index - 1)).element;
|
|
69
|
-
|
|
70
52
|
if (index > 0) {
|
|
71
53
|
this.contentItems[index - 1].element.after(splitterElement);
|
|
72
54
|
splitterElement.after(contentItem.element);
|
|
@@ -77,75 +59,61 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
77
59
|
} else {
|
|
78
60
|
this.childElementContainer.append(contentItem.element);
|
|
79
61
|
}
|
|
80
|
-
|
|
81
62
|
AbstractContentItem.prototype.addChild.call(this, contentItem, index);
|
|
82
63
|
newItemSize = 1 / this.contentItems.length * 100;
|
|
83
|
-
|
|
84
64
|
if (_$suspendResize === true) {
|
|
85
65
|
this.emitBubblingEvent('stateChanged');
|
|
86
66
|
return;
|
|
87
67
|
}
|
|
88
|
-
|
|
89
68
|
for (i = 0; i < this.contentItems.length; i++) {
|
|
90
69
|
if (this.contentItems[i] === contentItem) {
|
|
91
70
|
contentItem.config[this._dimension] = newItemSize;
|
|
92
71
|
} else {
|
|
93
72
|
var _this$contentItems$i$;
|
|
94
|
-
|
|
95
73
|
itemSize = ((_this$contentItems$i$ = this.contentItems[i].config[this._dimension]) !== null && _this$contentItems$i$ !== void 0 ? _this$contentItems$i$ : 0) * (100 - newItemSize) / 100;
|
|
96
74
|
this.contentItems[i].config[this._dimension] = itemSize;
|
|
97
75
|
}
|
|
98
76
|
}
|
|
99
|
-
|
|
100
77
|
this.callDownwards('setSize');
|
|
101
78
|
this.emitBubblingEvent('stateChanged');
|
|
102
79
|
}
|
|
80
|
+
|
|
103
81
|
/**
|
|
104
82
|
* Removes a child of this element
|
|
105
83
|
*
|
|
106
84
|
* @param contentItem
|
|
107
85
|
* @param keepChild If true the child will be removed, but not destroyed
|
|
108
86
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
87
|
removeChild(contentItem, keepChild) {
|
|
112
88
|
var _contentItem$config$t;
|
|
113
|
-
|
|
114
89
|
var removedItemSize = (_contentItem$config$t = contentItem.config[this._dimension]) !== null && _contentItem$config$t !== void 0 ? _contentItem$config$t : 0,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
90
|
+
index = this.contentItems.indexOf(contentItem),
|
|
91
|
+
splitterIndex = Math.max(index - 1, 0),
|
|
92
|
+
i,
|
|
93
|
+
childItem;
|
|
120
94
|
if (index === -1) {
|
|
121
95
|
throw new Error("Can't remove child. ContentItem is not child of this Row or Column");
|
|
122
96
|
}
|
|
97
|
+
|
|
123
98
|
/**
|
|
124
99
|
* Remove the splitter before the item or after if the item happens
|
|
125
100
|
* to be the first in the row/column
|
|
126
101
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
102
|
if (this._splitter[splitterIndex]) {
|
|
130
103
|
this._splitter[splitterIndex]._$destroy();
|
|
131
|
-
|
|
132
104
|
this._splitter.splice(splitterIndex, 1);
|
|
133
105
|
}
|
|
106
|
+
|
|
134
107
|
/**
|
|
135
108
|
* Allocate the space that the removed item occupied to the remaining items
|
|
136
109
|
*/
|
|
137
|
-
|
|
138
|
-
|
|
139
110
|
for (i = 0; i < this.contentItems.length; i++) {
|
|
140
111
|
if (this.contentItems[i] !== contentItem) {
|
|
141
112
|
var _this$contentItems$i$2;
|
|
142
|
-
|
|
143
113
|
this.contentItems[i].config[this._dimension] = ((_this$contentItems$i$2 = this.contentItems[i].config[this._dimension]) !== null && _this$contentItems$i$2 !== void 0 ? _this$contentItems$i$2 : 0) + removedItemSize / (this.contentItems.length - 1);
|
|
144
114
|
}
|
|
145
115
|
}
|
|
146
|
-
|
|
147
116
|
AbstractContentItem.prototype.removeChild.call(this, contentItem, keepChild);
|
|
148
|
-
|
|
149
117
|
if (this.contentItems.length === 1 && this.config.isClosable === true) {
|
|
150
118
|
childItem = this.contentItems[0];
|
|
151
119
|
this.contentItems = [];
|
|
@@ -155,14 +123,13 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
155
123
|
this.emitBubblingEvent('stateChanged');
|
|
156
124
|
}
|
|
157
125
|
}
|
|
126
|
+
|
|
158
127
|
/**
|
|
159
128
|
* Replaces a child of this Row or Column with another contentItem
|
|
160
129
|
*
|
|
161
130
|
* @param oldChild
|
|
162
131
|
* @param newChild
|
|
163
132
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
133
|
replaceChild(oldChild, newChild) {
|
|
167
134
|
var size = oldChild.config[this._dimension];
|
|
168
135
|
super.replaceChild(oldChild, newChild);
|
|
@@ -170,55 +137,46 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
170
137
|
this.callDownwards('setSize');
|
|
171
138
|
this.emitBubblingEvent('stateChanged');
|
|
172
139
|
}
|
|
140
|
+
|
|
173
141
|
/**
|
|
174
142
|
* Called whenever the dimensions of this item or one of its parents change
|
|
175
143
|
*/
|
|
176
|
-
|
|
177
|
-
|
|
178
144
|
setSize() {
|
|
179
145
|
if (this.contentItems.length > 0) {
|
|
180
146
|
this._calculateRelativeSizes();
|
|
181
|
-
|
|
182
147
|
this._setAbsoluteSizes();
|
|
183
148
|
}
|
|
184
|
-
|
|
185
149
|
this.emitBubblingEvent('stateChanged');
|
|
186
150
|
this.emit('resize');
|
|
187
151
|
}
|
|
152
|
+
|
|
188
153
|
/**
|
|
189
154
|
* Invoked recursively by the layout manager. AbstractContentItem.init appends
|
|
190
155
|
* the contentItem's DOM elements to the container, RowOrColumn init adds splitters
|
|
191
156
|
* in between them
|
|
192
157
|
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
158
|
_$init() {
|
|
196
159
|
if (this.isInitialised === true) return;
|
|
197
160
|
var i;
|
|
198
|
-
|
|
199
161
|
AbstractContentItem.prototype._$init.call(this);
|
|
200
|
-
|
|
201
162
|
for (i = 0; i < this.contentItems.length - 1; i++) {
|
|
202
163
|
this.contentItems[i].element.after(this._createSplitter(i).element);
|
|
203
164
|
}
|
|
204
165
|
}
|
|
166
|
+
|
|
205
167
|
/**
|
|
206
168
|
* Turns the relative sizes calculated by _calculateRelativeSizes into
|
|
207
169
|
* absolute pixel values and applies them to the children's DOM elements
|
|
208
170
|
*
|
|
209
171
|
* Assigns additional pixels to counteract Math.floor
|
|
210
172
|
*/
|
|
211
|
-
|
|
212
|
-
|
|
213
173
|
_setAbsoluteSizes() {
|
|
214
174
|
var i,
|
|
215
|
-
|
|
216
|
-
|
|
175
|
+
sizeData = this._calculateAbsoluteSizes();
|
|
217
176
|
for (i = 0; i < this.contentItems.length; i++) {
|
|
218
177
|
if (sizeData.additionalPixel - i > 0) {
|
|
219
178
|
sizeData.itemSizes[i]++;
|
|
220
179
|
}
|
|
221
|
-
|
|
222
180
|
if (this._isColumn) {
|
|
223
181
|
this.contentItems[i].element.width(sizeData.totalWidth);
|
|
224
182
|
this.contentItems[i].element.height(sizeData.itemSizes[i]);
|
|
@@ -228,35 +186,29 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
228
186
|
}
|
|
229
187
|
}
|
|
230
188
|
}
|
|
189
|
+
|
|
231
190
|
/**
|
|
232
191
|
* Calculates the absolute sizes of all of the children of this Item.
|
|
233
192
|
* @returns {object} - Set with absolute sizes and additional pixels.
|
|
234
193
|
*/
|
|
235
|
-
|
|
236
|
-
|
|
237
194
|
_calculateAbsoluteSizes() {
|
|
238
195
|
var _this$element$width, _this$element$height;
|
|
239
|
-
|
|
240
196
|
var totalSplitterSize = (this.contentItems.length - 1) * this._splitterSize;
|
|
241
197
|
var totalWidth = (_this$element$width = this.element.width()) !== null && _this$element$width !== void 0 ? _this$element$width : 0;
|
|
242
198
|
var totalHeight = (_this$element$height = this.element.height()) !== null && _this$element$height !== void 0 ? _this$element$height : 0;
|
|
243
199
|
var totalAssigned = 0;
|
|
244
200
|
var itemSizes = [];
|
|
245
|
-
|
|
246
201
|
if (this._isColumn) {
|
|
247
202
|
totalHeight -= totalSplitterSize;
|
|
248
203
|
} else {
|
|
249
204
|
totalWidth -= totalSplitterSize;
|
|
250
205
|
}
|
|
251
|
-
|
|
252
206
|
for (var i = 0; i < this.contentItems.length; i++) {
|
|
253
207
|
var _this$contentItems$i$3, _this$contentItems$i$4;
|
|
254
|
-
|
|
255
208
|
var itemSize = this._isColumn ? Math.floor(totalHeight * (((_this$contentItems$i$3 = this.contentItems[i].config.height) !== null && _this$contentItems$i$3 !== void 0 ? _this$contentItems$i$3 : 0) / 100)) : Math.floor(totalWidth * (((_this$contentItems$i$4 = this.contentItems[i].config.width) !== null && _this$contentItems$i$4 !== void 0 ? _this$contentItems$i$4 : 0) / 100));
|
|
256
209
|
totalAssigned += itemSize;
|
|
257
210
|
itemSizes.push(itemSize);
|
|
258
211
|
}
|
|
259
|
-
|
|
260
212
|
var additionalPixel = Math.floor((this._isColumn ? totalHeight : totalWidth) - totalAssigned);
|
|
261
213
|
return {
|
|
262
214
|
itemSizes,
|
|
@@ -265,6 +217,7 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
265
217
|
totalHeight
|
|
266
218
|
};
|
|
267
219
|
}
|
|
220
|
+
|
|
268
221
|
/**
|
|
269
222
|
* Calculates the relative sizes of all children of this Item. The logic
|
|
270
223
|
* is as follows:
|
|
@@ -283,81 +236,66 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
283
236
|
* If there are no items without set dimensions, increase all items sizes relative to
|
|
284
237
|
* their original size so that they add up to 100
|
|
285
238
|
*/
|
|
286
|
-
|
|
287
|
-
|
|
288
239
|
_calculateRelativeSizes() {
|
|
289
240
|
var total = 0;
|
|
290
241
|
var itemsWithoutSetDimension = [];
|
|
291
242
|
var dimension = this._isColumn ? 'height' : 'width';
|
|
292
|
-
|
|
293
243
|
for (var i = 0; i < this.contentItems.length; i++) {
|
|
294
244
|
if (this.contentItems[i].config[dimension] !== undefined) {
|
|
295
245
|
var _this$contentItems$i$5;
|
|
296
|
-
|
|
297
246
|
total += (_this$contentItems$i$5 = this.contentItems[i].config[dimension]) !== null && _this$contentItems$i$5 !== void 0 ? _this$contentItems$i$5 : 0;
|
|
298
247
|
} else {
|
|
299
248
|
itemsWithoutSetDimension.push(this.contentItems[i]);
|
|
300
249
|
}
|
|
301
250
|
}
|
|
251
|
+
|
|
302
252
|
/**
|
|
303
253
|
* Everything adds up to hundred, all good :-)
|
|
304
254
|
*/
|
|
305
|
-
|
|
306
|
-
|
|
307
255
|
if (Math.round(total) === 100) {
|
|
308
256
|
this._respectMinItemWidth();
|
|
309
|
-
|
|
310
257
|
return;
|
|
311
258
|
}
|
|
259
|
+
|
|
312
260
|
/**
|
|
313
261
|
* Allocate the remaining size to the items without a set dimension
|
|
314
262
|
*/
|
|
315
|
-
|
|
316
|
-
|
|
317
263
|
if (Math.round(total) < 100 && itemsWithoutSetDimension.length > 0) {
|
|
318
264
|
for (var _i = 0; _i < itemsWithoutSetDimension.length; _i++) {
|
|
319
265
|
itemsWithoutSetDimension[_i].config[dimension] = (100 - total) / itemsWithoutSetDimension.length;
|
|
320
266
|
}
|
|
321
|
-
|
|
322
267
|
this._respectMinItemWidth();
|
|
323
|
-
|
|
324
268
|
return;
|
|
325
269
|
}
|
|
270
|
+
|
|
326
271
|
/**
|
|
327
272
|
* If the total is > 100, but there are also items without a set dimension left, assing 50
|
|
328
273
|
* as their dimension and add it to the total
|
|
329
274
|
*
|
|
330
275
|
* This will be reset in the next step
|
|
331
276
|
*/
|
|
332
|
-
|
|
333
|
-
|
|
334
277
|
if (Math.round(total) > 100) {
|
|
335
278
|
for (var _i2 = 0; _i2 < itemsWithoutSetDimension.length; _i2++) {
|
|
336
279
|
itemsWithoutSetDimension[_i2].config[dimension] = 50;
|
|
337
280
|
total += 50;
|
|
338
281
|
}
|
|
339
282
|
}
|
|
283
|
+
|
|
340
284
|
/**
|
|
341
285
|
* Set every items size relative to 100 relative to its size to total
|
|
342
286
|
*/
|
|
343
|
-
|
|
344
|
-
|
|
345
287
|
for (var _i3 = 0; _i3 < this.contentItems.length; _i3++) {
|
|
346
288
|
var _this$contentItems$_i;
|
|
347
|
-
|
|
348
289
|
this.contentItems[_i3].config[dimension] = ((_this$contentItems$_i = this.contentItems[_i3].config[dimension]) !== null && _this$contentItems$_i !== void 0 ? _this$contentItems$_i : 0) / total * 100;
|
|
349
290
|
}
|
|
350
|
-
|
|
351
291
|
this._respectMinItemWidth();
|
|
352
292
|
}
|
|
293
|
+
|
|
353
294
|
/**
|
|
354
295
|
* Adjusts the column widths to respect the dimensions minItemWidth if set.
|
|
355
296
|
*/
|
|
356
|
-
|
|
357
|
-
|
|
358
297
|
_respectMinItemWidth() {
|
|
359
298
|
var _this$layoutManager$c;
|
|
360
|
-
|
|
361
299
|
var minItemWidth = this.layoutManager.config.dimensions ? (_this$layoutManager$c = this.layoutManager.config.dimensions.minItemWidth) !== null && _this$layoutManager$c !== void 0 ? _this$layoutManager$c : 0 : 0;
|
|
362
300
|
var entriesOverMin = [];
|
|
363
301
|
var totalOverMin = 0;
|
|
@@ -365,21 +303,17 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
365
303
|
var remainingWidth = 0;
|
|
366
304
|
var allEntries = [];
|
|
367
305
|
var entry;
|
|
368
|
-
|
|
369
306
|
if (this._isColumn || !minItemWidth || this.contentItems.length <= 1) {
|
|
370
307
|
return;
|
|
371
308
|
}
|
|
372
|
-
|
|
373
309
|
var sizeData = this._calculateAbsoluteSizes();
|
|
310
|
+
|
|
374
311
|
/**
|
|
375
312
|
* Figure out how much we are under the min item size total and how much room we have to use.
|
|
376
313
|
*/
|
|
377
|
-
|
|
378
|
-
|
|
379
314
|
for (var i = 0; i < this.contentItems.length; i++) {
|
|
380
315
|
var contentItem = this.contentItems[i];
|
|
381
316
|
var itemSize = sizeData.itemSizes[i];
|
|
382
|
-
|
|
383
317
|
if (itemSize < minItemWidth) {
|
|
384
318
|
totalUnderMin += minItemWidth - itemSize;
|
|
385
319
|
entry = {
|
|
@@ -392,48 +326,43 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
392
326
|
};
|
|
393
327
|
entriesOverMin.push(entry);
|
|
394
328
|
}
|
|
395
|
-
|
|
396
329
|
allEntries.push(entry);
|
|
397
330
|
}
|
|
331
|
+
|
|
398
332
|
/**
|
|
399
333
|
* If there is nothing under min, or there is not enough over to make up the difference, do nothing.
|
|
400
334
|
*/
|
|
401
|
-
|
|
402
|
-
|
|
403
335
|
if (totalUnderMin === 0 || totalUnderMin > totalOverMin) {
|
|
404
336
|
return;
|
|
405
337
|
}
|
|
338
|
+
|
|
406
339
|
/**
|
|
407
340
|
* Evenly reduce all columns that are over the min item width to make up the difference.
|
|
408
341
|
*/
|
|
409
|
-
|
|
410
|
-
|
|
411
342
|
var reducePercent = totalUnderMin / totalOverMin;
|
|
412
343
|
remainingWidth = totalUnderMin;
|
|
413
|
-
|
|
414
344
|
for (var _i4 = 0; _i4 < entriesOverMin.length; _i4++) {
|
|
415
345
|
entry = entriesOverMin[_i4];
|
|
416
346
|
var reducedWidth = Math.round((entry.width - minItemWidth) * reducePercent);
|
|
417
347
|
remainingWidth -= reducedWidth;
|
|
418
348
|
entry.width -= reducedWidth;
|
|
419
349
|
}
|
|
350
|
+
|
|
420
351
|
/**
|
|
421
352
|
* Take anything remaining from the last item.
|
|
422
353
|
*/
|
|
423
|
-
|
|
424
|
-
|
|
425
354
|
if (remainingWidth !== 0) {
|
|
426
355
|
allEntries[allEntries.length - 1].width -= remainingWidth;
|
|
427
356
|
}
|
|
357
|
+
|
|
428
358
|
/**
|
|
429
359
|
* Set every items size relative to 100 relative to its size to total
|
|
430
360
|
*/
|
|
431
|
-
|
|
432
|
-
|
|
433
361
|
for (var _i5 = 0; _i5 < this.contentItems.length; _i5++) {
|
|
434
362
|
this.contentItems[_i5].config.width = allEntries[_i5].width / sizeData.totalWidth * 100;
|
|
435
363
|
}
|
|
436
364
|
}
|
|
365
|
+
|
|
437
366
|
/**
|
|
438
367
|
* Instantiates a new lm.controls.Splitter, binds events to it and adds
|
|
439
368
|
* it to the array of splitters at the position specified as the index argument
|
|
@@ -443,19 +372,16 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
443
372
|
* @param index The position of the splitter
|
|
444
373
|
* @returns The created splitter
|
|
445
374
|
*/
|
|
446
|
-
|
|
447
|
-
|
|
448
375
|
_createSplitter(index) {
|
|
449
376
|
var splitter;
|
|
450
377
|
splitter = new Splitter(this._isColumn, this._splitterSize, this._splitterGrabSize);
|
|
451
378
|
splitter.on('drag', this._onSplitterDrag.bind(this, splitter), this);
|
|
452
379
|
splitter.on('dragStop', this._onSplitterDragStop.bind(this, splitter), this);
|
|
453
380
|
splitter.on('dragStart', this._onSplitterDragStart.bind(this, splitter), this);
|
|
454
|
-
|
|
455
381
|
this._splitter.splice(index, 0, splitter);
|
|
456
|
-
|
|
457
382
|
return splitter;
|
|
458
383
|
}
|
|
384
|
+
|
|
459
385
|
/**
|
|
460
386
|
* Locates the instance of lm.controls.Splitter in the array of
|
|
461
387
|
* registered splitters and returns a map containing the contentItem
|
|
@@ -466,69 +392,55 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
466
392
|
*
|
|
467
393
|
* @returns A map of contentItems that the splitter affects
|
|
468
394
|
*/
|
|
469
|
-
|
|
470
|
-
|
|
471
395
|
_getItemsForSplitter(splitter) {
|
|
472
396
|
var index = this._splitter.indexOf(splitter);
|
|
473
|
-
|
|
474
397
|
if (index < 0) {
|
|
475
398
|
throw new Error('Splitter not found in RowOrColumn');
|
|
476
399
|
}
|
|
477
|
-
|
|
478
400
|
return {
|
|
479
401
|
before: this.contentItems[index],
|
|
480
402
|
after: this.contentItems[index + 1]
|
|
481
403
|
};
|
|
482
404
|
}
|
|
405
|
+
|
|
483
406
|
/**
|
|
484
407
|
* Gets the minimum dimensions for the given item configuration array
|
|
485
408
|
* @param item
|
|
486
409
|
* @private
|
|
487
410
|
*/
|
|
488
|
-
|
|
489
|
-
|
|
490
411
|
_getMinimumDimensions(arr) {
|
|
491
412
|
var minWidth = 0,
|
|
492
|
-
|
|
493
|
-
|
|
413
|
+
minHeight = 0;
|
|
494
414
|
for (var i = 0; i < arr.length; ++i) {
|
|
495
415
|
var _arr$i$minWidth, _arr$i$minHeight;
|
|
496
|
-
|
|
497
416
|
minWidth = Math.max((_arr$i$minWidth = arr[i].minWidth) !== null && _arr$i$minWidth !== void 0 ? _arr$i$minWidth : 0, minWidth);
|
|
498
417
|
minHeight = Math.max((_arr$i$minHeight = arr[i].minHeight) !== null && _arr$i$minHeight !== void 0 ? _arr$i$minHeight : 0, minHeight);
|
|
499
418
|
}
|
|
500
|
-
|
|
501
419
|
return {
|
|
502
420
|
horizontal: minWidth,
|
|
503
421
|
vertical: minHeight
|
|
504
422
|
};
|
|
505
423
|
}
|
|
424
|
+
|
|
506
425
|
/**
|
|
507
426
|
* Invoked when a splitter's dragListener fires dragStart. Calculates the splitters
|
|
508
427
|
* movement area once (so that it doesn't need calculating on every mousemove event)
|
|
509
428
|
*
|
|
510
429
|
* @param splitter
|
|
511
430
|
*/
|
|
512
|
-
|
|
513
|
-
|
|
514
431
|
_onSplitterDragStart(splitter) {
|
|
515
432
|
var _items$before$config$, _items$after$config$c, _items$before$element, _items$after$element$;
|
|
516
|
-
|
|
517
433
|
var items = this._getItemsForSplitter(splitter);
|
|
518
|
-
|
|
519
434
|
var minSize = this.layoutManager.config.dimensions[this._isColumn ? 'minItemHeight' : 'minItemWidth'];
|
|
520
|
-
|
|
521
435
|
var beforeMinDim = this._getMinimumDimensions((_items$before$config$ = items.before.config.content) !== null && _items$before$config$ !== void 0 ? _items$before$config$ : []);
|
|
522
|
-
|
|
523
436
|
var beforeMinSize = this._isColumn ? beforeMinDim.vertical : beforeMinDim.horizontal;
|
|
524
|
-
|
|
525
437
|
var afterMinDim = this._getMinimumDimensions((_items$after$config$c = items.after.config.content) !== null && _items$after$config$c !== void 0 ? _items$after$config$c : []);
|
|
526
|
-
|
|
527
438
|
var afterMinSize = this._isColumn ? afterMinDim.vertical : afterMinDim.horizontal;
|
|
528
439
|
this._splitterPosition = 0;
|
|
529
440
|
this._splitterMinPosition = -1 * (((_items$before$element = items.before.element[this._dimension]()) !== null && _items$before$element !== void 0 ? _items$before$element : 0) - (beforeMinSize || minSize));
|
|
530
441
|
this._splitterMaxPosition = ((_items$after$element$ = items.after.element[this._dimension]()) !== null && _items$after$element$ !== void 0 ? _items$after$element$ : 0) - (afterMinSize || minSize);
|
|
531
442
|
}
|
|
443
|
+
|
|
532
444
|
/**
|
|
533
445
|
* Invoked when a splitter's DragListener fires drag. Updates the splitters DOM position,
|
|
534
446
|
* but not the sizes of the elements the splitter controls in order to minimize resize events
|
|
@@ -537,20 +449,17 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
537
449
|
* @param offsetX Relative pixel values to the splitters original position. Can be negative
|
|
538
450
|
* @param offsetY Relative pixel values to the splitters original position. Can be negative
|
|
539
451
|
*/
|
|
540
|
-
|
|
541
|
-
|
|
542
452
|
_onSplitterDrag(splitter, offsetX, offsetY) {
|
|
543
453
|
var offset = this._isColumn ? offsetY : offsetX;
|
|
544
|
-
|
|
545
454
|
if (this._splitterMaxPosition == null || this._splitterMinPosition == null) {
|
|
546
455
|
return;
|
|
547
456
|
}
|
|
548
|
-
|
|
549
457
|
if (offset > this._splitterMinPosition && offset < this._splitterMaxPosition) {
|
|
550
458
|
this._splitterPosition = offset;
|
|
551
459
|
splitter.element.css(this._isColumn ? 'top' : 'left', offset);
|
|
552
460
|
}
|
|
553
461
|
}
|
|
462
|
+
|
|
554
463
|
/**
|
|
555
464
|
* Invoked when a splitter's DragListener fires dragStop. Resets the splitters DOM position,
|
|
556
465
|
* and applies the new sizes to the elements before and after the splitter and their children
|
|
@@ -558,13 +467,9 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
558
467
|
*
|
|
559
468
|
* @param {lm.controls.Splitter} splitter
|
|
560
469
|
*/
|
|
561
|
-
|
|
562
|
-
|
|
563
470
|
_onSplitterDragStop(splitter) {
|
|
564
471
|
var _items$before$element2, _items$after$element$2, _this$_splitterPositi, _items$before$config$2, _items$after$config$t;
|
|
565
|
-
|
|
566
472
|
var items = this._getItemsForSplitter(splitter);
|
|
567
|
-
|
|
568
473
|
var sizeBefore = (_items$before$element2 = items.before.element[this._dimension]()) !== null && _items$before$element2 !== void 0 ? _items$before$element2 : 0;
|
|
569
474
|
var sizeAfter = (_items$after$element$2 = items.after.element[this._dimension]()) !== null && _items$after$element$2 !== void 0 ? _items$after$element$2 : 0;
|
|
570
475
|
var splitterPositionInRange = (((_this$_splitterPositi = this._splitterPosition) !== null && _this$_splitterPositi !== void 0 ? _this$_splitterPositi : 0) + sizeBefore) / (sizeBefore + sizeAfter);
|
|
@@ -577,6 +482,5 @@ export default class RowOrColumn extends AbstractContentItem {
|
|
|
577
482
|
});
|
|
578
483
|
animFrame(this.callDownwards.bind(this, 'setSize', undefined, undefined, undefined));
|
|
579
484
|
}
|
|
580
|
-
|
|
581
485
|
}
|
|
582
486
|
//# sourceMappingURL=RowOrColumn.js.map
|