add is_area_empty API method

This commit is contained in:
Pavel Reznikov 2015-03-08 22:45:14 -07:00
commit 94b4889eb7
4 changed files with 20 additions and 2 deletions

View file

@ -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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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;