Skip to content

Commit

Permalink
auto-size content batch mode
Browse files Browse the repository at this point in the history
* fix gridstack#404
* make sure to use batch mode to improve re-layout
  • Loading branch information
adumesny committed Aug 7, 2023
1 parent 4fc6a7b commit da8ba57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gridstack-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class GridStackEngine {
if (flag) {
this._prevFloat = this._float;
this._float = true; // let things go anywhere for now... will restore and possibly reposition later
this.cleanNodes();
this.saveInitial(); // since begin update (which is called multiple times) won't do this
} else {
this._float = this._prevFloat;
Expand Down
5 changes: 5 additions & 0 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ export class GridStack {
public batchUpdate(flag = true): GridStack {
this.engine.batchUpdate(flag);
if (!flag) {
this._updateContainerHeight();
this._triggerRemoveEvent();
this._triggerAddEvent();
this._triggerChangeEvent();
Expand Down Expand Up @@ -1580,6 +1581,8 @@ export class GridStack {
this.prevWidth = this.el.clientWidth
// console.log('onResize ', this.el.clientWidth);

this.batchUpdate();

// see if we're nested and take our column count from our parent....
let columnChanged = false;
if (this._autoColumn && this.parentGridItem) {
Expand Down Expand Up @@ -1611,6 +1614,8 @@ export class GridStack {
}
});

this.batchUpdate(false);

return this;
}

Expand Down

0 comments on commit da8ba57

Please sign in to comment.