add batch_update/commit methods
This commit is contained in:
parent
8747785ba0
commit
ec6e6f5421
2 changed files with 43 additions and 0 deletions
|
|
@ -67,6 +67,23 @@
|
|||
|
||||
this.nodes = items || [];
|
||||
this.onchange = onchange || function () {};
|
||||
|
||||
this._update_counter = 0;
|
||||
this._float = this.float;
|
||||
};
|
||||
|
||||
GridStackEngine.prototype.batch_update = function () {
|
||||
this._update_counter = 1;
|
||||
this.float = true;
|
||||
};
|
||||
|
||||
GridStackEngine.prototype.commit = function () {
|
||||
this._update_counter = 0;
|
||||
if (this._update_counter == 0) {
|
||||
this.float = this._float;
|
||||
this._pack_nodes();
|
||||
this._notify();
|
||||
}
|
||||
};
|
||||
|
||||
GridStackEngine.prototype._fix_collisions = function (node) {
|
||||
|
|
@ -188,6 +205,9 @@
|
|||
};
|
||||
|
||||
GridStackEngine.prototype._notify = function () {
|
||||
if (this._update_counter) {
|
||||
return;
|
||||
}
|
||||
var deleted_nodes = Array.prototype.slice.call(arguments, 1).concat(this.get_dirty_nodes());
|
||||
deleted_nodes = deleted_nodes.concat(this.get_dirty_nodes());
|
||||
this.onchange(deleted_nodes);
|
||||
|
|
@ -502,6 +522,9 @@
|
|||
};
|
||||
|
||||
GridStack.prototype._update_container_height = function () {
|
||||
if (this.grid._update_counter) {
|
||||
return;
|
||||
}
|
||||
this.container.height(this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) - this.opts.vertical_margin);
|
||||
};
|
||||
|
||||
|
|
@ -789,6 +812,15 @@
|
|||
return {x: Math.floor(relativeLeft / column_width), y: Math.floor(relativeTop / row_height)};
|
||||
};
|
||||
|
||||
GridStack.prototype.batch_update = function () {
|
||||
this.grid.batch_update();
|
||||
};
|
||||
|
||||
GridStack.prototype.commit = function () {
|
||||
this.grid.commit();
|
||||
this._update_container_height()
|
||||
};
|
||||
|
||||
scope.GridStackUI = GridStack;
|
||||
|
||||
scope.GridStackUI.Utils = Utils;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue