gridstack 10.0.1 → 10.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 +2 -2
- 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 +19 -30
- package/dist/dd-draggable.js.map +1 -1
- package/dist/dd-droppable.d.ts +3 -3
- package/dist/dd-droppable.js +15 -13
- package/dist/dd-droppable.js.map +1 -1
- package/dist/dd-element.d.ts +2 -2
- 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 +14 -4
- 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 +5 -2
- package/dist/dd-resizable-handle.js +8 -9
- package/dist/dd-resizable-handle.js.map +1 -1
- package/dist/dd-resizable.d.ts +4 -4
- package/dist/dd-resizable.js +11 -25
- 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 +19 -30
- package/dist/es5/dd-draggable.js.map +1 -1
- package/dist/es5/dd-droppable.d.ts +3 -3
- package/dist/es5/dd-droppable.js +17 -14
- package/dist/es5/dd-droppable.js.map +1 -1
- package/dist/es5/dd-element.d.ts +2 -2
- 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 +13 -3
- 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 +5 -2
- package/dist/es5/dd-resizable-handle.js +8 -9
- package/dist/es5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/dd-resizable.d.ts +4 -4
- package/dist/es5/dd-resizable.js +12 -26
- 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 +9 -24
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +16 -13
- package/dist/es5/gridstack.js +96 -55
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +1 -1
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +14 -3
- package/dist/es5/utils.js +34 -5
- 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 +9 -24
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +2 -2
- package/dist/gridstack.d.ts +16 -13
- package/dist/gridstack.js +95 -56
- 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 +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +14 -3
- package/dist/utils.js +33 -5
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +15 -0
- package/doc/README.md +1 -1
- package/package.json +1 -1
package/dist/gridstack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GridStack 10.
|
|
2
|
+
* GridStack 10.1.1
|
|
3
3
|
* https://gridstackjs.com/
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2021-2022 Alain Dumesny
|
|
@@ -48,6 +48,8 @@ class GridStack {
|
|
|
48
48
|
* let grid = document.querySelector('.grid-stack').gridstack;
|
|
49
49
|
*/
|
|
50
50
|
static init(options = {}, elOrString = '.grid-stack') {
|
|
51
|
+
if (typeof document === 'undefined')
|
|
52
|
+
return null; // temp workaround SSR
|
|
51
53
|
let el = GridStack.getGridElement(elOrString);
|
|
52
54
|
if (!el) {
|
|
53
55
|
if (typeof elOrString === 'string') {
|
|
@@ -75,6 +77,8 @@ class GridStack {
|
|
|
75
77
|
*/
|
|
76
78
|
static initAll(options = {}, selector = '.grid-stack') {
|
|
77
79
|
let grids = [];
|
|
80
|
+
if (typeof document === 'undefined')
|
|
81
|
+
return grids; // temp workaround SSR
|
|
78
82
|
GridStack.getGridElements(selector).forEach(el => {
|
|
79
83
|
if (!el.gridstack) {
|
|
80
84
|
el.gridstack = new GridStack(el, Utils.cloneDeep(options));
|
|
@@ -147,16 +151,19 @@ class GridStack {
|
|
|
147
151
|
}
|
|
148
152
|
/**
|
|
149
153
|
* Construct a grid item from the given element and options
|
|
150
|
-
* @param el
|
|
151
|
-
* @param opts
|
|
154
|
+
* @param el the HTML element tied to this grid after it's been initialized
|
|
155
|
+
* @param opts grid options - public for classes to access, but use methods to modify!
|
|
152
156
|
*/
|
|
153
157
|
constructor(el, opts = {}) {
|
|
158
|
+
this.el = el;
|
|
159
|
+
this.opts = opts;
|
|
154
160
|
/** @internal */
|
|
155
161
|
this._gsEventHandler = {};
|
|
156
162
|
/** @internal extra row added when dragging at the bottom of the grid */
|
|
157
163
|
this._extraDragRow = 0;
|
|
164
|
+
/** @internal meant to store the scale of the active grid */
|
|
165
|
+
this.dragTransform = { xScale: 1, yScale: 1, xOffset: 0, yOffset: 0 };
|
|
158
166
|
el.gridstack = this;
|
|
159
|
-
this.el = el; // exposed HTML element to the user
|
|
160
167
|
opts = opts || {}; // handles null/undefined/0
|
|
161
168
|
if (!el.classList.contains('grid-stack')) {
|
|
162
169
|
this.el.classList.add('grid-stack');
|
|
@@ -180,7 +187,7 @@ class GridStack {
|
|
|
180
187
|
const oldOpts = opts;
|
|
181
188
|
if (oldOpts.oneColumnModeDomSort) {
|
|
182
189
|
delete oldOpts.oneColumnModeDomSort;
|
|
183
|
-
console.log('
|
|
190
|
+
console.log('warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.');
|
|
184
191
|
}
|
|
185
192
|
if (oldOpts.oneColumnSize || oldOpts.disableOneColumnMode === false) {
|
|
186
193
|
const oneSize = oldOpts.oneColumnSize || 768;
|
|
@@ -227,16 +234,15 @@ class GridStack {
|
|
|
227
234
|
if (el.getAttribute('gs-animate')) { // default to true, but if set to false use that instead
|
|
228
235
|
defaults.animate = Utils.toBool(el.getAttribute('gs-animate'));
|
|
229
236
|
}
|
|
230
|
-
|
|
231
|
-
opts = null; // make sure we use this.opts instead
|
|
237
|
+
opts = Utils.defaults(opts, defaults);
|
|
232
238
|
this._initMargin(); // part of settings defaults...
|
|
233
239
|
// 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)
|
|
234
240
|
this.checkDynamicColumn();
|
|
235
|
-
this.el.classList.add('gs-' +
|
|
236
|
-
if (
|
|
237
|
-
|
|
241
|
+
this.el.classList.add('gs-' + opts.column);
|
|
242
|
+
if (opts.rtl === 'auto') {
|
|
243
|
+
opts.rtl = (el.style.direction === 'rtl');
|
|
238
244
|
}
|
|
239
|
-
if (
|
|
245
|
+
if (opts.rtl) {
|
|
240
246
|
this.el.classList.add('grid-stack-rtl');
|
|
241
247
|
}
|
|
242
248
|
// check if we're been nested, and if so update our style and keep pointer around (used during save)
|
|
@@ -248,31 +254,31 @@ class GridStack {
|
|
|
248
254
|
this.el.classList.add('grid-stack-nested');
|
|
249
255
|
parentGridItem.el.classList.add('grid-stack-sub-grid');
|
|
250
256
|
}
|
|
251
|
-
this._isAutoCellHeight = (
|
|
252
|
-
if (this._isAutoCellHeight ||
|
|
257
|
+
this._isAutoCellHeight = (opts.cellHeight === 'auto');
|
|
258
|
+
if (this._isAutoCellHeight || opts.cellHeight === 'initial') {
|
|
253
259
|
// make the cell content square initially (will use resize/column event to keep it square)
|
|
254
260
|
this.cellHeight(undefined, false);
|
|
255
261
|
}
|
|
256
262
|
else {
|
|
257
263
|
// append unit if any are set
|
|
258
|
-
if (typeof
|
|
259
|
-
|
|
260
|
-
delete
|
|
264
|
+
if (typeof opts.cellHeight == 'number' && opts.cellHeightUnit && opts.cellHeightUnit !== gridDefaults.cellHeightUnit) {
|
|
265
|
+
opts.cellHeight = opts.cellHeight + opts.cellHeightUnit;
|
|
266
|
+
delete opts.cellHeightUnit;
|
|
261
267
|
}
|
|
262
|
-
this.cellHeight(
|
|
268
|
+
this.cellHeight(opts.cellHeight, false);
|
|
263
269
|
}
|
|
264
270
|
// see if we need to adjust auto-hide
|
|
265
|
-
if (
|
|
266
|
-
|
|
271
|
+
if (opts.alwaysShowResizeHandle === 'mobile') {
|
|
272
|
+
opts.alwaysShowResizeHandle = isTouch;
|
|
267
273
|
}
|
|
268
274
|
this._styleSheetClass = 'gs-id-' + GridStackEngine._idSeq++;
|
|
269
275
|
this.el.classList.add(this._styleSheetClass);
|
|
270
276
|
this._setStaticClass();
|
|
271
|
-
let engineClass =
|
|
277
|
+
let engineClass = opts.engineClass || GridStack.engineClass || GridStackEngine;
|
|
272
278
|
this.engine = new engineClass({
|
|
273
279
|
column: this.getColumn(),
|
|
274
|
-
float:
|
|
275
|
-
maxRow:
|
|
280
|
+
float: opts.float,
|
|
281
|
+
maxRow: opts.maxRow,
|
|
276
282
|
onChange: (cbNodes) => {
|
|
277
283
|
let maxH = 0;
|
|
278
284
|
this.engine.nodes.forEach(n => { maxH = Math.max(maxH, n.y + n.h); });
|
|
@@ -294,25 +300,25 @@ class GridStack {
|
|
|
294
300
|
});
|
|
295
301
|
// create initial global styles BEFORE loading children so resizeToContent margin can be calculated correctly
|
|
296
302
|
this._updateStyles(false, 0);
|
|
297
|
-
if (
|
|
303
|
+
if (opts.auto) {
|
|
298
304
|
this.batchUpdate(); // prevent in between re-layout #1535 TODO: this only set float=true, need to prevent collision check...
|
|
299
305
|
this.getGridItems().forEach(el => this._prepareElement(el));
|
|
300
306
|
this.batchUpdate(false);
|
|
301
307
|
}
|
|
302
308
|
// load any passed in children as well, which overrides any DOM layout done above
|
|
303
|
-
if (
|
|
304
|
-
let children =
|
|
305
|
-
delete
|
|
309
|
+
if (opts.children) {
|
|
310
|
+
let children = opts.children;
|
|
311
|
+
delete opts.children;
|
|
306
312
|
if (children.length)
|
|
307
313
|
this.load(children); // don't load empty
|
|
308
314
|
}
|
|
309
315
|
// if (this.engine.nodes.length) this._updateStyles(); // update based on # of children. done in engine onChange CB
|
|
310
|
-
this.setAnimation(
|
|
316
|
+
this.setAnimation(opts.animate);
|
|
311
317
|
// dynamic grids require pausing during drag to detect over to nest vs push
|
|
312
|
-
if (
|
|
318
|
+
if (opts.subGridDynamic && !DDManager.pauseDrag)
|
|
313
319
|
DDManager.pauseDrag = true;
|
|
314
|
-
if (
|
|
315
|
-
DDManager.pauseDrag =
|
|
320
|
+
if (opts.draggable?.pause !== undefined)
|
|
321
|
+
DDManager.pauseDrag = opts.draggable.pause;
|
|
316
322
|
this._setupRemoveDrop();
|
|
317
323
|
this._setupAcceptWidget();
|
|
318
324
|
this._updateResizeEvent();
|
|
@@ -390,6 +396,7 @@ class GridStack {
|
|
|
390
396
|
* @param el gridItem element to convert
|
|
391
397
|
* @param ops (optional) sub-grid options, else default to node, then parent settings, else defaults
|
|
392
398
|
* @param nodeToAdd (optional) node to add to the newly created sub grid (used when dragging over existing regular item)
|
|
399
|
+
* @param saveContent if true (default) the html inside .grid-stack-content will be saved to child widget
|
|
393
400
|
* @returns newly created grid
|
|
394
401
|
*/
|
|
395
402
|
makeSubGrid(el, ops, nodeToAdd, saveContent = true) {
|
|
@@ -407,7 +414,7 @@ class GridStack {
|
|
|
407
414
|
grid = grid.parentGridItem?.grid;
|
|
408
415
|
}
|
|
409
416
|
//... and set the create options
|
|
410
|
-
ops = Utils.cloneDeep({ ...(subGridTemplate || {}), children: undefined, ...(ops || node.subGridOpts) });
|
|
417
|
+
ops = Utils.cloneDeep({ ...(subGridTemplate || {}), children: undefined, ...(ops || node.subGridOpts || {}) });
|
|
411
418
|
node.subGridOpts = ops;
|
|
412
419
|
// if column special case it set, remember that flag and set default
|
|
413
420
|
let autoColumn;
|
|
@@ -688,13 +695,20 @@ class GridStack {
|
|
|
688
695
|
(!forcePixel || !this.opts.cellHeightUnit || this.opts.cellHeightUnit === 'px')) {
|
|
689
696
|
return this.opts.cellHeight;
|
|
690
697
|
}
|
|
691
|
-
// do rem/em to px conversion
|
|
698
|
+
// do rem/em/cm/mm to px conversion
|
|
692
699
|
if (this.opts.cellHeightUnit === 'rem') {
|
|
693
700
|
return this.opts.cellHeight * parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
694
701
|
}
|
|
695
702
|
if (this.opts.cellHeightUnit === 'em') {
|
|
696
703
|
return this.opts.cellHeight * parseFloat(getComputedStyle(this.el).fontSize);
|
|
697
704
|
}
|
|
705
|
+
if (this.opts.cellHeightUnit === 'cm') {
|
|
706
|
+
// 1cm = 96px/2.54. See https://www.w3.org/TR/css-values-3/#absolute-lengths
|
|
707
|
+
return this.opts.cellHeight * (96 / 2.54);
|
|
708
|
+
}
|
|
709
|
+
if (this.opts.cellHeightUnit === 'mm') {
|
|
710
|
+
return this.opts.cellHeight * (96 / 2.54) / 10;
|
|
711
|
+
}
|
|
698
712
|
// else get first cell height
|
|
699
713
|
let el = this.el.querySelector('.' + this.opts.itemClass);
|
|
700
714
|
if (el) {
|
|
@@ -818,7 +832,7 @@ class GridStack {
|
|
|
818
832
|
// update the items now, checking if we have a custom children layout
|
|
819
833
|
/*const newChildren = this.opts.columnOpts?.breakpoints?.find(r => r.c === column)?.children;
|
|
820
834
|
if (newChildren) this.load(newChildren);
|
|
821
|
-
else*/ this.engine.columnChanged(oldColumn, column,
|
|
835
|
+
else*/ this.engine.columnChanged(oldColumn, column, layout);
|
|
822
836
|
if (this._isAutoCellHeight)
|
|
823
837
|
this.cellHeight();
|
|
824
838
|
this.resizeToContentCheck(true); // wait for width resizing
|
|
@@ -957,22 +971,6 @@ class GridStack {
|
|
|
957
971
|
delete this._ignoreLayoutsNodeChange;
|
|
958
972
|
return el;
|
|
959
973
|
}
|
|
960
|
-
/**
|
|
961
|
-
* Event handler that extracts our CustomEvent data out automatically for receiving custom
|
|
962
|
-
* notifications (see doc for supported events)
|
|
963
|
-
* @param name of the event (see possible values) or list of names space separated
|
|
964
|
-
* @param callback function called with event and optional second/third param
|
|
965
|
-
* (see README documentation for each signature).
|
|
966
|
-
*
|
|
967
|
-
* @example
|
|
968
|
-
* grid.on('added', function(e, items) { log('added ', items)} );
|
|
969
|
-
* or
|
|
970
|
-
* grid.on('added removed change', function(e, items) { log(e.type, items)} );
|
|
971
|
-
*
|
|
972
|
-
* Note: in some cases it is the same as calling native handler and parsing the event.
|
|
973
|
-
* grid.el.addEventListener('added', function(event) { log('added ', event.detail)} );
|
|
974
|
-
*
|
|
975
|
-
*/
|
|
976
974
|
on(name, callback) {
|
|
977
975
|
// check for array of names being passed instead
|
|
978
976
|
if (name.indexOf(' ') !== -1) {
|
|
@@ -998,13 +996,13 @@ class GridStack {
|
|
|
998
996
|
this._gsEventHandler[name] = callback;
|
|
999
997
|
}
|
|
1000
998
|
else {
|
|
1001
|
-
console.
|
|
999
|
+
console.error('GridStack.on(' + name + ') event not supported');
|
|
1002
1000
|
}
|
|
1003
1001
|
return this;
|
|
1004
1002
|
}
|
|
1005
1003
|
/**
|
|
1006
|
-
* unsubscribe from the 'on' event
|
|
1007
|
-
* @param name of the event (see possible values)
|
|
1004
|
+
* unsubscribe from the 'on' event GridStackEvent
|
|
1005
|
+
* @param name of the event (see possible values) or list of names space separated
|
|
1008
1006
|
*/
|
|
1009
1007
|
off(name) {
|
|
1010
1008
|
// check for array of names being passed instead
|
|
@@ -1024,7 +1022,7 @@ class GridStack {
|
|
|
1024
1022
|
}
|
|
1025
1023
|
/** remove all event handlers */
|
|
1026
1024
|
offAll() {
|
|
1027
|
-
Object.keys(this._gsEventHandler).forEach(key => this.off(key));
|
|
1025
|
+
Object.keys(this._gsEventHandler).forEach((key) => this.off(key));
|
|
1028
1026
|
return this;
|
|
1029
1027
|
}
|
|
1030
1028
|
/**
|
|
@@ -1237,7 +1235,7 @@ class GridStack {
|
|
|
1237
1235
|
// NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
|
|
1238
1236
|
const child = item.firstElementChild;
|
|
1239
1237
|
if (!child) {
|
|
1240
|
-
console.
|
|
1238
|
+
console.error(`Error: GridStack.resizeToContent() widget id:${n.id} '${GridStack.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);
|
|
1241
1239
|
return;
|
|
1242
1240
|
}
|
|
1243
1241
|
wantedH = child.getBoundingClientRect().height || itemH;
|
|
@@ -1404,6 +1402,8 @@ class GridStack {
|
|
|
1404
1402
|
Utils.addCSSRule(this._styles, content, `top: ${top}; right: ${right}; bottom: ${bottom}; left: ${left};`);
|
|
1405
1403
|
Utils.addCSSRule(this._styles, placeholder, `top: ${top}; right: ${right}; bottom: ${bottom}; left: ${left};`);
|
|
1406
1404
|
// resize handles offset (to match margin)
|
|
1405
|
+
Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-n`, `top: ${top};`);
|
|
1406
|
+
Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-s`, `bottom: ${bottom}`);
|
|
1407
1407
|
Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-ne`, `right: ${right}`);
|
|
1408
1408
|
Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-e`, `right: ${right}`);
|
|
1409
1409
|
Utils.addCSSRule(this._styles, `${prefix} > .ui-resizable-se`, `right: ${right}; bottom: ${bottom}`);
|
|
@@ -1868,11 +1868,27 @@ class GridStack {
|
|
|
1868
1868
|
if (!node)
|
|
1869
1869
|
return;
|
|
1870
1870
|
helper = helper || el;
|
|
1871
|
+
// if the element is being dragged from outside, scale it down to match the grid's scale
|
|
1872
|
+
// and slightly adjust its position relative to the mouse
|
|
1873
|
+
if (!node.grid?.el) {
|
|
1874
|
+
// this scales the helper down
|
|
1875
|
+
helper.style.transform = `scale(${1 / this.dragTransform.xScale},${1 / this.dragTransform.yScale})`;
|
|
1876
|
+
// this makes it so that the helper is well positioned relative to the mouse after scaling
|
|
1877
|
+
const helperRect = helper.getBoundingClientRect();
|
|
1878
|
+
helper.style.left = helperRect.x + (this.dragTransform.xScale - 1) * (event.clientX - helperRect.x) / this.dragTransform.xScale + 'px';
|
|
1879
|
+
helper.style.top = helperRect.y + (this.dragTransform.yScale - 1) * (event.clientY - helperRect.y) / this.dragTransform.yScale + 'px';
|
|
1880
|
+
helper.style.transformOrigin = `0px 0px`;
|
|
1881
|
+
}
|
|
1871
1882
|
let parent = this.el.getBoundingClientRect();
|
|
1872
1883
|
let { top, left } = helper.getBoundingClientRect();
|
|
1873
1884
|
left -= parent.left;
|
|
1874
1885
|
top -= parent.top;
|
|
1875
|
-
let ui = {
|
|
1886
|
+
let ui = {
|
|
1887
|
+
position: {
|
|
1888
|
+
top: top * this.dragTransform.xScale,
|
|
1889
|
+
left: left * this.dragTransform.yScale
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1876
1892
|
if (node._temporaryRemoved) {
|
|
1877
1893
|
node.x = Math.max(0, Math.round(left / cellWidth));
|
|
1878
1894
|
node.y = Math.max(0, Math.round(top / cellHeight));
|
|
@@ -2211,6 +2227,26 @@ class GridStack {
|
|
|
2211
2227
|
this._writePosAttr(this.placeholder, node);
|
|
2212
2228
|
this.el.appendChild(this.placeholder);
|
|
2213
2229
|
// console.log('_onStartMoving placeholder') // TEST
|
|
2230
|
+
// if the element is inside a grid, it has already been scaled
|
|
2231
|
+
// we can use that as a scale reference
|
|
2232
|
+
if (node.grid?.el) {
|
|
2233
|
+
this.dragTransform = Utils.getValuesFromTransformedElement(el);
|
|
2234
|
+
}
|
|
2235
|
+
// if the element is being dragged from outside (not from any grid)
|
|
2236
|
+
// we use the grid as the transformation reference, since the helper is not subject to transformation
|
|
2237
|
+
else if (this.placeholder && this.placeholder.closest('.grid-stack')) {
|
|
2238
|
+
const gridEl = this.placeholder.closest('.grid-stack');
|
|
2239
|
+
this.dragTransform = Utils.getValuesFromTransformedElement(gridEl);
|
|
2240
|
+
}
|
|
2241
|
+
// Fallback
|
|
2242
|
+
else {
|
|
2243
|
+
this.dragTransform = {
|
|
2244
|
+
xScale: 1,
|
|
2245
|
+
xOffset: 0,
|
|
2246
|
+
yScale: 1,
|
|
2247
|
+
yOffset: 0,
|
|
2248
|
+
};
|
|
2249
|
+
}
|
|
2214
2250
|
node.el = this.placeholder;
|
|
2215
2251
|
node._lastUiPosition = ui.position;
|
|
2216
2252
|
node._prevYPix = ui.position.top;
|
|
@@ -2327,6 +2363,9 @@ class GridStack {
|
|
|
2327
2363
|
let node = el.gridstackNode;
|
|
2328
2364
|
if (!node)
|
|
2329
2365
|
return;
|
|
2366
|
+
helper = helper || el;
|
|
2367
|
+
// restore the scale of the helper on leave
|
|
2368
|
+
helper.style.transform = 'scale(1)';
|
|
2330
2369
|
dd.off(el, 'drag'); // no need to track while being outside
|
|
2331
2370
|
// this gets called when cursor leaves and shape is outside, so only do this once
|
|
2332
2371
|
if (node._temporaryRemoved)
|
|
@@ -2361,6 +2400,6 @@ GridStack.resizeToContentParent = '.grid-stack-item-content';
|
|
|
2361
2400
|
GridStack.Utils = Utils;
|
|
2362
2401
|
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
2363
2402
|
GridStack.Engine = GridStackEngine;
|
|
2364
|
-
GridStack.GDRev = '10.
|
|
2403
|
+
GridStack.GDRev = '10.1.1';
|
|
2365
2404
|
export { GridStack };
|
|
2366
2405
|
//# sourceMappingURL=gridstack.js.map
|