gridstack 10.0.0 → 10.0.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/angular/package.json +1 -1
- package/angular/projects/lib/package.json +1 -1
- package/angular/projects/lib/src/lib/base-widget.ts +1 -1
- package/angular/projects/lib/src/lib/gridstack-item.component.ts +1 -1
- package/angular/projects/lib/src/lib/gridstack.component.ts +1 -1
- package/angular/projects/lib/src/lib/gridstack.module.ts +1 -1
- package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack.component.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
- package/dist/angular/fesm2015/gridstack-angular.mjs +4 -4
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
- package/dist/angular/fesm2020/gridstack-angular.mjs +4 -4
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
- package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
- package/dist/angular/lib/gridstack.component.d.ts +1 -1
- package/dist/angular/package.json +1 -1
- package/dist/angular/src/base-widget.ts +1 -1
- package/dist/angular/src/gridstack-item.component.ts +1 -1
- package/dist/angular/src/gridstack.component.ts +1 -1
- package/dist/angular/src/gridstack.module.ts +1 -1
- package/dist/dd-base-impl.d.ts +1 -1
- package/dist/dd-base-impl.js +1 -1
- package/dist/dd-base-impl.js.map +1 -1
- package/dist/dd-draggable.d.ts +1 -1
- package/dist/dd-draggable.js +1 -1
- package/dist/dd-draggable.js.map +1 -1
- package/dist/dd-droppable.d.ts +1 -1
- package/dist/dd-droppable.js +1 -1
- package/dist/dd-droppable.js.map +1 -1
- package/dist/dd-element.d.ts +1 -1
- package/dist/dd-element.js +1 -1
- package/dist/dd-element.js.map +1 -1
- package/dist/dd-gridstack.d.ts +1 -1
- package/dist/dd-gridstack.js +1 -1
- package/dist/dd-gridstack.js.map +1 -1
- package/dist/dd-manager.d.ts +1 -1
- package/dist/dd-manager.js +1 -1
- package/dist/dd-manager.js.map +1 -1
- package/dist/dd-resizable-handle.d.ts +1 -1
- package/dist/dd-resizable-handle.js +1 -1
- package/dist/dd-resizable-handle.js.map +1 -1
- package/dist/dd-resizable.d.ts +1 -1
- package/dist/dd-resizable.js +1 -1
- package/dist/dd-resizable.js.map +1 -1
- package/dist/dd-touch.d.ts +1 -1
- package/dist/dd-touch.js +1 -1
- package/dist/dd-touch.js.map +1 -1
- package/dist/es5/dd-base-impl.d.ts +1 -1
- package/dist/es5/dd-base-impl.js +1 -1
- package/dist/es5/dd-base-impl.js.map +1 -1
- package/dist/es5/dd-draggable.d.ts +1 -1
- package/dist/es5/dd-draggable.js +1 -1
- package/dist/es5/dd-draggable.js.map +1 -1
- package/dist/es5/dd-droppable.d.ts +1 -1
- package/dist/es5/dd-droppable.js +1 -1
- package/dist/es5/dd-droppable.js.map +1 -1
- package/dist/es5/dd-element.d.ts +1 -1
- package/dist/es5/dd-element.js +1 -1
- package/dist/es5/dd-element.js.map +1 -1
- package/dist/es5/dd-gridstack.d.ts +1 -1
- package/dist/es5/dd-gridstack.js +1 -1
- package/dist/es5/dd-gridstack.js.map +1 -1
- package/dist/es5/dd-manager.d.ts +1 -1
- package/dist/es5/dd-manager.js +1 -1
- package/dist/es5/dd-manager.js.map +1 -1
- package/dist/es5/dd-resizable-handle.d.ts +1 -1
- package/dist/es5/dd-resizable-handle.js +1 -1
- package/dist/es5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/dd-resizable.d.ts +1 -1
- package/dist/es5/dd-resizable.js +1 -1
- package/dist/es5/dd-resizable.js.map +1 -1
- package/dist/es5/dd-touch.d.ts +1 -1
- package/dist/es5/dd-touch.js +1 -1
- package/dist/es5/dd-touch.js.map +1 -1
- package/dist/es5/gridstack-all.js +1 -1
- package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/es5/gridstack-all.js.map +1 -1
- package/dist/es5/gridstack-engine.d.ts +1 -1
- package/dist/es5/gridstack-engine.js +1 -1
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +7 -5
- package/dist/es5/gridstack.js +88 -67
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +3 -3
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +2 -2
- package/dist/es5/utils.js +4 -3
- package/dist/es5/utils.js.map +1 -1
- package/dist/gridstack-all.js +1 -1
- package/dist/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/gridstack-all.js.map +1 -1
- package/dist/gridstack-engine.d.ts +1 -1
- package/dist/gridstack-engine.js +1 -1
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +2 -2
- package/dist/gridstack.d.ts +7 -5
- package/dist/gridstack.js +91 -67
- package/dist/gridstack.js.map +1 -1
- package/dist/gridstack.min.css +1 -1
- package/dist/src/gridstack.scss +2 -2
- package/dist/types.d.ts +3 -3
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +4 -3
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +10 -1
- package/doc/README.md +6 -6
- package/package.json +2 -2
package/dist/gridstack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GridStack 10.0.
|
|
2
|
+
* GridStack 10.0.1
|
|
3
3
|
* https://gridstackjs.com/
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2021-2022 Alain Dumesny
|
|
@@ -155,6 +155,7 @@ class GridStack {
|
|
|
155
155
|
this._gsEventHandler = {};
|
|
156
156
|
/** @internal extra row added when dragging at the bottom of the grid */
|
|
157
157
|
this._extraDragRow = 0;
|
|
158
|
+
el.gridstack = this;
|
|
158
159
|
this.el = el; // exposed HTML element to the user
|
|
159
160
|
opts = opts || {}; // handles null/undefined/0
|
|
160
161
|
if (!el.classList.contains('grid-stack')) {
|
|
@@ -231,6 +232,7 @@ class GridStack {
|
|
|
231
232
|
this._initMargin(); // part of settings defaults...
|
|
232
233
|
// 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)
|
|
233
234
|
this.checkDynamicColumn();
|
|
235
|
+
this.el.classList.add('gs-' + this.opts.column);
|
|
234
236
|
if (this.opts.rtl === 'auto') {
|
|
235
237
|
this.opts.rtl = (el.style.direction === 'rtl');
|
|
236
238
|
}
|
|
@@ -290,6 +292,8 @@ class GridStack {
|
|
|
290
292
|
this._updateStyles(false, maxH); // false = don't recreate, just append if need be
|
|
291
293
|
}
|
|
292
294
|
});
|
|
295
|
+
// create initial global styles BEFORE loading children so resizeToContent margin can be calculated correctly
|
|
296
|
+
this._updateStyles(false, 0);
|
|
293
297
|
if (this.opts.auto) {
|
|
294
298
|
this.batchUpdate(); // prevent in between re-layout #1535 TODO: this only set float=true, need to prevent collision check...
|
|
295
299
|
this.getGridItems().forEach(el => this._prepareElement(el));
|
|
@@ -302,9 +306,8 @@ class GridStack {
|
|
|
302
306
|
if (children.length)
|
|
303
307
|
this.load(children); // don't load empty
|
|
304
308
|
}
|
|
309
|
+
// if (this.engine.nodes.length) this._updateStyles(); // update based on # of children. done in engine onChange CB
|
|
305
310
|
this.setAnimation(this.opts.animate);
|
|
306
|
-
this._updateStyles();
|
|
307
|
-
this.el.classList.add('gs-' + this.opts.column);
|
|
308
311
|
// dynamic grids require pausing during drag to detect over to nest vs push
|
|
309
312
|
if (this.opts.subGridDynamic && !DDManager.pauseDrag)
|
|
310
313
|
DDManager.pauseDrag = true;
|
|
@@ -592,6 +595,10 @@ class GridStack {
|
|
|
592
595
|
GridStack.addRemoveCB = addRemove;
|
|
593
596
|
let removed = [];
|
|
594
597
|
this.batchUpdate();
|
|
598
|
+
// if we are blank (loading into empty like startup) temp remove animation
|
|
599
|
+
const noAnim = !this.engine.nodes.length;
|
|
600
|
+
if (noAnim)
|
|
601
|
+
this.setAnimation(false);
|
|
595
602
|
// see if any items are missing from new layout and need to be removed first
|
|
596
603
|
if (addRemove) {
|
|
597
604
|
let copyNodes = [...this.engine.nodes]; // don't loop through array you modify
|
|
@@ -617,21 +624,19 @@ class GridStack {
|
|
|
617
624
|
} // remove if found from list
|
|
618
625
|
return true;
|
|
619
626
|
});
|
|
620
|
-
let widthChanged = false;
|
|
621
627
|
items.forEach(w => {
|
|
622
628
|
let item = Utils.find(updateNodes, w.id);
|
|
623
629
|
if (item) {
|
|
624
|
-
// if item sizes to content, re-use the exiting height so it's a better guess at the final size
|
|
630
|
+
// if item sizes to content, re-use the exiting height so it's a better guess at the final size (same if width doesn't change)
|
|
625
631
|
if (Utils.shouldSizeToContent(item))
|
|
626
632
|
w.h = item.h;
|
|
627
633
|
// check if missing coord, in which case find next empty slot with new (or old if missing) sizes
|
|
628
|
-
this.engine.nodeBoundFix(w);
|
|
634
|
+
this.engine.nodeBoundFix(w);
|
|
629
635
|
if (w.autoPosition || w.x === undefined || w.y === undefined) {
|
|
630
636
|
w.w = w.w || item.w;
|
|
631
637
|
w.h = w.h || item.h;
|
|
632
638
|
this.engine.findEmptyPosition(w);
|
|
633
639
|
}
|
|
634
|
-
widthChanged = widthChanged || (w.w !== undefined && w.w !== item.w);
|
|
635
640
|
// add back to current list BUT force a collision check if it 'appears' we didn't change to make sure we don't overlap others now
|
|
636
641
|
this.engine.nodes.push(item);
|
|
637
642
|
if (Utils.samePos(item, w)) {
|
|
@@ -651,12 +656,14 @@ class GridStack {
|
|
|
651
656
|
}
|
|
652
657
|
});
|
|
653
658
|
this.engine.removedNodes = removed;
|
|
654
|
-
this.doContentResize(widthChanged, true); // we only need to wait for animation if we changed any widths
|
|
655
659
|
this.batchUpdate(false);
|
|
656
660
|
// after commit, clear that flag
|
|
657
661
|
delete this._ignoreLayoutsNodeChange;
|
|
658
662
|
delete this._insertNotAppend;
|
|
659
663
|
prevCB ? GridStack.addRemoveCB = prevCB : delete GridStack.addRemoveCB;
|
|
664
|
+
// delay adding animation back
|
|
665
|
+
if (noAnim && this.opts.animate)
|
|
666
|
+
setTimeout(() => this.setAnimation(this.opts.animate));
|
|
660
667
|
return this;
|
|
661
668
|
}
|
|
662
669
|
/**
|
|
@@ -681,11 +688,18 @@ class GridStack {
|
|
|
681
688
|
(!forcePixel || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === 'px')) {
|
|
682
689
|
return this.opts.cellHeight;
|
|
683
690
|
}
|
|
691
|
+
// do rem/em to px conversion
|
|
692
|
+
if (this.opts.cellHeightUnit === 'rem') {
|
|
693
|
+
return this.opts.cellHeight * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
694
|
+
}
|
|
695
|
+
if (this.opts.cellHeightUnit === 'em') {
|
|
696
|
+
return this.opts.cellHeight * parseFloat(getComputedStyle(this.el).fontSize);
|
|
697
|
+
}
|
|
684
698
|
// else get first cell height
|
|
685
699
|
let el = this.el.querySelector('.' + this.opts.itemClass);
|
|
686
700
|
if (el) {
|
|
687
|
-
let
|
|
688
|
-
return Math.round(el.offsetHeight /
|
|
701
|
+
let h = Utils.toNumber(el.getAttribute('gs-h')) || 1; // since we don't write 1 anymore
|
|
702
|
+
return Math.round(el.offsetHeight / h);
|
|
689
703
|
}
|
|
690
704
|
// else do entire grid and # of rows (but doesn't work if min-height is the actual constrain)
|
|
691
705
|
let rows = parseInt(this.el.getAttribute('gs-current-row'));
|
|
@@ -728,7 +742,7 @@ class GridStack {
|
|
|
728
742
|
}
|
|
729
743
|
this.opts.cellHeightUnit = data.unit;
|
|
730
744
|
this.opts.cellHeight = data.h;
|
|
731
|
-
this.
|
|
745
|
+
this.resizeToContentCheck();
|
|
732
746
|
if (update) {
|
|
733
747
|
this._updateStyles(true); // true = force re-create for current # of rows
|
|
734
748
|
}
|
|
@@ -807,7 +821,7 @@ class GridStack {
|
|
|
807
821
|
else*/ this.engine.columnChanged(oldColumn, column, undefined, layout);
|
|
808
822
|
if (this._isAutoCellHeight)
|
|
809
823
|
this.cellHeight();
|
|
810
|
-
this.
|
|
824
|
+
this.resizeToContentCheck(true); // wait for width resizing
|
|
811
825
|
// and trigger our event last...
|
|
812
826
|
this._ignoreLayoutsNodeChange = true; // skip layout update
|
|
813
827
|
this._triggerChangeEvent();
|
|
@@ -929,7 +943,6 @@ class GridStack {
|
|
|
929
943
|
this._prepareElement(el, true, options);
|
|
930
944
|
const node = el.gridstackNode;
|
|
931
945
|
this._updateContainerHeight();
|
|
932
|
-
this.doContentResize(false, false, node);
|
|
933
946
|
// see if there is a sub-grid to create
|
|
934
947
|
if (node.subGridOpts) {
|
|
935
948
|
this.makeSubGrid(el, node.subGridOpts, undefined, false); // node.subGrid will be used as option in method, no need to pass
|
|
@@ -1075,6 +1088,8 @@ class GridStack {
|
|
|
1075
1088
|
}
|
|
1076
1089
|
return this;
|
|
1077
1090
|
}
|
|
1091
|
+
/** @internal */
|
|
1092
|
+
hasAnimationCSS() { return this.el.classList.contains('grid-stack-animate'); }
|
|
1078
1093
|
/**
|
|
1079
1094
|
* Toggle the grid static state, which permanently removes/add Drag&Drop support, unlike disable()/enable() that just turns it off/on.
|
|
1080
1095
|
* Also toggle the grid-stack-static class.
|
|
@@ -1160,8 +1175,11 @@ class GridStack {
|
|
|
1160
1175
|
}
|
|
1161
1176
|
Utils.sanitizeMinMax(n);
|
|
1162
1177
|
// finally move the widget and update attr
|
|
1163
|
-
if (m)
|
|
1178
|
+
if (m) {
|
|
1179
|
+
const widthChanged = (m.w !== undefined && m.w !== n.w);
|
|
1164
1180
|
this.moveNode(n, m);
|
|
1181
|
+
this.resizeToContentCheck(widthChanged, n); // wait for animation if we changed width
|
|
1182
|
+
}
|
|
1165
1183
|
if (m || changed) {
|
|
1166
1184
|
this._writeAttr(el, n);
|
|
1167
1185
|
}
|
|
@@ -1182,26 +1200,25 @@ class GridStack {
|
|
|
1182
1200
|
/**
|
|
1183
1201
|
* Updates widget height to match the content height to avoid v-scrollbar or dead space.
|
|
1184
1202
|
* Note: this assumes only 1 child under resizeToContentParent='.grid-stack-item-content' (sized to gridItem minus padding) that is at the entire content size wanted.
|
|
1185
|
-
*
|
|
1203
|
+
* @param el grid item element
|
|
1204
|
+
* @param useNodeH set to true if GridStackNode.h should be used instead of actual container height when we don't need to wait for animation to finish to get actual DOM heights
|
|
1186
1205
|
*/
|
|
1187
|
-
resizeToContent(el
|
|
1206
|
+
resizeToContent(el) {
|
|
1188
1207
|
if (!el)
|
|
1189
1208
|
return;
|
|
1190
1209
|
el.classList.remove('size-to-content-max');
|
|
1191
1210
|
if (!el.clientHeight)
|
|
1192
1211
|
return; // 0 when hidden, skip
|
|
1193
|
-
|
|
1212
|
+
const n = el.gridstackNode;
|
|
1194
1213
|
if (!n)
|
|
1195
1214
|
return;
|
|
1196
1215
|
const grid = n.grid;
|
|
1197
|
-
if (!grid)
|
|
1198
|
-
return;
|
|
1199
|
-
if (el.parentElement !== grid.el)
|
|
1216
|
+
if (!grid || el.parentElement !== grid.el)
|
|
1200
1217
|
return; // skip if we are not inside a grid
|
|
1201
|
-
const cell = grid.getCellHeight();
|
|
1218
|
+
const cell = grid.getCellHeight(true);
|
|
1202
1219
|
if (!cell)
|
|
1203
1220
|
return;
|
|
1204
|
-
let height =
|
|
1221
|
+
let height = n.h ? n.h * cell : el.clientHeight; // getBoundingClientRect().height seem to flicker back and forth
|
|
1205
1222
|
let item;
|
|
1206
1223
|
if (n.resizeToContentParent)
|
|
1207
1224
|
item = el.querySelector(n.resizeToContentParent);
|
|
@@ -1210,11 +1227,11 @@ class GridStack {
|
|
|
1210
1227
|
if (!item)
|
|
1211
1228
|
return;
|
|
1212
1229
|
const padding = el.clientHeight - item.clientHeight; // full - available height to our child (minus border, padding...)
|
|
1213
|
-
const itemH =
|
|
1230
|
+
const itemH = n.h ? n.h * cell - padding : item.clientHeight; // calculated to what cellHeight is or will become (rather than actual to prevent waiting for animation to finish)
|
|
1214
1231
|
let wantedH;
|
|
1215
1232
|
if (n.subGrid) {
|
|
1216
1233
|
// sub-grid - use their actual row count * their cell height
|
|
1217
|
-
wantedH = n.subGrid.getRow() * n.subGrid.getCellHeight();
|
|
1234
|
+
wantedH = n.subGrid.getRow() * n.subGrid.getCellHeight(true);
|
|
1218
1235
|
}
|
|
1219
1236
|
else {
|
|
1220
1237
|
// NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
|
|
@@ -1246,11 +1263,11 @@ class GridStack {
|
|
|
1246
1263
|
}
|
|
1247
1264
|
}
|
|
1248
1265
|
/** call the user resize (so they can do extra work) else our build in version */
|
|
1249
|
-
|
|
1266
|
+
resizeToContentCBCheck(el) {
|
|
1250
1267
|
if (GridStack.resizeToContentCB)
|
|
1251
|
-
GridStack.resizeToContentCB(el
|
|
1268
|
+
GridStack.resizeToContentCB(el);
|
|
1252
1269
|
else
|
|
1253
|
-
this.resizeToContent(el
|
|
1270
|
+
this.resizeToContent(el);
|
|
1254
1271
|
}
|
|
1255
1272
|
/**
|
|
1256
1273
|
* Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options (CSS string format of 1,2,4 values or single number).
|
|
@@ -1343,7 +1360,8 @@ class GridStack {
|
|
|
1343
1360
|
/** @internal called to delete the current dynamic style sheet used for our layout */
|
|
1344
1361
|
_removeStylesheet() {
|
|
1345
1362
|
if (this._styles) {
|
|
1346
|
-
|
|
1363
|
+
const styleLocation = this.opts.styleInHead ? undefined : this.el.parentNode;
|
|
1364
|
+
Utils.removeStylesheet(this._styleSheetClass, styleLocation);
|
|
1347
1365
|
delete this._styles;
|
|
1348
1366
|
}
|
|
1349
1367
|
return this;
|
|
@@ -1354,7 +1372,7 @@ class GridStack {
|
|
|
1354
1372
|
if (forceUpdate) {
|
|
1355
1373
|
this._removeStylesheet();
|
|
1356
1374
|
}
|
|
1357
|
-
if (
|
|
1375
|
+
if (maxH === undefined)
|
|
1358
1376
|
maxH = this.getRow();
|
|
1359
1377
|
this._updateContainerHeight();
|
|
1360
1378
|
// if user is telling us they will handle the CSS themselves by setting heights to 0. Do we need this opts really ??
|
|
@@ -1367,7 +1385,7 @@ class GridStack {
|
|
|
1367
1385
|
// create one as needed
|
|
1368
1386
|
if (!this._styles) {
|
|
1369
1387
|
// insert style to parent (instead of 'head' by default) to support WebComponent
|
|
1370
|
-
|
|
1388
|
+
const styleLocation = this.opts.styleInHead ? undefined : this.el.parentNode;
|
|
1371
1389
|
this._styles = Utils.createStylesheet(this._styleSheetClass, styleLocation, {
|
|
1372
1390
|
nonce: this.opts.nonce,
|
|
1373
1391
|
});
|
|
@@ -1434,25 +1452,24 @@ class GridStack {
|
|
|
1434
1452
|
}
|
|
1435
1453
|
// if we're a nested grid inside an sizeToContent item, tell it to resize itself too
|
|
1436
1454
|
if (parent && !parent.grid.engine.batchMode && Utils.shouldSizeToContent(parent)) {
|
|
1437
|
-
parent.grid.
|
|
1455
|
+
parent.grid.resizeToContentCBCheck(parent.el);
|
|
1438
1456
|
}
|
|
1439
1457
|
return this;
|
|
1440
1458
|
}
|
|
1441
1459
|
/** @internal */
|
|
1442
1460
|
_prepareElement(el, triggerAddEvent = false, node) {
|
|
1443
|
-
el.classList.add(this.opts.itemClass);
|
|
1444
1461
|
node = node || this._readAttr(el);
|
|
1445
1462
|
el.gridstackNode = node;
|
|
1446
1463
|
node.el = el;
|
|
1447
1464
|
node.grid = this;
|
|
1448
|
-
let copy = { ...node };
|
|
1449
1465
|
node = this.engine.addNode(node, triggerAddEvent);
|
|
1450
|
-
// write
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1466
|
+
// write the dom sizes and class
|
|
1467
|
+
this._writeAttr(el, node);
|
|
1468
|
+
el.classList.add(gridDefaults.itemClass, this.opts.itemClass);
|
|
1469
|
+
const sizeToContent = Utils.shouldSizeToContent(node);
|
|
1470
|
+
sizeToContent ? el.classList.add('size-to-content') : el.classList.remove('size-to-content');
|
|
1471
|
+
if (sizeToContent)
|
|
1472
|
+
this.resizeToContentCheck(false, node);
|
|
1456
1473
|
this._prepareDragDropByNode(node);
|
|
1457
1474
|
return this;
|
|
1458
1475
|
}
|
|
@@ -1579,34 +1596,35 @@ class GridStack {
|
|
|
1579
1596
|
n.subGrid.onResize();
|
|
1580
1597
|
});
|
|
1581
1598
|
if (!this._skipInitialResize)
|
|
1582
|
-
this.
|
|
1599
|
+
this.resizeToContentCheck(columnChanged); // wait for anim of column changed (DOM reflow before we can size correctly)
|
|
1583
1600
|
delete this._skipInitialResize;
|
|
1584
1601
|
this.batchUpdate(false);
|
|
1585
1602
|
return this;
|
|
1586
1603
|
}
|
|
1587
|
-
|
|
1604
|
+
/** resizes content for given node (or all) if shouldSizeToContent() is true */
|
|
1605
|
+
resizeToContentCheck(delay = false, n = undefined) {
|
|
1606
|
+
if (!this.engine)
|
|
1607
|
+
return; // we've been deleted in between!
|
|
1588
1608
|
// update any gridItem height with sizeToContent, but wait for DOM $animation_speed to settle if we changed column count
|
|
1589
1609
|
// TODO: is there a way to know what the final (post animation) size of the content will be so we can animate the column width and height together rather than sequentially ?
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
if (n)
|
|
1610
|
+
if (delay && this.hasAnimationCSS())
|
|
1611
|
+
return setTimeout(() => this.resizeToContentCheck(false, n), 300 + 10);
|
|
1612
|
+
if (n) {
|
|
1613
|
+
if (Utils.shouldSizeToContent(n))
|
|
1614
|
+
this.resizeToContentCBCheck(n.el);
|
|
1615
|
+
}
|
|
1616
|
+
else if (this.engine.nodes.some(n => Utils.shouldSizeToContent(n))) {
|
|
1617
|
+
const nodes = [...this.engine.nodes]; // in case order changes while resizing one
|
|
1618
|
+
this.batchUpdate();
|
|
1619
|
+
nodes.forEach(n => {
|
|
1594
1620
|
if (Utils.shouldSizeToContent(n))
|
|
1595
|
-
this.
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
this.resizeToContentCheck(n.el, useAttr);
|
|
1603
|
-
});
|
|
1604
|
-
this.batchUpdate(false);
|
|
1605
|
-
}
|
|
1606
|
-
// call this regardless of shouldSizeToContent because widget might need to stretch to take available space after a resize
|
|
1607
|
-
if (this._gsEventHandler['resizecontent'])
|
|
1608
|
-
this._gsEventHandler['resizecontent'](null, n ? [n] : this.engine.nodes);
|
|
1609
|
-
}, delay ? 300 + 10 : 0);
|
|
1621
|
+
this.resizeToContentCBCheck(n.el);
|
|
1622
|
+
});
|
|
1623
|
+
this.batchUpdate(false);
|
|
1624
|
+
}
|
|
1625
|
+
// call this regardless of shouldSizeToContent because widget might need to stretch to take available space after a resize
|
|
1626
|
+
if (this._gsEventHandler['resizecontent'])
|
|
1627
|
+
this._gsEventHandler['resizecontent'](null, n ? [n] : this.engine.nodes);
|
|
1610
1628
|
}
|
|
1611
1629
|
/** add or remove the grid element size event handler */
|
|
1612
1630
|
_updateResizeEvent(forceRemove = false) {
|
|
@@ -1737,7 +1755,7 @@ class GridStack {
|
|
|
1737
1755
|
if (this.opts.staticGrid)
|
|
1738
1756
|
return this; // can't move a static grid!
|
|
1739
1757
|
GridStack.getElements(els).forEach(el => {
|
|
1740
|
-
|
|
1758
|
+
const n = el.gridstackNode;
|
|
1741
1759
|
if (!n)
|
|
1742
1760
|
return;
|
|
1743
1761
|
val ? delete n.noMove : n.noMove = true;
|
|
@@ -1993,8 +2011,12 @@ class GridStack {
|
|
|
1993
2011
|
// ignore drop on ourself from ourself that didn't come from the outside - dragend will handle the simple move instead
|
|
1994
2012
|
if (node?.grid === this && !node._isExternal)
|
|
1995
2013
|
return false;
|
|
1996
|
-
|
|
2014
|
+
const wasAdded = !!this.placeholder.parentElement; // skip items not actually added to us because of constrains, but do cleanup #1419
|
|
1997
2015
|
this.placeholder.remove();
|
|
2016
|
+
// disable animation when replacing a placeholder (already positioned) with actual content
|
|
2017
|
+
const noAnim = wasAdded && this.opts.animate;
|
|
2018
|
+
if (noAnim)
|
|
2019
|
+
this.setAnimation(false);
|
|
1998
2020
|
// notify previous grid of removal
|
|
1999
2021
|
// console.log('drop delete _gridstackNodeOrig') // TEST
|
|
2000
2022
|
let origNode = el._gridstackNodeOrig;
|
|
@@ -2039,15 +2061,13 @@ class GridStack {
|
|
|
2039
2061
|
// @ts-ignore
|
|
2040
2062
|
Utils.copyPos(node, this._readAttr(this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578
|
|
2041
2063
|
Utils.removePositioningStyles(el); // @ts-ignore
|
|
2042
|
-
this._writeAttr(el, node);
|
|
2043
|
-
el.classList.add(gridDefaults.itemClass, this.opts.itemClass);
|
|
2044
2064
|
this.el.appendChild(el); // @ts-ignore // TODO: now would be ideal time to _removeHelperStyle() overriding floating styles (native only)
|
|
2065
|
+
this._prepareElement(el, true, node);
|
|
2045
2066
|
if (subGrid) {
|
|
2046
2067
|
subGrid.parentGridItem = node;
|
|
2047
2068
|
if (!subGrid.opts.styleInHead)
|
|
2048
2069
|
subGrid._updateStyles(true); // re-create sub-grid styles now that we've moved
|
|
2049
2070
|
}
|
|
2050
|
-
this._prepareDragDropByNode(node);
|
|
2051
2071
|
this._updateContainerHeight();
|
|
2052
2072
|
this.engine.addedNodes.push(node); // @ts-ignore
|
|
2053
2073
|
this._triggerAddEvent(); // @ts-ignore
|
|
@@ -2056,6 +2076,9 @@ class GridStack {
|
|
|
2056
2076
|
if (this._gsEventHandler['dropped']) {
|
|
2057
2077
|
this._gsEventHandler['dropped']({ ...event, type: 'dropped' }, origNode && origNode.grid ? origNode : undefined, node);
|
|
2058
2078
|
}
|
|
2079
|
+
// delay adding animation back
|
|
2080
|
+
if (noAnim)
|
|
2081
|
+
setTimeout(() => this.setAnimation(this.opts.animate));
|
|
2059
2082
|
return false; // prevent parent from receiving msg (which may be grid as well)
|
|
2060
2083
|
});
|
|
2061
2084
|
return this;
|
|
@@ -2123,6 +2146,7 @@ class GridStack {
|
|
|
2123
2146
|
delete node._moving;
|
|
2124
2147
|
delete node._event;
|
|
2125
2148
|
delete node._lastTried;
|
|
2149
|
+
const widthChanged = node.w !== node._orig.w;
|
|
2126
2150
|
// if the item has moved to another grid, we're done here
|
|
2127
2151
|
let target = event.target;
|
|
2128
2152
|
if (!target.gridstackNode || target.gridstackNode.grid !== this)
|
|
@@ -2160,7 +2184,7 @@ class GridStack {
|
|
|
2160
2184
|
if (event.type === 'resizestop') {
|
|
2161
2185
|
if (Number.isInteger(node.sizeToContent))
|
|
2162
2186
|
node.sizeToContent = node.h; // new soft limit
|
|
2163
|
-
this.
|
|
2187
|
+
this.resizeToContentCheck(widthChanged, node); // wait for width animation if changed
|
|
2164
2188
|
}
|
|
2165
2189
|
};
|
|
2166
2190
|
dd.draggable(el, {
|
|
@@ -2337,6 +2361,6 @@ GridStack.resizeToContentParent = '.grid-stack-item-content';
|
|
|
2337
2361
|
GridStack.Utils = Utils;
|
|
2338
2362
|
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
2339
2363
|
GridStack.Engine = GridStackEngine;
|
|
2340
|
-
GridStack.GDRev = '10.0.
|
|
2364
|
+
GridStack.GDRev = '10.0.1';
|
|
2341
2365
|
export { GridStack };
|
|
2342
2366
|
//# sourceMappingURL=gridstack.js.map
|