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

Skip to content

Commit 8747785

Browse files
committed
add update method
1 parent 8cb3098 commit 8747785

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Inspired by [gridster.js](http://gridster.net). Built with love.
3939
- [move(el, x, y)](#moveel-x-y)
4040
- [resizable(el, val)](#resizableel-val)
4141
- [movable(el, val)](#movableel-val)
42+
- [update(el, x, y, width, height)](#updateel-x-y-width-height)
4243
- [will_it_fit(x, y, width, height, auto_position)](#will_it_fitx-y-width-height-auto_position)
4344
- [Utils](#utils)
4445
- [GridStackUI.Utils.sort(nodes, dir, width)](#gridstackuiutilssortnodes-dir-width)
@@ -313,6 +314,16 @@ Enables/Disables moving.
313314
- `el` - widget to modify
314315
- `val` - if `true` widget will be draggable.
315316

317+
### update(el, x, y, width, height)
318+
319+
Parameters:
320+
321+
- `el` - widget to move
322+
- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored.
323+
- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored.
324+
325+
Updates widget position/size.
326+
316327
### will_it_fit(x, y, width, height, auto_position)
317328

318329
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
605616

606617
#### v0.2.3 (development version)
607618

619+
- add `update` method
608620
- allow to override `resizable`/`draggable` options
609621
- add `disable`/`enable` methods
610622
- add `get_cell_from_pixel` (thanks to @juchi)

src/gridstack.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,17 @@
751751
});
752752
};
753753

754+
GridStack.prototype.update = function (el, x, y, width, height) {
755+
this._update_element(el, function (el, node) {
756+
x = (x != null && typeof x != 'undefined') ? x : node.x;
757+
y = (y != null && typeof y != 'undefined') ? y : node.y;
758+
width = (width != null && typeof width != 'undefined') ? width : node.width;
759+
height = (height != null && typeof height != 'undefined') ? height : node.height;
760+
761+
this.grid.move_node(node, x, y, width, height);
762+
});
763+
};
764+
754765
GridStack.prototype.cell_height = function (val) {
755766
if (typeof val == 'undefined') {
756767
return this.opts.cell_height;

0 commit comments

Comments
 (0)