From da8ba57d495705b8d43c3be2c30a60fc7932acc7 Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Mon, 7 Aug 2023 09:25:31 -0700 Subject: [PATCH] auto-size content batch mode * fix #404 * make sure to use batch mode to improve re-layout --- src/gridstack-engine.ts | 1 + src/gridstack.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/gridstack-engine.ts b/src/gridstack-engine.ts index 986cbd7aa..a810684ea 100644 --- a/src/gridstack-engine.ts +++ b/src/gridstack-engine.ts @@ -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; diff --git a/src/gridstack.ts b/src/gridstack.ts index a6af8a2c8..b44b3a1ac 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -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(); @@ -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) { @@ -1611,6 +1614,8 @@ export class GridStack { } }); + this.batchUpdate(false); + return this; }