add is_area_empty API method
This commit is contained in:
parent
6eb623ce70
commit
94b4889eb7
4 changed files with 20 additions and 2 deletions
|
|
@ -34,6 +34,7 @@ Inspired by [gridster.js](http://gridster.net). Built with love.
|
|||
- [disable()](#disable)
|
||||
- [enable()](#enable)
|
||||
- [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)
|
||||
- [remove_widget(el)](#remove_widgetel)
|
||||
- [remove_all()](#remove_all)
|
||||
|
|
@ -274,6 +275,10 @@ Parameters :
|
|||
|
||||
Returns an object with properties `x` and `y` i.e. the column and row in the grid.
|
||||
|
||||
### is_area_empty(x, y, width, height)
|
||||
|
||||
Checks if specified area is empty.
|
||||
|
||||
### locked(el, val)
|
||||
|
||||
Locks/unlocks widget.
|
||||
|
|
@ -634,6 +639,7 @@ Changes
|
|||
|
||||
#### v0.2.3 (development version)
|
||||
|
||||
- add `is_area_empty` method
|
||||
- nested grids
|
||||
- add `batch_update`/`commit` methods
|
||||
- add `update` method
|
||||
|
|
|
|||
2
dist/gridstack.min.js
vendored
2
dist/gridstack.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/gridstack.min.map
vendored
2
dist/gridstack.min.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -107,6 +107,14 @@
|
|||
}
|
||||
};
|
||||
|
||||
GridStackEngine.prototype.is_area_empty = function (x, y, width, height) {
|
||||
var nn = {x: x || 0, y: y || 0, width: width || 1, height: height || 1};
|
||||
var collision_node = _.find(this.nodes, function (n) {
|
||||
return Utils.is_intercepted(n, nn);
|
||||
}, this);
|
||||
return collision_node == null;
|
||||
};
|
||||
|
||||
GridStackEngine.prototype._sort_nodes = function (dir) {
|
||||
this.nodes = Utils.sort(this.nodes, dir, this.width);
|
||||
};
|
||||
|
|
@ -831,6 +839,10 @@
|
|||
this._update_container_height()
|
||||
};
|
||||
|
||||
GridStack.prototype.is_area_empty = function (x, y, width, height) {
|
||||
return this.grid.is_area_empty(x, y, width, height);
|
||||
};
|
||||
|
||||
scope.GridStackUI = GridStack;
|
||||
|
||||
scope.GridStackUI.Utils = Utils;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue