From 7d688535dde593ceaa794d9925fc911c10e9f832 Mon Sep 17 00:00:00 2001 From: Dmytro Soldatov Date: Sun, 17 Dec 2023 16:44:26 +0200 Subject: [PATCH] fix issues --- src/Layout.ts | 6 +++--- src/controllers/AlignController.ts | 16 ++++++++-------- src/controllers/ContentController.ts | 17 +++++++++-------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Layout.ts b/src/Layout.ts index 9b4e955..ba679ad 100644 --- a/src/Layout.ts +++ b/src/Layout.ts @@ -291,8 +291,6 @@ export class LayoutSystem */ export class Layout extends Container { - override layout: LayoutSystem; - /** * Creates layout container. * @param options @@ -301,7 +299,7 @@ export class Layout extends Container { super(); - this.layout = new LayoutSystem(options, this); + this.initLayout(options); } /** Get {@link SizeController} */ @@ -442,6 +440,7 @@ declare module '@pixi/display' { initLayout(config?: LayoutOptions): Container; layout?: LayoutSystem; + isPixiLayout?: boolean; } } @@ -453,6 +452,7 @@ if (!Container.prototype.initLayout) if (!this.layout) { this.layout = new LayoutSystem(options, this); + this.isPixiLayout = true; } return this; diff --git a/src/controllers/AlignController.ts b/src/controllers/AlignController.ts index 9ed31a5..d8a38e5 100644 --- a/src/controllers/AlignController.ts +++ b/src/controllers/AlignController.ts @@ -119,17 +119,17 @@ export class AlignController let childMarginTop = 0; let childMarginBottom = 0; - if (child instanceof Layout) + if (child.isPixiLayout) { - childDisplay = child.style.display; - const childPosition = child.style.position; + const childLayout = child.layout as LayoutSystem; - childMarginLeft = child.style.marginLeft; - childMarginRight = child.style.marginRight; - childMarginTop = child.style.marginTop; - childMarginBottom = child.style.marginBottom; + childDisplay = childLayout.style.display; + childMarginLeft = childLayout.style.marginLeft; + childMarginRight = childLayout.style.marginRight; + childMarginTop = childLayout.style.marginTop; + childMarginBottom = childLayout.style.marginBottom; - if (childPosition !== undefined) + if (childLayout.style.position !== undefined) { // this layout position will be handled by it's own controller return; diff --git a/src/controllers/ContentController.ts b/src/controllers/ContentController.ts index c074353..44fc76c 100644 --- a/src/controllers/ContentController.ts +++ b/src/controllers/ContentController.ts @@ -226,9 +226,9 @@ export class ContentController { this.children.forEach((child) => { - if (child instanceof Layout) + if (child.isPixiLayout) { - child.resize(width, height); + child.layout.resize(width, height); } }); } @@ -269,15 +269,16 @@ export class ContentController { if (typeof content === 'string') return 'string'; - if (content instanceof Layout) return 'layout'; - if (content instanceof Text) return 'text'; - if (content instanceof Sprite) return 'container'; - - if (content instanceof Graphics) return 'container'; + if (content instanceof Sprite + || content instanceof Graphics + || content instanceof Container) + { + if (content.isPixiLayout) return 'layout'; - if (content instanceof Container) return 'container'; + return 'container'; + } if (Array.isArray(content)) return 'array';