gridstack 4.4.1 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -16
- package/dist/es5/gridstack-dd.d.ts +1 -1
- package/dist/es5/gridstack-dd.js +13 -10
- package/dist/es5/gridstack-dd.js.map +1 -1
- package/dist/es5/gridstack-ddi.d.ts +1 -1
- package/dist/es5/gridstack-ddi.js +1 -1
- package/dist/es5/gridstack-ddi.js.map +1 -1
- package/dist/es5/gridstack-engine.d.ts +11 -7
- package/dist/es5/gridstack-engine.js +30 -40
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-h5.d.ts +1 -1
- package/dist/es5/gridstack-h5.js +1 -1
- package/dist/es5/gridstack-h5.js.LICENSE.txt +2 -2
- package/dist/es5/gridstack-h5.js.map +1 -1
- package/dist/es5/gridstack-jq.d.ts +1 -1
- package/dist/es5/gridstack-jq.js +1 -1
- package/dist/es5/gridstack-jq.js.LICENSE.txt +8 -8
- package/dist/es5/gridstack-jq.js.map +1 -1
- package/dist/es5/gridstack-poly.js +3 -3
- package/dist/es5/gridstack-static.d.ts +1 -1
- package/dist/es5/gridstack-static.js +1 -1
- package/dist/es5/gridstack-static.js.LICENSE.txt +2 -2
- package/dist/es5/gridstack-static.js.map +1 -1
- package/dist/es5/gridstack.d.ts +11 -5
- package/dist/es5/gridstack.js +91 -41
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/h5/dd-base-impl.d.ts +2 -2
- package/dist/es5/h5/dd-base-impl.js +2 -2
- package/dist/es5/h5/dd-base-impl.js.map +1 -1
- package/dist/es5/h5/dd-draggable.d.ts +2 -3
- package/dist/es5/h5/dd-draggable.js +29 -22
- package/dist/es5/h5/dd-draggable.js.map +1 -1
- package/dist/es5/h5/dd-droppable.d.ts +3 -2
- package/dist/es5/h5/dd-droppable.js +43 -26
- package/dist/es5/h5/dd-droppable.js.map +1 -1
- package/dist/es5/h5/dd-element.d.ts +1 -1
- package/dist/es5/h5/dd-element.js +1 -1
- package/dist/es5/h5/dd-element.js.map +1 -1
- package/dist/es5/h5/dd-manager.d.ts +1 -1
- package/dist/es5/h5/dd-manager.js +1 -1
- package/dist/es5/h5/dd-manager.js.map +1 -1
- package/dist/es5/h5/dd-resizable-handle.d.ts +2 -2
- package/dist/es5/h5/dd-resizable-handle.js +2 -2
- package/dist/es5/h5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/h5/dd-resizable.d.ts +2 -3
- package/dist/es5/h5/dd-resizable.js +3 -4
- package/dist/es5/h5/dd-resizable.js.map +1 -1
- package/dist/es5/h5/dd-utils.d.ts +3 -1
- package/dist/es5/h5/dd-utils.js +13 -1
- package/dist/es5/h5/dd-utils.js.map +1 -1
- package/dist/es5/h5/gridstack-dd-native.d.ts +2 -2
- package/dist/es5/h5/gridstack-dd-native.js +2 -2
- package/dist/es5/h5/gridstack-dd-native.js.map +1 -1
- package/dist/es5/jq/gridstack-dd-jqueryui.js.map +1 -1
- package/dist/es5/types.d.ts +14 -6
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +3 -3
- package/dist/es5/utils.js +16 -15
- package/dist/es5/utils.js.map +1 -1
- package/dist/gridstack-dd.d.ts +1 -1
- package/dist/gridstack-dd.js +13 -10
- package/dist/gridstack-dd.js.map +1 -1
- package/dist/gridstack-ddi.d.ts +1 -1
- package/dist/gridstack-ddi.js +1 -1
- package/dist/gridstack-ddi.js.map +1 -1
- package/dist/gridstack-engine.d.ts +11 -7
- package/dist/gridstack-engine.js +30 -39
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack-h5.d.ts +1 -1
- package/dist/gridstack-h5.js +1 -1
- package/dist/gridstack-h5.js.LICENSE.txt +2 -2
- package/dist/gridstack-h5.js.map +1 -1
- package/dist/gridstack-jq.d.ts +1 -1
- package/dist/gridstack-jq.js +1 -1
- package/dist/gridstack-jq.js.LICENSE.txt +8 -8
- package/dist/gridstack-jq.js.map +1 -1
- package/dist/gridstack-static.d.ts +1 -1
- package/dist/gridstack-static.js +1 -1
- package/dist/gridstack-static.js.LICENSE.txt +2 -2
- package/dist/gridstack-static.js.map +1 -1
- package/dist/gridstack.css +1 -4
- package/dist/gridstack.d.ts +11 -5
- package/dist/gridstack.js +91 -41
- package/dist/gridstack.js.map +1 -1
- package/dist/gridstack.min.css +1 -1
- package/dist/h5/dd-base-impl.d.ts +2 -2
- package/dist/h5/dd-base-impl.js +2 -2
- package/dist/h5/dd-base-impl.js.map +1 -1
- package/dist/h5/dd-draggable.d.ts +2 -3
- package/dist/h5/dd-draggable.js +29 -22
- package/dist/h5/dd-draggable.js.map +1 -1
- package/dist/h5/dd-droppable.d.ts +3 -2
- package/dist/h5/dd-droppable.js +43 -26
- package/dist/h5/dd-droppable.js.map +1 -1
- package/dist/h5/dd-element.d.ts +1 -1
- package/dist/h5/dd-element.js +1 -1
- package/dist/h5/dd-element.js.map +1 -1
- package/dist/h5/dd-manager.d.ts +1 -1
- package/dist/h5/dd-manager.js +1 -1
- package/dist/h5/dd-manager.js.map +1 -1
- package/dist/h5/dd-resizable-handle.d.ts +2 -2
- package/dist/h5/dd-resizable-handle.js +2 -2
- package/dist/h5/dd-resizable-handle.js.map +1 -1
- package/dist/h5/dd-resizable.d.ts +2 -3
- package/dist/h5/dd-resizable.js +3 -4
- package/dist/h5/dd-resizable.js.map +1 -1
- package/dist/h5/dd-utils.d.ts +3 -1
- package/dist/h5/dd-utils.js +13 -1
- package/dist/h5/dd-utils.js.map +1 -1
- package/dist/h5/gridstack-dd-native.d.ts +2 -2
- package/dist/h5/gridstack-dd-native.js +2 -2
- package/dist/h5/gridstack-dd-native.js.map +1 -1
- package/dist/jq/gridstack-dd-jqueryui.js.map +1 -1
- package/dist/jq/jquery-ui.js +1 -1
- package/dist/jq/jquery-ui.js.map +1 -1
- package/dist/src/gridstack.scss +5 -4
- package/dist/types.d.ts +14 -6
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +15 -14
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +20 -0
- package/doc/README.md +17 -6
- package/package.json +4 -4
package/dist/gridstack.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* gridstack SASS styles
|
|
2
|
+
* gridstack SASS styles 5.1.1
|
|
3
3
|
* Copyright (c) 2021 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
:root .grid-stack-item > .ui-resizable-handle {
|
|
@@ -305,7 +305,4 @@
|
|
|
305
305
|
-ms-transition: left 0s, top 0s, height 0s, width 0s;
|
|
306
306
|
-o-transition: left 0s, top 0s, height 0s, width 0s;
|
|
307
307
|
transition: left 0s, top 0s, height 0s, width 0s;
|
|
308
|
-
}
|
|
309
|
-
.grid-stack.ui-droppable.ui-droppable-over > *:not(.ui-droppable) {
|
|
310
|
-
pointer-events: none;
|
|
311
308
|
}
|
package/dist/gridstack.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GridStack
|
|
2
|
+
* GridStack 5.1.1
|
|
3
3
|
* https://gridstackjs.com/
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c) 2021 Alain Dumesny
|
|
5
|
+
* Copyright (c) 2021-2022 Alain Dumesny
|
|
6
6
|
* see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
|
|
7
7
|
*/
|
|
8
8
|
import { GridStackEngine } from './gridstack-engine';
|
|
@@ -70,6 +70,11 @@ export declare class GridStack {
|
|
|
70
70
|
* @param opt grids options used to initialize the grid, and list of children
|
|
71
71
|
*/
|
|
72
72
|
static addGrid(parent: HTMLElement, opt?: GridStackOptions): GridStack;
|
|
73
|
+
/** call this method to register your engine instead of the default one.
|
|
74
|
+
* See instead `GridStackOptions.engineClass` if you only need to
|
|
75
|
+
* replace just one instance.
|
|
76
|
+
*/
|
|
77
|
+
static registerEngine(engineClass: typeof GridStackEngine): void;
|
|
73
78
|
/** scoping so users can call GridStack.Utils.sort() for example */
|
|
74
79
|
static Utils: typeof Utils;
|
|
75
80
|
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
@@ -80,6 +85,7 @@ export declare class GridStack {
|
|
|
80
85
|
engine: GridStackEngine;
|
|
81
86
|
/** grid options - public for classes to access, but use methods to modify! */
|
|
82
87
|
opts: GridStackOptions;
|
|
88
|
+
protected static engineClass: typeof GridStackEngine;
|
|
83
89
|
/**
|
|
84
90
|
* Construct a grid item from the given element and options
|
|
85
91
|
* @param el
|
|
@@ -149,7 +155,7 @@ export declare class GridStack {
|
|
|
149
155
|
/** Gets current cell width. */
|
|
150
156
|
cellWidth(): number;
|
|
151
157
|
/** return our expected width (or parent) for 1 column check */
|
|
152
|
-
|
|
158
|
+
protected _widthOrContainer(): number;
|
|
153
159
|
/**
|
|
154
160
|
* Finishes batch updates. Updates DOM nodes. You must call it after batchUpdate.
|
|
155
161
|
*/
|
|
@@ -290,11 +296,11 @@ export declare class GridStack {
|
|
|
290
296
|
willItFit(node: GridStackWidget): boolean;
|
|
291
297
|
/**
|
|
292
298
|
* called when we are being resized by the window - check if the one Column Mode needs to be turned on/off
|
|
293
|
-
* and remember the prev columns we used, as well as check for auto cell height (square)
|
|
299
|
+
* and remember the prev columns we used, or get our count from parent, as well as check for auto cell height (square)
|
|
294
300
|
*/
|
|
295
301
|
onParentResize(): GridStack;
|
|
296
302
|
/** add or remove the window size event handler */
|
|
297
|
-
|
|
303
|
+
protected _updateWindowResizeEvent(forceRemove?: boolean): GridStack;
|
|
298
304
|
/**
|
|
299
305
|
* call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.
|
|
300
306
|
* Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar
|
package/dist/gridstack.js
CHANGED
|
@@ -12,10 +12,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.GridStack = void 0;
|
|
14
14
|
/*!
|
|
15
|
-
* GridStack
|
|
15
|
+
* GridStack 5.1.1
|
|
16
16
|
* https://gridstackjs.com/
|
|
17
17
|
*
|
|
18
|
-
* Copyright (c) 2021 Alain Dumesny
|
|
18
|
+
* Copyright (c) 2021-2022 Alain Dumesny
|
|
19
19
|
* see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
|
|
20
20
|
*/
|
|
21
21
|
const gridstack_engine_1 = require("./gridstack-engine");
|
|
@@ -41,7 +41,7 @@ const GridDefaults = {
|
|
|
41
41
|
cellHeightThrottle: 100,
|
|
42
42
|
margin: 10,
|
|
43
43
|
auto: true,
|
|
44
|
-
|
|
44
|
+
oneColumnSize: 768,
|
|
45
45
|
float: false,
|
|
46
46
|
staticGrid: false,
|
|
47
47
|
animate: true,
|
|
@@ -96,6 +96,17 @@ class GridStack {
|
|
|
96
96
|
delete opts.row;
|
|
97
97
|
}
|
|
98
98
|
let rowAttr = utils_1.Utils.toNumber(el.getAttribute('gs-row'));
|
|
99
|
+
// flag only valid in sub-grids (handled by parent, not here)
|
|
100
|
+
if (opts.column === 'auto') {
|
|
101
|
+
delete opts.column;
|
|
102
|
+
}
|
|
103
|
+
// 'minWidth' legacy support in 5.1
|
|
104
|
+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
|
105
|
+
let anyOpts = opts;
|
|
106
|
+
if (anyOpts.minWidth !== undefined) {
|
|
107
|
+
opts.oneColumnSize = opts.oneColumnSize || anyOpts.minWidth;
|
|
108
|
+
delete anyOpts.minWidth;
|
|
109
|
+
}
|
|
99
110
|
// elements attributes override any passed options (like CSS style) - merge the two together
|
|
100
111
|
let defaults = Object.assign(Object.assign({}, utils_1.Utils.cloneDeep(GridDefaults)), { column: utils_1.Utils.toNumber(el.getAttribute('gs-column')) || 12, minRow: rowAttr ? rowAttr : utils_1.Utils.toNumber(el.getAttribute('gs-min-row')) || 0, maxRow: rowAttr ? rowAttr : utils_1.Utils.toNumber(el.getAttribute('gs-max-row')) || 0, staticGrid: utils_1.Utils.toBool(el.getAttribute('gs-static')) || false, _styleSheetClass: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0), alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false, resizable: {
|
|
101
112
|
autoHide: !(opts.alwaysShowResizeHandle || false),
|
|
@@ -112,10 +123,10 @@ class GridStack {
|
|
|
112
123
|
}
|
|
113
124
|
this.opts = utils_1.Utils.defaults(opts, defaults);
|
|
114
125
|
opts = null; // make sure we use this.opts instead
|
|
115
|
-
this.
|
|
126
|
+
this._initMargin(); // part of settings defaults...
|
|
116
127
|
// Now check if we're loading into 1 column mode FIRST so we don't do un-necessary work (like cellHeight = width / 12 then go 1 column)
|
|
117
|
-
if (this.opts.column !== 1 && !this.opts.disableOneColumnMode && this._widthOrContainer() <= this.opts.
|
|
118
|
-
this._prevColumn = this.
|
|
128
|
+
if (this.opts.column !== 1 && !this.opts.disableOneColumnMode && this._widthOrContainer() <= this.opts.oneColumnSize) {
|
|
129
|
+
this._prevColumn = this.getColumn();
|
|
119
130
|
this.opts.column = 1;
|
|
120
131
|
}
|
|
121
132
|
if (this.opts.rtl === 'auto') {
|
|
@@ -129,6 +140,7 @@ class GridStack {
|
|
|
129
140
|
if (parentGridItemEl && parentGridItemEl.gridstackNode) {
|
|
130
141
|
this.opts._isNested = parentGridItemEl.gridstackNode;
|
|
131
142
|
this.opts._isNested.subGrid = this;
|
|
143
|
+
parentGridItemEl.classList.add('grid-stack-nested');
|
|
132
144
|
this.el.classList.add('grid-stack-nested');
|
|
133
145
|
}
|
|
134
146
|
this._isAutoCellHeight = (this.opts.cellHeight === 'auto');
|
|
@@ -146,8 +158,9 @@ class GridStack {
|
|
|
146
158
|
}
|
|
147
159
|
this.el.classList.add(this.opts._styleSheetClass);
|
|
148
160
|
this._setStaticClass();
|
|
149
|
-
this.
|
|
150
|
-
|
|
161
|
+
let engineClass = this.opts.engineClass || GridStack.engineClass || gridstack_engine_1.GridStackEngine;
|
|
162
|
+
this.engine = new engineClass({
|
|
163
|
+
column: this.getColumn(),
|
|
151
164
|
float: this.opts.float,
|
|
152
165
|
maxRow: this.opts.maxRow,
|
|
153
166
|
onChange: (cbNodes) => {
|
|
@@ -178,7 +191,7 @@ class GridStack {
|
|
|
178
191
|
elements.push({
|
|
179
192
|
el,
|
|
180
193
|
// if x,y are missing (autoPosition) add them to end of list - but keep their respective DOM order
|
|
181
|
-
i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * this.
|
|
194
|
+
i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * this.getColumn()
|
|
182
195
|
});
|
|
183
196
|
});
|
|
184
197
|
elements.sort((a, b) => a.i - b.i).forEach(e => this._prepareElement(e.el));
|
|
@@ -280,6 +293,13 @@ class GridStack {
|
|
|
280
293
|
}
|
|
281
294
|
return grid;
|
|
282
295
|
}
|
|
296
|
+
/** call this method to register your engine instead of the default one.
|
|
297
|
+
* See instead `GridStackOptions.engineClass` if you only need to
|
|
298
|
+
* replace just one instance.
|
|
299
|
+
*/
|
|
300
|
+
static registerEngine(engineClass) {
|
|
301
|
+
GridStack.engineClass = engineClass;
|
|
302
|
+
}
|
|
283
303
|
/** @internal create placeholder DIV as needed */
|
|
284
304
|
get placeholder() {
|
|
285
305
|
if (!this._placeholder) {
|
|
@@ -356,8 +376,19 @@ class GridStack {
|
|
|
356
376
|
this._updateContainerHeight();
|
|
357
377
|
// check if nested grid definition is present
|
|
358
378
|
if (node.subGrid && !node.subGrid.el) { // see if there is a sub-grid to create too
|
|
379
|
+
// if column special case it set, remember that flag and set default
|
|
380
|
+
let autoColumn;
|
|
381
|
+
let ops = node.subGrid;
|
|
382
|
+
if (ops.column === 'auto') {
|
|
383
|
+
ops.column = node.w;
|
|
384
|
+
ops.disableOneColumnMode = true; // driven by parent
|
|
385
|
+
autoColumn = true;
|
|
386
|
+
}
|
|
359
387
|
let content = node.el.querySelector('.grid-stack-item-content');
|
|
360
388
|
node.subGrid = GridStack.addGrid(content, node.subGrid);
|
|
389
|
+
if (autoColumn) {
|
|
390
|
+
node.subGrid._autoColumn = true;
|
|
391
|
+
}
|
|
361
392
|
}
|
|
362
393
|
this._triggerAddEvent();
|
|
363
394
|
this._triggerChangeEvent();
|
|
@@ -411,6 +442,10 @@ class GridStack {
|
|
|
411
442
|
if (this._isAutoCellHeight) {
|
|
412
443
|
o.cellHeight = 'auto';
|
|
413
444
|
}
|
|
445
|
+
if (this._autoColumn) {
|
|
446
|
+
o.column = 'auto';
|
|
447
|
+
delete o.disableOneColumnMode;
|
|
448
|
+
}
|
|
414
449
|
utils_1.Utils.removeInternalAndSame(o, GridDefaults);
|
|
415
450
|
o.children = list;
|
|
416
451
|
return o;
|
|
@@ -428,7 +463,7 @@ class GridStack {
|
|
|
428
463
|
* see http://gridstackjs.com/demo/serialization.html
|
|
429
464
|
**/
|
|
430
465
|
load(layout, addAndRemove = true) {
|
|
431
|
-
let items = GridStack.Utils.sort([...layout], -1, this._prevColumn || this.
|
|
466
|
+
let items = GridStack.Utils.sort([...layout], -1, this._prevColumn || this.getColumn()); // make copy before we mod/sort
|
|
432
467
|
this._insertNotAppend = true; // since create in reverse order...
|
|
433
468
|
// if we're loading a layout into 1 column (_prevColumn is set only when going to 1) and items don't fit, make sure to save
|
|
434
469
|
// the original wanted layout so we can scale back up correctly #1471
|
|
@@ -498,12 +533,15 @@ class GridStack {
|
|
|
498
533
|
(!forcePixel || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === 'px')) {
|
|
499
534
|
return this.opts.cellHeight;
|
|
500
535
|
}
|
|
501
|
-
// else
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
536
|
+
// else get first cell height
|
|
537
|
+
let el = this.el.querySelector('.' + this.opts.itemClass);
|
|
538
|
+
if (el) {
|
|
539
|
+
let height = utils_1.Utils.toNumber(el.getAttribute('gs-h'));
|
|
540
|
+
return Math.round(el.offsetHeight / height);
|
|
541
|
+
}
|
|
542
|
+
// else do entire grid and # of rows (but doesn't work if min-height is the actual constrain)
|
|
543
|
+
let rows = parseInt(this.el.getAttribute('gs-current-row'));
|
|
544
|
+
return rows ? Math.round(this.el.getBoundingClientRect().height / rows) : this.opts.cellHeight;
|
|
507
545
|
}
|
|
508
546
|
/**
|
|
509
547
|
* Update current cell height - see `GridStackOptions.cellHeight` for format.
|
|
@@ -549,7 +587,7 @@ class GridStack {
|
|
|
549
587
|
}
|
|
550
588
|
/** Gets current cell width. */
|
|
551
589
|
cellWidth() {
|
|
552
|
-
return this._widthOrContainer() / this.
|
|
590
|
+
return this._widthOrContainer() / this.getColumn();
|
|
553
591
|
}
|
|
554
592
|
/** return our expected width (or parent) for 1 column check */
|
|
555
593
|
_widthOrContainer() {
|
|
@@ -585,7 +623,7 @@ class GridStack {
|
|
|
585
623
|
column(column, layout = 'moveScale') {
|
|
586
624
|
if (column < 1 || this.opts.column === column)
|
|
587
625
|
return this;
|
|
588
|
-
let oldColumn = this.
|
|
626
|
+
let oldColumn = this.getColumn();
|
|
589
627
|
// if we go into 1 column mode (which happens if we're sized less than minW unless disableOneColumnMode is on)
|
|
590
628
|
// then remember the original columns so we can restore.
|
|
591
629
|
if (column === 1) {
|
|
@@ -694,7 +732,7 @@ class GridStack {
|
|
|
694
732
|
}
|
|
695
733
|
let relativeLeft = position.left - containerPos.left;
|
|
696
734
|
let relativeTop = position.top - containerPos.top;
|
|
697
|
-
let columnWidth = (box.width / this.
|
|
735
|
+
let columnWidth = (box.width / this.getColumn());
|
|
698
736
|
let rowHeight = (box.height / parseInt(this.el.getAttribute('gs-current-row')));
|
|
699
737
|
return { x: Math.floor(relativeLeft / columnWidth), y: Math.floor(relativeTop / rowHeight) };
|
|
700
738
|
}
|
|
@@ -955,7 +993,7 @@ class GridStack {
|
|
|
955
993
|
// re-use existing margin handling
|
|
956
994
|
this.opts.margin = value;
|
|
957
995
|
this.opts.marginTop = this.opts.marginBottom = this.opts.marginLeft = this.opts.marginRight = undefined;
|
|
958
|
-
this.
|
|
996
|
+
this._initMargin();
|
|
959
997
|
this._updateStyles(true); // true = force re-create
|
|
960
998
|
return this;
|
|
961
999
|
}
|
|
@@ -1100,13 +1138,15 @@ class GridStack {
|
|
|
1100
1138
|
return this;
|
|
1101
1139
|
let row = this.getRow() + this._extraDragRow; // checks for minRow already
|
|
1102
1140
|
// check for css min height
|
|
1103
|
-
|
|
1104
|
-
if
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1141
|
+
// Note: we don't handle %,rem correctly so comment out, beside we don't need need to create un-necessary
|
|
1142
|
+
// rows as the CSS will make us bigger than our set height if needed... not sure why we had this.
|
|
1143
|
+
// let cssMinHeight = parseInt(getComputedStyle(this.el)['min-height']);
|
|
1144
|
+
// if (cssMinHeight > 0) {
|
|
1145
|
+
// let minRow = Math.round(cssMinHeight / this.getCellHeight(true));
|
|
1146
|
+
// if (row < minRow) {
|
|
1147
|
+
// row = minRow;
|
|
1148
|
+
// }
|
|
1149
|
+
// }
|
|
1110
1150
|
this.el.setAttribute('gs-current-row', String(row));
|
|
1111
1151
|
if (row === 0) {
|
|
1112
1152
|
this.el.style.removeProperty('height');
|
|
@@ -1222,33 +1262,43 @@ class GridStack {
|
|
|
1222
1262
|
}
|
|
1223
1263
|
/**
|
|
1224
1264
|
* called when we are being resized by the window - check if the one Column Mode needs to be turned on/off
|
|
1225
|
-
* and remember the prev columns we used, as well as check for auto cell height (square)
|
|
1265
|
+
* and remember the prev columns we used, or get our count from parent, as well as check for auto cell height (square)
|
|
1226
1266
|
*/
|
|
1227
1267
|
onParentResize() {
|
|
1228
1268
|
if (!this.el || !this.el.clientWidth)
|
|
1229
1269
|
return; // return if we're gone or no size yet (will get called again)
|
|
1230
|
-
let
|
|
1231
|
-
|
|
1232
|
-
if (
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
this.
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1270
|
+
let changedColumn = false;
|
|
1271
|
+
// see if we're nested and take our column count from our parent....
|
|
1272
|
+
if (this._autoColumn && this.opts._isNested) {
|
|
1273
|
+
if (this.opts.column !== this.opts._isNested.w) {
|
|
1274
|
+
changedColumn = true;
|
|
1275
|
+
this.column(this.opts._isNested.w, 'none');
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
else {
|
|
1279
|
+
// else check for 1 column in/out behavior
|
|
1280
|
+
let oneColumn = !this.opts.disableOneColumnMode && this.el.clientWidth <= this.opts.oneColumnSize;
|
|
1281
|
+
if ((this.opts.column === 1) !== oneColumn) {
|
|
1282
|
+
changedColumn = true;
|
|
1283
|
+
if (this.opts.animate) {
|
|
1284
|
+
this.setAnimation(false);
|
|
1285
|
+
} // 1 <-> 12 is too radical, turn off animation
|
|
1286
|
+
this.column(oneColumn ? 1 : this._prevColumn);
|
|
1287
|
+
if (this.opts.animate) {
|
|
1288
|
+
this.setAnimation(true);
|
|
1289
|
+
}
|
|
1240
1290
|
}
|
|
1241
1291
|
}
|
|
1242
1292
|
// make the cells content square again
|
|
1243
1293
|
if (this._isAutoCellHeight) {
|
|
1244
|
-
if (!
|
|
1294
|
+
if (!changedColumn && this.opts.cellHeightThrottle) {
|
|
1245
1295
|
if (!this._cellHeightThrottle) {
|
|
1246
1296
|
this._cellHeightThrottle = utils_1.Utils.throttle(() => this.cellHeight(), this.opts.cellHeightThrottle);
|
|
1247
1297
|
}
|
|
1248
1298
|
this._cellHeightThrottle();
|
|
1249
1299
|
}
|
|
1250
1300
|
else {
|
|
1251
|
-
// immediate update if we've changed
|
|
1301
|
+
// immediate update if we've changed column count or have no threshold
|
|
1252
1302
|
this.cellHeight();
|
|
1253
1303
|
}
|
|
1254
1304
|
}
|
|
@@ -1283,7 +1333,7 @@ class GridStack {
|
|
|
1283
1333
|
/** @internal */
|
|
1284
1334
|
static getGridElements(els) { return utils_1.Utils.getElements(els); }
|
|
1285
1335
|
/** @internal initialize margin top/bottom/left/right and units */
|
|
1286
|
-
|
|
1336
|
+
_initMargin() {
|
|
1287
1337
|
let data;
|
|
1288
1338
|
let margin = 0;
|
|
1289
1339
|
// support passing multiple values like CSS (ex: '5px 10px 0 20px')
|