Skip to content

Commit 78ad209

Browse files
author
Alain Dumesny
authored
Merge pull request #1234 from adumesny/develop
`staticGrid` no longer disable oneColumnMode
2 parents 1b86dd9 + ff76497 commit 78ad209

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

doc/CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Change log
3535

3636
## 1.1.1-dev (upcoming)
3737

38-
- TBD
38+
- fix [1229](https://github.com/gridstack/gridstack.js/issues/1229) `staticGrid` no longer disable oneColumnMode
3939

4040
## 1.1.1 (2020-03-17)
4141

doc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ gridstack.js API
101101
- `removeTimeout` - time in milliseconds before widget is being removed while dragging outside of the grid. (default: `2000`)
102102
- `row` - fix grid number of rows. This is a shortcut of writing `minRow:N, maxRow:N`. (default `0` no constrain)
103103
- `rtl` - if `true` turns grid to RTL. Possible values are `true`, `false`, `'auto'` (default: `'auto'`) See [example](http://gridstackjs.com/demo/rtl.html)
104-
- `staticGrid` - makes grid static (default `false`). If true widgets are not movable/resizable. You don't even need jQueryUI draggable/resizable. A CSS class `grid-stack-static` is also added to the container.
104+
- `staticGrid` - removes drag&drop&resize (default `false`). If `true` widgets are not movable/resizable by the user, but code can still move and oneColumnMode will still work. You don't even need jQueryUI draggable/resizable. A CSS class `grid-stack-static` is also added to the container.
105105
- `verticalMargin` - vertical gap size (default: `20`). Can be:
106106
* an integer (px)
107107
* a string (ex: '2em', '20px', '2rem')

spec/gridstack-spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ describe('gridstack', function() {
145145
staticGrid: true
146146
};
147147
var grid = GridStack.init(options);
148+
expect($('.grid-stack').hasClass('grid-stack-static')).toBe(true);
148149
$('.grid-stack').removeClass('grid-stack-static');
149150
grid._setStaticClass();
150151
expect($('.grid-stack').hasClass('grid-stack-static')).toBe(true);
@@ -156,6 +157,7 @@ describe('gridstack', function() {
156157
staticGrid: false
157158
};
158159
var grid = GridStack.init(options);
160+
expect($('.grid-stack').hasClass('grid-stack-static')).toBe(false);
159161
$('.grid-stack').addClass('grid-stack-static');
160162
grid._setStaticClass();
161163
expect($('.grid-stack').hasClass('grid-stack-static')).toBe(false);

src/gridstack.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,10 @@ interface GridstackOptions {
624624
rtl ? : boolean | 'auto';
625625

626626
/**
627-
* makes grid static (default?: false). If `true` widgets are not movable/resizable.
628-
* You don't even need draggable/resizable. A CSS class
629-
* 'grid-stack-static' is also added to the element.
627+
* removes drag&drop&resize (default `false`).
628+
* If `true` widgets are not movable/resizable by the user, but code can still move and oneColumnMode will still work.
629+
* You don't even need jQueryUI draggable/resizable.
630+
* A CSS class `grid-stack-static` is also added to the container.
630631
*/
631632
staticGrid ? : boolean;
632633

src/gridstack.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -867,14 +867,12 @@
867867
self._updateHeightsOnResize();
868868
}
869869

870-
if (self.opts.staticGrid) { return; }
871-
872870
if (!self.opts.disableOneColumnMode && (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) <= self.opts.minWidth) {
873-
if (self.oneColumnMode) { return; }
871+
if (self.oneColumnMode) { return }
874872
self.oneColumnMode = true;
875873
self.column(1);
876874
} else {
877-
if (!self.oneColumnMode) { return; }
875+
if (!self.oneColumnMode) { return }
878876
self.oneColumnMode = false;
879877
self.column(self._prevColumn);
880878
}

0 commit comments

Comments
 (0)