@energy8platform/game-engine 0.14.1 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -3151,6 +3151,7 @@ class FlexContainer extends pixi_js.Container {
3151
3151
  /** @internal */ _rawHeight;
3152
3152
  _layoutChildren = [];
3153
3153
  _layoutDirty = true;
3154
+ _layoutSuspended = false;
3154
3155
  constructor(config = {}) {
3155
3156
  super();
3156
3157
  this._config = {
@@ -3212,7 +3213,19 @@ class FlexContainer extends pixi_js.Container {
3212
3213
  }
3213
3214
  }
3214
3215
  const result = super.addChild(...children);
3215
- if (this._layoutDirty)
3216
+ if (this._layoutDirty && !this._layoutSuspended)
3217
+ this.updateLayout();
3218
+ return result;
3219
+ }
3220
+ addChildAt(child, index) {
3221
+ if (!this._layoutChildren.includes(child)) {
3222
+ // Insert into layout children at matching position
3223
+ const layoutIndex = Math.min(index, this._layoutChildren.length);
3224
+ this._layoutChildren.splice(layoutIndex, 0, child);
3225
+ this._layoutDirty = true;
3226
+ }
3227
+ const result = super.addChildAt(child, index);
3228
+ if (this._layoutDirty && !this._layoutSuspended)
3216
3229
  this.updateLayout();
3217
3230
  return result;
3218
3231
  }
@@ -3230,12 +3243,23 @@ class FlexContainer extends pixi_js.Container {
3230
3243
  get flexChildren() {
3231
3244
  return this._layoutChildren;
3232
3245
  }
3246
+ /** Suspend automatic layout recalculation. Call resumeLayout() to flush. */
3247
+ suspendLayout() {
3248
+ this._layoutSuspended = true;
3249
+ }
3250
+ /** Resume automatic layout and flush if dirty. */
3251
+ resumeLayout() {
3252
+ this._layoutSuspended = false;
3253
+ if (this._layoutDirty)
3254
+ this.updateLayout();
3255
+ }
3233
3256
  /** Update the container size and recalculate layout */
3234
3257
  resize(width, height) {
3235
3258
  this._explicitWidth = width;
3236
3259
  this._explicitHeight = height;
3237
3260
  this._layoutDirty = true;
3238
- this.updateLayout();
3261
+ if (!this._layoutSuspended)
3262
+ this.updateLayout();
3239
3263
  }
3240
3264
  /** Update layout direction */
3241
3265
  setDirection(direction) {
@@ -3268,6 +3292,10 @@ class FlexContainer extends pixi_js.Container {
3268
3292
  * adding/removing children without resize.
3269
3293
  */
3270
3294
  updateLayout() {
3295
+ if (this._layoutSuspended) {
3296
+ this._layoutDirty = true;
3297
+ return;
3298
+ }
3271
3299
  this._layoutDirty = false;
3272
3300
  const { direction, justifyContent, alignItems, gap, flexWrap, alignContent } = this._config;
3273
3301
  const [pt, pr, pb, pl] = this._padding;
@@ -3476,11 +3504,12 @@ class FlexContainer extends pixi_js.Container {
3476
3504
  this._explicitWidth = typeof w === 'number' ? w : 0;
3477
3505
  this._explicitHeight = typeof h === 'number' ? h : 0;
3478
3506
  this._layoutDirty = true;
3479
- this.updateLayout();
3507
+ if (!this._layoutSuspended)
3508
+ this.updateLayout();
3480
3509
  }
3481
3510
  return;
3482
3511
  }
3483
- if (this._layoutDirty)
3512
+ if (this._layoutDirty && !this._layoutSuspended)
3484
3513
  this.updateLayout();
3485
3514
  }
3486
3515
  destroy(options) {
@@ -4063,6 +4092,14 @@ class Panel extends pixi_js.Container {
4063
4092
  get content() {
4064
4093
  return this._content;
4065
4094
  }
4095
+ /** Suspend content layout recalculation. Call resumeLayout() to flush. */
4096
+ suspendLayout() {
4097
+ this._content.suspendLayout();
4098
+ }
4099
+ /** Resume content layout and flush if dirty. */
4100
+ resumeLayout() {
4101
+ this._content.resumeLayout();
4102
+ }
4066
4103
  /** Convenience: add a child to the content layout */
4067
4104
  addContent(child) {
4068
4105
  this._content.addFlexChild(child);