Skip to content

Commit 5b1cd50

Browse files
committed
column # changes auto cellHeight
* fix changing column # `column(n)` now resizes `cellHeight:'auto'` to keep square * update column.html demo to have fix cellHeight (makes it easier to see relayout for debugging)
1 parent c804af2 commit 5b1cd50

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

demo/column.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</head>
1313
<body>
1414
<div class="container-fluid">
15-
<h1>column() grid demo</h1>
15+
<h1>column() grid demo (fix cellHeight)</h1>
1616
<div><span>Number of Columns:</span> <span id="column-text">12</span></div>
1717
<div>
1818
<label>Choose re-layout:</label>
@@ -41,7 +41,11 @@ <h1>column() grid demo</h1>
4141
</div>
4242

4343
<script type="text/javascript">
44-
let grid = GridStack.init({float: true});
44+
let grid = GridStack.init({
45+
float: true,
46+
disableOneColumnMode: true, // prevent auto column for this manual demo
47+
cellHeight: 100 // fixed as default 'auto' (square) makes it hard to test 1-3 column in actual large windows tests
48+
});
4549
let text = document.querySelector('#column-text');
4650
let layout = 'moveScale';
4751

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Change log
5454
- Dragging up and down now behave the same (used to require push WAY down past to swap/append). Also much more efficient collision code.
5555
- handle mid point of dragged over items (>50%) rather than a new row/column and check for the most covered when multiple items collide.
5656
- fix [1617](https://github.com/gridstack/gridstack.js/issues/1617) FireFox DOM order issue. Thanks [@marcel-necker](https://github.com/marcel-necker)
57+
- fix changing column # `column(n)` now resizes `cellHeight:'auto'` to keep square
5758
- add `drag | resize` events while dragging [1616](https://github.com/gridstack/gridstack.js/pull/1616). Thanks [@MrCorba](https://github.com/MrCorba)
5859
- add `GridStack.setupDragIn()` so user can update external draggable after the grid has been created [1637](https://github.com/gridstack/gridstack.js/issues/1637)
5960

src/gridstack.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ export class GridStack {
298298

299299
this._isAutoCellHeight = (this.opts.cellHeight === 'auto');
300300
if (this._isAutoCellHeight || this.opts.cellHeight === 'initial') {
301-
// make the cell content square initially (will use resize event to keep it square)
301+
// make the cell content square initially (will use resize/column event to keep it square)
302302
this.cellHeight(undefined, false);
303303
} else {
304304
this.cellHeight(this.opts.cellHeight, false);
@@ -685,6 +685,7 @@ export class GridStack {
685685
if (!domNodes.length) { domNodes = undefined; }
686686
}
687687
this.engine.updateNodeWidths(oldColumn, column, domNodes, layout);
688+
if (this._isAutoCellHeight) this.cellHeight();
688689

689690
// and trigger our event last...
690691
this._ignoreLayoutsNodeChange = true; // skip layout update

0 commit comments

Comments
 (0)