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/es5/gridstack.js
CHANGED
|
@@ -36,7 +36,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.GridStack = void 0;
|
|
38
38
|
/*!
|
|
39
|
-
* GridStack 10.0.
|
|
39
|
+
* GridStack 10.0.1
|
|
40
40
|
* https://gridstackjs.com/
|
|
41
41
|
*
|
|
42
42
|
* Copyright (c) 2021-2022 Alain Dumesny
|
|
@@ -84,6 +84,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
84
84
|
this._gsEventHandler = {};
|
|
85
85
|
/** @internal extra row added when dragging at the bottom of the grid */
|
|
86
86
|
this._extraDragRow = 0;
|
|
87
|
+
el.gridstack = this;
|
|
87
88
|
this.el = el; // exposed HTML element to the user
|
|
88
89
|
opts = opts || {}; // handles null/undefined/0
|
|
89
90
|
if (!el.classList.contains('grid-stack')) {
|
|
@@ -153,6 +154,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
153
154
|
this._initMargin(); // part of settings defaults...
|
|
154
155
|
// 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)
|
|
155
156
|
this.checkDynamicColumn();
|
|
157
|
+
this.el.classList.add('gs-' + this.opts.column);
|
|
156
158
|
if (this.opts.rtl === 'auto') {
|
|
157
159
|
this.opts.rtl = (el.style.direction === 'rtl');
|
|
158
160
|
}
|
|
@@ -212,6 +214,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
212
214
|
_this._updateStyles(false, maxH); // false = don't recreate, just append if need be
|
|
213
215
|
}
|
|
214
216
|
});
|
|
217
|
+
// create initial global styles BEFORE loading children so resizeToContent margin can be calculated correctly
|
|
218
|
+
this._updateStyles(false, 0);
|
|
215
219
|
if (this.opts.auto) {
|
|
216
220
|
this.batchUpdate(); // prevent in between re-layout #1535 TODO: this only set float=true, need to prevent collision check...
|
|
217
221
|
this.getGridItems().forEach(function (el) { return _this._prepareElement(el); });
|
|
@@ -224,9 +228,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
224
228
|
if (children.length)
|
|
225
229
|
this.load(children); // don't load empty
|
|
226
230
|
}
|
|
231
|
+
// if (this.engine.nodes.length) this._updateStyles(); // update based on # of children. done in engine onChange CB
|
|
227
232
|
this.setAnimation(this.opts.animate);
|
|
228
|
-
this._updateStyles();
|
|
229
|
-
this.el.classList.add('gs-' + this.opts.column);
|
|
230
233
|
// dynamic grids require pausing during drag to detect over to nest vs push
|
|
231
234
|
if (this.opts.subGridDynamic && !dd_manager_1.DDManager.pauseDrag)
|
|
232
235
|
dd_manager_1.DDManager.pauseDrag = true;
|
|
@@ -644,6 +647,10 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
644
647
|
GridStack.addRemoveCB = addRemove;
|
|
645
648
|
var removed = [];
|
|
646
649
|
this.batchUpdate();
|
|
650
|
+
// if we are blank (loading into empty like startup) temp remove animation
|
|
651
|
+
var noAnim = !this.engine.nodes.length;
|
|
652
|
+
if (noAnim)
|
|
653
|
+
this.setAnimation(false);
|
|
647
654
|
// see if any items are missing from new layout and need to be removed first
|
|
648
655
|
if (addRemove) {
|
|
649
656
|
var copyNodes = __spreadArray([], this.engine.nodes, true); // don't loop through array you modify
|
|
@@ -669,22 +676,20 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
669
676
|
} // remove if found from list
|
|
670
677
|
return true;
|
|
671
678
|
});
|
|
672
|
-
var widthChanged = false;
|
|
673
679
|
items.forEach(function (w) {
|
|
674
680
|
var _a;
|
|
675
681
|
var item = utils_1.Utils.find(updateNodes, w.id);
|
|
676
682
|
if (item) {
|
|
677
|
-
// if item sizes to content, re-use the exiting height so it's a better guess at the final size
|
|
683
|
+
// 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)
|
|
678
684
|
if (utils_1.Utils.shouldSizeToContent(item))
|
|
679
685
|
w.h = item.h;
|
|
680
686
|
// check if missing coord, in which case find next empty slot with new (or old if missing) sizes
|
|
681
|
-
_this.engine.nodeBoundFix(w);
|
|
687
|
+
_this.engine.nodeBoundFix(w);
|
|
682
688
|
if (w.autoPosition || w.x === undefined || w.y === undefined) {
|
|
683
689
|
w.w = w.w || item.w;
|
|
684
690
|
w.h = w.h || item.h;
|
|
685
691
|
_this.engine.findEmptyPosition(w);
|
|
686
692
|
}
|
|
687
|
-
widthChanged = widthChanged || (w.w !== undefined && w.w !== item.w);
|
|
688
693
|
// 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
|
|
689
694
|
_this.engine.nodes.push(item);
|
|
690
695
|
if (utils_1.Utils.samePos(item, w)) {
|
|
@@ -704,12 +709,14 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
704
709
|
}
|
|
705
710
|
});
|
|
706
711
|
this.engine.removedNodes = removed;
|
|
707
|
-
this.doContentResize(widthChanged, true); // we only need to wait for animation if we changed any widths
|
|
708
712
|
this.batchUpdate(false);
|
|
709
713
|
// after commit, clear that flag
|
|
710
714
|
delete this._ignoreLayoutsNodeChange;
|
|
711
715
|
delete this._insertNotAppend;
|
|
712
716
|
prevCB ? GridStack.addRemoveCB = prevCB : delete GridStack.addRemoveCB;
|
|
717
|
+
// delay adding animation back
|
|
718
|
+
if (noAnim && this.opts.animate)
|
|
719
|
+
setTimeout(function () { return _this.setAnimation(_this.opts.animate); });
|
|
713
720
|
return this;
|
|
714
721
|
};
|
|
715
722
|
/**
|
|
@@ -736,11 +743,18 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
736
743
|
(!forcePixel || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === 'px')) {
|
|
737
744
|
return this.opts.cellHeight;
|
|
738
745
|
}
|
|
746
|
+
// do rem/em to px conversion
|
|
747
|
+
if (this.opts.cellHeightUnit === 'rem') {
|
|
748
|
+
return this.opts.cellHeight * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
749
|
+
}
|
|
750
|
+
if (this.opts.cellHeightUnit === 'em') {
|
|
751
|
+
return this.opts.cellHeight * parseFloat(getComputedStyle(this.el).fontSize);
|
|
752
|
+
}
|
|
739
753
|
// else get first cell height
|
|
740
754
|
var el = this.el.querySelector('.' + this.opts.itemClass);
|
|
741
755
|
if (el) {
|
|
742
|
-
var
|
|
743
|
-
return Math.round(el.offsetHeight /
|
|
756
|
+
var h = utils_1.Utils.toNumber(el.getAttribute('gs-h')) || 1; // since we don't write 1 anymore
|
|
757
|
+
return Math.round(el.offsetHeight / h);
|
|
744
758
|
}
|
|
745
759
|
// else do entire grid and # of rows (but doesn't work if min-height is the actual constrain)
|
|
746
760
|
var rows = parseInt(this.el.getAttribute('gs-current-row'));
|
|
@@ -784,7 +798,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
784
798
|
}
|
|
785
799
|
this.opts.cellHeightUnit = data.unit;
|
|
786
800
|
this.opts.cellHeight = data.h;
|
|
787
|
-
this.
|
|
801
|
+
this.resizeToContentCheck();
|
|
788
802
|
if (update) {
|
|
789
803
|
this._updateStyles(true); // true = force re-create for current # of rows
|
|
790
804
|
}
|
|
@@ -869,7 +883,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
869
883
|
else*/ this.engine.columnChanged(oldColumn, column, undefined, layout);
|
|
870
884
|
if (this._isAutoCellHeight)
|
|
871
885
|
this.cellHeight();
|
|
872
|
-
this.
|
|
886
|
+
this.resizeToContentCheck(true); // wait for width resizing
|
|
873
887
|
// and trigger our event last...
|
|
874
888
|
this._ignoreLayoutsNodeChange = true; // skip layout update
|
|
875
889
|
this._triggerChangeEvent();
|
|
@@ -994,7 +1008,6 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
994
1008
|
this._prepareElement(el, true, options);
|
|
995
1009
|
var node = el.gridstackNode;
|
|
996
1010
|
this._updateContainerHeight();
|
|
997
|
-
this.doContentResize(false, false, node);
|
|
998
1011
|
// see if there is a sub-grid to create
|
|
999
1012
|
if (node.subGridOpts) {
|
|
1000
1013
|
this.makeSubGrid(el, node.subGridOpts, undefined, false); // node.subGrid will be used as option in method, no need to pass
|
|
@@ -1148,6 +1161,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1148
1161
|
}
|
|
1149
1162
|
return this;
|
|
1150
1163
|
};
|
|
1164
|
+
/** @internal */
|
|
1165
|
+
GridStack.prototype.hasAnimationCSS = function () { return this.el.classList.contains('grid-stack-animate'); };
|
|
1151
1166
|
/**
|
|
1152
1167
|
* Toggle the grid static state, which permanently removes/add Drag&Drop support, unlike disable()/enable() that just turns it off/on.
|
|
1153
1168
|
* Also toggle the grid-stack-static class.
|
|
@@ -1238,8 +1253,11 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1238
1253
|
}
|
|
1239
1254
|
utils_1.Utils.sanitizeMinMax(n);
|
|
1240
1255
|
// finally move the widget and update attr
|
|
1241
|
-
if (m)
|
|
1256
|
+
if (m) {
|
|
1257
|
+
var widthChanged = (m.w !== undefined && m.w !== n.w);
|
|
1242
1258
|
_this.moveNode(n, m);
|
|
1259
|
+
_this.resizeToContentCheck(widthChanged, n); // wait for animation if we changed width
|
|
1260
|
+
}
|
|
1243
1261
|
if (m || changed) {
|
|
1244
1262
|
_this._writeAttr(el, n);
|
|
1245
1263
|
}
|
|
@@ -1260,10 +1278,10 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1260
1278
|
/**
|
|
1261
1279
|
* Updates widget height to match the content height to avoid v-scrollbar or dead space.
|
|
1262
1280
|
* 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.
|
|
1263
|
-
*
|
|
1281
|
+
* @param el grid item element
|
|
1282
|
+
* @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
|
|
1264
1283
|
*/
|
|
1265
|
-
GridStack.prototype.resizeToContent = function (el
|
|
1266
|
-
if (useAttrSize === void 0) { useAttrSize = false; }
|
|
1284
|
+
GridStack.prototype.resizeToContent = function (el) {
|
|
1267
1285
|
if (!el)
|
|
1268
1286
|
return;
|
|
1269
1287
|
el.classList.remove('size-to-content-max');
|
|
@@ -1273,14 +1291,12 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1273
1291
|
if (!n)
|
|
1274
1292
|
return;
|
|
1275
1293
|
var grid = n.grid;
|
|
1276
|
-
if (!grid)
|
|
1277
|
-
return;
|
|
1278
|
-
if (el.parentElement !== grid.el)
|
|
1294
|
+
if (!grid || el.parentElement !== grid.el)
|
|
1279
1295
|
return; // skip if we are not inside a grid
|
|
1280
|
-
var cell = grid.getCellHeight();
|
|
1296
|
+
var cell = grid.getCellHeight(true);
|
|
1281
1297
|
if (!cell)
|
|
1282
1298
|
return;
|
|
1283
|
-
var height =
|
|
1299
|
+
var height = n.h ? n.h * cell : el.clientHeight; // getBoundingClientRect().height seem to flicker back and forth
|
|
1284
1300
|
var item;
|
|
1285
1301
|
if (n.resizeToContentParent)
|
|
1286
1302
|
item = el.querySelector(n.resizeToContentParent);
|
|
@@ -1289,11 +1305,11 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1289
1305
|
if (!item)
|
|
1290
1306
|
return;
|
|
1291
1307
|
var padding = el.clientHeight - item.clientHeight; // full - available height to our child (minus border, padding...)
|
|
1292
|
-
var itemH =
|
|
1308
|
+
var 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)
|
|
1293
1309
|
var wantedH;
|
|
1294
1310
|
if (n.subGrid) {
|
|
1295
1311
|
// sub-grid - use their actual row count * their cell height
|
|
1296
|
-
wantedH = n.subGrid.getRow() * n.subGrid.getCellHeight();
|
|
1312
|
+
wantedH = n.subGrid.getRow() * n.subGrid.getCellHeight(true);
|
|
1297
1313
|
}
|
|
1298
1314
|
else {
|
|
1299
1315
|
// NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
|
|
@@ -1325,12 +1341,11 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1325
1341
|
}
|
|
1326
1342
|
};
|
|
1327
1343
|
/** call the user resize (so they can do extra work) else our build in version */
|
|
1328
|
-
GridStack.prototype.
|
|
1329
|
-
if (useAttr === void 0) { useAttr = false; }
|
|
1344
|
+
GridStack.prototype.resizeToContentCBCheck = function (el) {
|
|
1330
1345
|
if (GridStack.resizeToContentCB)
|
|
1331
|
-
GridStack.resizeToContentCB(el
|
|
1346
|
+
GridStack.resizeToContentCB(el);
|
|
1332
1347
|
else
|
|
1333
|
-
this.resizeToContent(el
|
|
1348
|
+
this.resizeToContent(el);
|
|
1334
1349
|
};
|
|
1335
1350
|
/**
|
|
1336
1351
|
* 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).
|
|
@@ -1425,7 +1440,8 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1425
1440
|
/** @internal called to delete the current dynamic style sheet used for our layout */
|
|
1426
1441
|
GridStack.prototype._removeStylesheet = function () {
|
|
1427
1442
|
if (this._styles) {
|
|
1428
|
-
|
|
1443
|
+
var styleLocation = this.opts.styleInHead ? undefined : this.el.parentNode;
|
|
1444
|
+
utils_1.Utils.removeStylesheet(this._styleSheetClass, styleLocation);
|
|
1429
1445
|
delete this._styles;
|
|
1430
1446
|
}
|
|
1431
1447
|
return this;
|
|
@@ -1437,7 +1453,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1437
1453
|
if (forceUpdate) {
|
|
1438
1454
|
this._removeStylesheet();
|
|
1439
1455
|
}
|
|
1440
|
-
if (
|
|
1456
|
+
if (maxH === undefined)
|
|
1441
1457
|
maxH = this.getRow();
|
|
1442
1458
|
this._updateContainerHeight();
|
|
1443
1459
|
// if user is telling us they will handle the CSS themselves by setting heights to 0. Do we need this opts really ??
|
|
@@ -1517,26 +1533,25 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1517
1533
|
}
|
|
1518
1534
|
// if we're a nested grid inside an sizeToContent item, tell it to resize itself too
|
|
1519
1535
|
if (parent && !parent.grid.engine.batchMode && utils_1.Utils.shouldSizeToContent(parent)) {
|
|
1520
|
-
parent.grid.
|
|
1536
|
+
parent.grid.resizeToContentCBCheck(parent.el);
|
|
1521
1537
|
}
|
|
1522
1538
|
return this;
|
|
1523
1539
|
};
|
|
1524
1540
|
/** @internal */
|
|
1525
1541
|
GridStack.prototype._prepareElement = function (el, triggerAddEvent, node) {
|
|
1526
1542
|
if (triggerAddEvent === void 0) { triggerAddEvent = false; }
|
|
1527
|
-
el.classList.add(this.opts.itemClass);
|
|
1528
1543
|
node = node || this._readAttr(el);
|
|
1529
1544
|
el.gridstackNode = node;
|
|
1530
1545
|
node.el = el;
|
|
1531
1546
|
node.grid = this;
|
|
1532
|
-
var copy = __assign({}, node);
|
|
1533
1547
|
node = this.engine.addNode(node, triggerAddEvent);
|
|
1534
|
-
// write
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1548
|
+
// write the dom sizes and class
|
|
1549
|
+
this._writeAttr(el, node);
|
|
1550
|
+
el.classList.add(types_1.gridDefaults.itemClass, this.opts.itemClass);
|
|
1551
|
+
var sizeToContent = utils_1.Utils.shouldSizeToContent(node);
|
|
1552
|
+
sizeToContent ? el.classList.add('size-to-content') : el.classList.remove('size-to-content');
|
|
1553
|
+
if (sizeToContent)
|
|
1554
|
+
this.resizeToContentCheck(false, node);
|
|
1540
1555
|
this._prepareDragDropByNode(node);
|
|
1541
1556
|
return this;
|
|
1542
1557
|
};
|
|
@@ -1666,38 +1681,38 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
1666
1681
|
n.subGrid.onResize();
|
|
1667
1682
|
});
|
|
1668
1683
|
if (!this._skipInitialResize)
|
|
1669
|
-
this.
|
|
1684
|
+
this.resizeToContentCheck(columnChanged); // wait for anim of column changed (DOM reflow before we can size correctly)
|
|
1670
1685
|
delete this._skipInitialResize;
|
|
1671
1686
|
this.batchUpdate(false);
|
|
1672
1687
|
return this;
|
|
1673
1688
|
};
|
|
1674
|
-
|
|
1689
|
+
/** resizes content for given node (or all) if shouldSizeToContent() is true */
|
|
1690
|
+
GridStack.prototype.resizeToContentCheck = function (delay, n) {
|
|
1675
1691
|
var _this = this;
|
|
1676
|
-
if (delay === void 0) { delay =
|
|
1677
|
-
if (useAttr === void 0) { useAttr = false; }
|
|
1692
|
+
if (delay === void 0) { delay = false; }
|
|
1678
1693
|
if (n === void 0) { n = undefined; }
|
|
1694
|
+
if (!this.engine)
|
|
1695
|
+
return; // we've been deleted in between!
|
|
1679
1696
|
// update any gridItem height with sizeToContent, but wait for DOM $animation_speed to settle if we changed column count
|
|
1680
1697
|
// 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 ?
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
if (n)
|
|
1698
|
+
if (delay && this.hasAnimationCSS())
|
|
1699
|
+
return setTimeout(function () { return _this.resizeToContentCheck(false, n); }, 300 + 10);
|
|
1700
|
+
if (n) {
|
|
1701
|
+
if (utils_1.Utils.shouldSizeToContent(n))
|
|
1702
|
+
this.resizeToContentCBCheck(n.el);
|
|
1703
|
+
}
|
|
1704
|
+
else if (this.engine.nodes.some(function (n) { return utils_1.Utils.shouldSizeToContent(n); })) {
|
|
1705
|
+
var nodes = __spreadArray([], this.engine.nodes, true); // in case order changes while resizing one
|
|
1706
|
+
this.batchUpdate();
|
|
1707
|
+
nodes.forEach(function (n) {
|
|
1685
1708
|
if (utils_1.Utils.shouldSizeToContent(n))
|
|
1686
|
-
_this.
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
_this.resizeToContentCheck(n.el, useAttr);
|
|
1694
|
-
});
|
|
1695
|
-
_this.batchUpdate(false);
|
|
1696
|
-
}
|
|
1697
|
-
// call this regardless of shouldSizeToContent because widget might need to stretch to take available space after a resize
|
|
1698
|
-
if (_this._gsEventHandler['resizecontent'])
|
|
1699
|
-
_this._gsEventHandler['resizecontent'](null, n ? [n] : _this.engine.nodes);
|
|
1700
|
-
}, delay ? 300 + 10 : 0);
|
|
1709
|
+
_this.resizeToContentCBCheck(n.el);
|
|
1710
|
+
});
|
|
1711
|
+
this.batchUpdate(false);
|
|
1712
|
+
}
|
|
1713
|
+
// call this regardless of shouldSizeToContent because widget might need to stretch to take available space after a resize
|
|
1714
|
+
if (this._gsEventHandler['resizecontent'])
|
|
1715
|
+
this._gsEventHandler['resizecontent'](null, n ? [n] : this.engine.nodes);
|
|
1701
1716
|
};
|
|
1702
1717
|
/** add or remove the grid element size event handler */
|
|
1703
1718
|
GridStack.prototype._updateResizeEvent = function (forceRemove) {
|
|
@@ -2106,6 +2121,10 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2106
2121
|
return false;
|
|
2107
2122
|
var wasAdded = !!_this.placeholder.parentElement; // skip items not actually added to us because of constrains, but do cleanup #1419
|
|
2108
2123
|
_this.placeholder.remove();
|
|
2124
|
+
// disable animation when replacing a placeholder (already positioned) with actual content
|
|
2125
|
+
var noAnim = wasAdded && _this.opts.animate;
|
|
2126
|
+
if (noAnim)
|
|
2127
|
+
_this.setAnimation(false);
|
|
2109
2128
|
// notify previous grid of removal
|
|
2110
2129
|
// console.log('drop delete _gridstackNodeOrig') // TEST
|
|
2111
2130
|
var origNode = el._gridstackNodeOrig;
|
|
@@ -2150,15 +2169,13 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2150
2169
|
// @ts-ignore
|
|
2151
2170
|
utils_1.Utils.copyPos(node, _this._readAttr(_this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578
|
|
2152
2171
|
utils_1.Utils.removePositioningStyles(el); // @ts-ignore
|
|
2153
|
-
_this._writeAttr(el, node);
|
|
2154
|
-
el.classList.add(types_1.gridDefaults.itemClass, _this.opts.itemClass);
|
|
2155
2172
|
_this.el.appendChild(el); // @ts-ignore // TODO: now would be ideal time to _removeHelperStyle() overriding floating styles (native only)
|
|
2173
|
+
_this._prepareElement(el, true, node);
|
|
2156
2174
|
if (subGrid) {
|
|
2157
2175
|
subGrid.parentGridItem = node;
|
|
2158
2176
|
if (!subGrid.opts.styleInHead)
|
|
2159
2177
|
subGrid._updateStyles(true); // re-create sub-grid styles now that we've moved
|
|
2160
2178
|
}
|
|
2161
|
-
_this._prepareDragDropByNode(node);
|
|
2162
2179
|
_this._updateContainerHeight();
|
|
2163
2180
|
_this.engine.addedNodes.push(node); // @ts-ignore
|
|
2164
2181
|
_this._triggerAddEvent(); // @ts-ignore
|
|
@@ -2167,6 +2184,9 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2167
2184
|
if (_this._gsEventHandler['dropped']) {
|
|
2168
2185
|
_this._gsEventHandler['dropped'](__assign(__assign({}, event), { type: 'dropped' }), origNode && origNode.grid ? origNode : undefined, node);
|
|
2169
2186
|
}
|
|
2187
|
+
// delay adding animation back
|
|
2188
|
+
if (noAnim)
|
|
2189
|
+
setTimeout(function () { return _this.setAnimation(_this.opts.animate); });
|
|
2170
2190
|
return false; // prevent parent from receiving msg (which may be grid as well)
|
|
2171
2191
|
});
|
|
2172
2192
|
return this;
|
|
@@ -2236,6 +2256,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2236
2256
|
delete node._moving;
|
|
2237
2257
|
delete node._event;
|
|
2238
2258
|
delete node._lastTried;
|
|
2259
|
+
var widthChanged = node.w !== node._orig.w;
|
|
2239
2260
|
// if the item has moved to another grid, we're done here
|
|
2240
2261
|
var target = event.target;
|
|
2241
2262
|
if (!target.gridstackNode || target.gridstackNode.grid !== _this)
|
|
@@ -2273,7 +2294,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2273
2294
|
if (event.type === 'resizestop') {
|
|
2274
2295
|
if (Number.isInteger(node.sizeToContent))
|
|
2275
2296
|
node.sizeToContent = node.h; // new soft limit
|
|
2276
|
-
_this.
|
|
2297
|
+
_this.resizeToContentCheck(widthChanged, node); // wait for width animation if changed
|
|
2277
2298
|
}
|
|
2278
2299
|
};
|
|
2279
2300
|
dd.draggable(el, {
|
|
@@ -2449,7 +2470,7 @@ var GridStack = exports.GridStack = /** @class */ (function () {
|
|
|
2449
2470
|
GridStack.Utils = utils_1.Utils;
|
|
2450
2471
|
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
2451
2472
|
GridStack.Engine = gridstack_engine_1.GridStackEngine;
|
|
2452
|
-
GridStack.GDRev = '10.0.
|
|
2473
|
+
GridStack.GDRev = '10.0.1';
|
|
2453
2474
|
return GridStack;
|
|
2454
2475
|
}());
|
|
2455
2476
|
//# sourceMappingURL=gridstack.js.map
|