Skip to content

Commit 9ead861

Browse files
committed
fix to nested grid resisze
* fox for #1361, we can now resize nested grids again
1 parent 6b6c396 commit 9ead861

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

demo/nested.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ <h1>Nested grids demo</h1>
6060
disableOneColumnMode: true, // nested are small, but still want N columns
6161
margin: 1
6262
};
63-
GridStack.init(null, '.grid-stack.top');
63+
GridStack.init({cellHeight: 70}, '.grid-stack.top');
6464
let grid1 = GridStack.init(nestOptions, '.grid-stack.nested1');
6565
nestOptions.dragOut = false;
6666
let grid2 = GridStack.init(nestOptions, '.grid-stack.nested2');

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Change log
4242
- fix `minWidth()`, `minHeight()`, `maxHeight()` to set node value as well [1359](https://github.com/gridstack/gridstack.js/issues/1359)
4343
- fix `GridStackOptions` spelling [1359](https://github.com/gridstack/gridstack.js/issues/1359)
4444
- fix remove window resize event when `grid.destroy()` [1369](https://github.com/gridstack/gridstack.js/issues/1369)
45+
- fix nested grid resize [1361](https://github.com/gridstack/gridstack.js/issues/1361)
4546

4647
## 2.0.0 (2020-09-07)
4748

src/gridstack.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,18 +1197,18 @@ export class GridStack {
11971197

11981198
/** called when item starts moving/resizing */
11991199
let onStartMoving = (event, ui) => {
1200+
let target: HTMLElement = event.target;
1201+
12001202
// trigger any 'dragstart' / 'resizestart' manually
12011203
if (this._gsEventHandler[event.type]) {
1202-
this._gsEventHandler[event.type](event, event.target);
1204+
this._gsEventHandler[event.type](event, target);
12031205
}
12041206

12051207
this.engine.cleanNodes();
12061208
this.engine.beginUpdate(node);
12071209
cellWidth = this.cellWidth();
12081210
cellHeight = this.getCellHeight();
12091211

1210-
let { target } = event;
1211-
12121212
this.placeholder.setAttribute('data-gs-x', target.getAttribute('data-gs-x'));
12131213
this.placeholder.setAttribute('data-gs-y', target.getAttribute('data-gs-y'));
12141214
this.placeholder.setAttribute('data-gs-width', target.getAttribute('data-gs-width'));
@@ -1219,20 +1219,10 @@ export class GridStack {
12191219
node._beforeDragX = node.x;
12201220
node._beforeDragY = node.y;
12211221
node._prevYPix = ui.position.top;
1222-
let minHeight = (node.minHeight || 1);
12231222

12241223
// mineHeight - Each row is cellHeight + margin
12251224
this.dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minWidth || 1));
1226-
this.dd.resizable(el, 'option', 'minHeight', cellHeight * minHeight);
1227-
1228-
if (event.type === 'resizestart') {
1229-
let itemElement = target.querySelector('.grid-stack-item') as HTMLElement;
1230-
if (itemElement) {
1231-
let ev = document.createEvent('HTMLEvents');
1232-
ev.initEvent('resizestart', true, false);
1233-
itemElement.dispatchEvent(event);
1234-
}
1235-
}
1225+
this.dd.resizable(el, 'option', 'minHeight', cellHeight * (node.minHeight || 1));
12361226
}
12371227

12381228
/** called when item is being dragged/resized */

0 commit comments

Comments
 (0)