Skip to content

Commit b3d5be1

Browse files
committed
Merge pull request #371 from pmoradei/setgridsize_propagate
Add a parameter to setGridWidth method to allow not to propagate resi…
2 parents 65d5110 + 601b5d5 commit b3d5be1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

doc/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,12 @@ Toggle the grid animation state. Toggles the `grid-stack-animate` class.
415415

416416
- `doAnimate` - if `true` the grid will animate.
417417

418-
### setGridWidth(gridWidth)
418+
### setGridWidth(gridWidth, doNotPropagate)
419419

420420
(Experimental) Modify number of columns in the grid. Will attempt to update existing widgets to conform to new number of columns. Requires `gridstack-extra.css` or `gridstack-extra.min.css`.
421421

422422
- `gridWidth` - Integer between 1 and 12.
423+
- `doNotPropagate` - if true existing widgets will not be updated.
423424

424425
### setStatic(staticValue)
425426

src/gridstack.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,10 +1538,13 @@
15381538
this.grid.commit();
15391539
};
15401540

1541-
GridStack.prototype.setGridWidth = function(gridWidth) {
1541+
GridStack.prototype.setGridWidth = function(gridWidth,doNotPropagate) {
15421542
this.container.removeClass('grid-stack-' + this.opts.width);
1543-
this._updateNodeWidths(this.opts.width, gridWidth);
1543+
if (doNotPropagate !== true) {
1544+
this._updateNodeWidths(this.opts.width, gridWidth);
1545+
}
15441546
this.opts.width = gridWidth;
1547+
this.grid.width = gridWidth;
15451548
this.container.addClass('grid-stack-' + gridWidth);
15461549
};
15471550

0 commit comments

Comments
 (0)