Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b73939

Browse files
committed
Add a API to set minWidth and minHeight to a node
1 parent 0a58260 commit 5b73939

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Inspired by [gridster.js](http://gridster.net). Built with love.
3636
- [get_cell_from_pixel(position)](#get_cell_from_pixelposition)
3737
- [is_area_empty(x, y, width, height)](#is_area_emptyx-y-width-height)
3838
- [locked(el, val)](#lockedel-val)
39+
- [min_width(el, val)](#min_widthel-val)
40+
- [min_height(el, val)](#min_heightel-val)
3941
- [remove_widget(el, detach_node)](#remove_widgetel-detach_node)
4042
- [remove_all()](#remove_all)
4143
- [resize(el, width, height)](#resizeel-width-height)
@@ -292,6 +294,20 @@ Locks/unlocks widget.
292294
- `el` - widget to modify.
293295
- `val` - if `true` widget will be locked.
294296

297+
### min_width(el, val)
298+
299+
Set the minWidth for a widget.
300+
301+
- `el` - widget to modify.
302+
- `val` - A numeric value of the number of columns
303+
304+
### min_height(el, val)
305+
306+
Set the minHeight for a widget.
307+
308+
- `el` - widget to modify.
309+
- `val` - A numeric value of the number of rows
310+
295311
### remove_widget(el, detach_node)
296312

297313
Removes widget from the grid.

src/gridstack.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,40 @@
797797
return this;
798798
};
799799

800+
GridStack.prototype.min_height = function (el, val) {
801+
el = $(el);
802+
el.each(function (index, el) {
803+
el = $(el);
804+
var node = el.data('_gridstack_node');
805+
if (typeof node == 'undefined' || node == null) {
806+
return;
807+
}
808+
809+
if(!isNaN(val)){
810+
node.min_height = (val || false);
811+
el.attr('data-gs-min-height', val);
812+
}
813+
});
814+
return this;
815+
};
816+
817+
GridStack.prototype.min_width = function (el, val) {
818+
el = $(el);
819+
el.each(function (index, el) {
820+
el = $(el);
821+
var node = el.data('_gridstack_node');
822+
if (typeof node == 'undefined' || node == null) {
823+
return;
824+
}
825+
826+
if(!isNaN(val)){
827+
node.min_width = (val || false);
828+
el.attr('data-gs-min-width', val);
829+
}
830+
});
831+
return this;
832+
};
833+
800834
GridStack.prototype._update_element = function(el, callback) {
801835
el = $(el).first();
802836
var node = el.data('_gridstack_node');

0 commit comments

Comments
 (0)