Skip to content

Commit 02f0eba

Browse files
committed
add maxWidth/maxHeight
1 parent 29857f4 commit 02f0eba

File tree

5 files changed

+93
-8
lines changed

5 files changed

+93
-8
lines changed

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com
4545
- [isAreaEmpty(x, y, width, height)](#isareaemptyx-y-width-height)
4646
- [locked(el, val)](#lockedel-val)
4747
- [makeWidget(el)](#makewidgetel)
48-
- [minWidth(el, val)](#minwidthel-val)
48+
- [maxHeight(el, val)](#maxheightel-val)
4949
- [minHeight(el, val)](#minheightel-val)
50+
- [maxWidth(el, val)](#maxwidthel-val)
51+
- [minWidth(el, val)](#minwidthel-val)
5052
- [movable(el, val)](#movableel-val)
5153
- [move(el, x, y)](#moveel-x-y)
5254
- [removeWidget(el, detachNode)](#removewidgetel-detachnode)
@@ -380,20 +382,34 @@ var grid = $('.grid-stack').data('gridstack');
380382
grid.makeWidget('gsi-1');
381383
```
382384

383-
### minWidth(el, val)
385+
### maxHeight(el, val)
384386

385-
Set the minWidth for a widget.
387+
Set the `maxHeight` for a widget.
386388

387389
- `el` - widget to modify.
388-
- `val` - A numeric value of the number of columns
390+
- `val` - A numeric value of the number of rows
389391

390392
### minHeight(el, val)
391393

392-
Set the minHeight for a widget.
394+
Set the `minHeight` for a widget.
393395

394396
- `el` - widget to modify.
395397
- `val` - A numeric value of the number of rows
396398

399+
### maxWidth(el, val)
400+
401+
Set the `maxWidth` for a widget.
402+
403+
- `el` - widget to modify.
404+
- `val` - A numeric value of the number of columns
405+
406+
### minWidth(el, val)
407+
408+
Set the `minWidth` for a widget.
409+
410+
- `el` - widget to modify.
411+
- `val` - A numeric value of the number of columns
412+
397413
### movable(el, val)
398414

399415
Enables/Disables moving.
@@ -787,8 +803,9 @@ Changes
787803

788804
#### v0.2.5-dev (Development version)
789805

790-
- `cell_height` and `vertical_margin` can now be string (e.g. '3em', '20px') (Thanks to @jlowcs)
791806
- update names to respect js naming convention
807+
- `cellHeight` and `verticalMargin` can now be string (e.g. '3em', '20px') (Thanks to @jlowcs)
808+
- add `maxWidth`/`maxHeight` methods.
792809

793810
#### v0.2.4 (2016-02-15)
794811

dist/gridstack.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,23 @@
991991
return this;
992992
};
993993

994+
GridStack.prototype.maxHeight = function(el, val) {
995+
el = $(el);
996+
el.each(function(index, el) {
997+
el = $(el);
998+
var node = el.data('_gridstack_node');
999+
if (typeof node == 'undefined' || node == null) {
1000+
return;
1001+
}
1002+
1003+
if (!isNaN(val)) {
1004+
node.maxHeight = (val || false);
1005+
el.attr('data-gs-max-height', val);
1006+
}
1007+
});
1008+
return this;
1009+
};
1010+
9941011
GridStack.prototype.minHeight = function(el, val) {
9951012
el = $(el);
9961013
el.each(function(index, el) {
@@ -1008,6 +1025,23 @@
10081025
return this;
10091026
};
10101027

1028+
GridStack.prototype.maxWidth = function(el, val) {
1029+
el = $(el);
1030+
el.each(function(index, el) {
1031+
el = $(el);
1032+
var node = el.data('_gridstack_node');
1033+
if (typeof node == 'undefined' || node == null) {
1034+
return;
1035+
}
1036+
1037+
if (!isNaN(val)) {
1038+
node.maxWidth = (val || false);
1039+
el.attr('data-gs-max-width', val);
1040+
}
1041+
});
1042+
return this;
1043+
};
1044+
10111045
GridStack.prototype.minWidth = function(el, val) {
10121046
el = $(el);
10131047
el.each(function(index, el) {

0 commit comments

Comments
 (0)