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

Skip to content

Add an API to set minWidth and minHeight to a node #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Inspired by [gridster.js](http://gridster.net). Built with love.
- [get_cell_from_pixel(position)](#get_cell_from_pixelposition)
- [is_area_empty(x, y, width, height)](#is_area_emptyx-y-width-height)
- [locked(el, val)](#lockedel-val)
- [min_width(el, val)](#min_widthel-val)
- [min_height(el, val)](#min_heightel-val)
- [remove_widget(el, detach_node)](#remove_widgetel-detach_node)
- [remove_all()](#remove_all)
- [resize(el, width, height)](#resizeel-width-height)
Expand Down Expand Up @@ -292,6 +294,20 @@ Locks/unlocks widget.
- `el` - widget to modify.
- `val` - if `true` widget will be locked.

### min_width(el, val)

Set the minWidth for a widget.

- `el` - widget to modify.
- `val` - A numeric value of the number of columns

### min_height(el, val)

Set the minHeight for a widget.

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

### remove_widget(el, detach_node)

Removes widget from the grid.
Expand Down
34 changes: 34 additions & 0 deletions src/gridstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,40 @@
return this;
};

GridStack.prototype.min_height = function (el, val) {
el = $(el);
el.each(function (index, el) {
el = $(el);
var node = el.data('_gridstack_node');
if (typeof node == 'undefined' || node == null) {
return;
}

if(!isNaN(val)){
node.min_height = (val || false);
el.attr('data-gs-min-height', val);
}
});
return this;
};

GridStack.prototype.min_width = function (el, val) {
el = $(el);
el.each(function (index, el) {
el = $(el);
var node = el.data('_gridstack_node');
if (typeof node == 'undefined' || node == null) {
return;
}

if(!isNaN(val)){
node.min_width = (val || false);
el.attr('data-gs-min-width', val);
}
});
return this;
};

GridStack.prototype._update_element = function(el, callback) {
el = $(el).first();
var node = el.data('_gridstack_node');
Expand Down