add update method
This commit is contained in:
parent
8cb3098d00
commit
8747785ba0
2 changed files with 23 additions and 0 deletions
12
README.md
12
README.md
|
|
@ -39,6 +39,7 @@ Inspired by [gridster.js](http://gridster.net). Built with love.
|
|||
- [move(el, x, y)](#moveel-x-y)
|
||||
- [resizable(el, val)](#resizableel-val)
|
||||
- [movable(el, val)](#movableel-val)
|
||||
- [update(el, x, y, width, height)](#updateel-x-y-width-height)
|
||||
- [will_it_fit(x, y, width, height, auto_position)](#will_it_fitx-y-width-height-auto_position)
|
||||
- [Utils](#utils)
|
||||
- [GridStackUI.Utils.sort(nodes, dir, width)](#gridstackuiutilssortnodes-dir-width)
|
||||
|
|
@ -313,6 +314,16 @@ Enables/Disables moving.
|
|||
- `el` - widget to modify
|
||||
- `val` - if `true` widget will be draggable.
|
||||
|
||||
### update(el, x, y, width, height)
|
||||
|
||||
Parameters:
|
||||
|
||||
- `el` - widget to move
|
||||
- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored.
|
||||
- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored.
|
||||
|
||||
Updates widget position/size.
|
||||
|
||||
### will_it_fit(x, y, width, height, auto_position)
|
||||
|
||||
Returns `true` if the `height` of the grid will be less the vertical constraint. Always returns `true` if grid doesn't
|
||||
|
|
@ -605,6 +616,7 @@ Changes
|
|||
|
||||
#### v0.2.3 (development version)
|
||||
|
||||
- add `update` method
|
||||
- allow to override `resizable`/`draggable` options
|
||||
- add `disable`/`enable` methods
|
||||
- add `get_cell_from_pixel` (thanks to @juchi)
|
||||
|
|
|
|||
|
|
@ -751,6 +751,17 @@
|
|||
});
|
||||
};
|
||||
|
||||
GridStack.prototype.update = function (el, x, y, width, height) {
|
||||
this._update_element(el, function (el, node) {
|
||||
x = (x != null && typeof x != 'undefined') ? x : node.x;
|
||||
y = (y != null && typeof y != 'undefined') ? y : node.y;
|
||||
width = (width != null && typeof width != 'undefined') ? width : node.width;
|
||||
height = (height != null && typeof height != 'undefined') ? height : node.height;
|
||||
|
||||
this.grid.move_node(node, x, y, width, height);
|
||||
});
|
||||
};
|
||||
|
||||
GridStack.prototype.cell_height = function (val) {
|
||||
if (typeof val == 'undefined') {
|
||||
return this.opts.cell_height;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue