Skip to content

Commit 9b943e9

Browse files
authored
fix issues (#62)
1 parent e1d591b commit 9b943e9

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/Layout.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,6 @@ export class LayoutSystem
291291
*/
292292
export class Layout extends Container
293293
{
294-
override layout: LayoutSystem;
295-
296294
/**
297295
* Creates layout container.
298296
* @param options
@@ -301,7 +299,7 @@ export class Layout extends Container
301299
{
302300
super();
303301

304-
this.layout = new LayoutSystem(options, this);
302+
this.initLayout(options);
305303
}
306304

307305
/** Get {@link SizeController} */
@@ -442,6 +440,7 @@ declare module '@pixi/display'
442440
{
443441
initLayout(config?: LayoutOptions): Container;
444442
layout?: LayoutSystem;
443+
isPixiLayout?: boolean;
445444
}
446445
}
447446

@@ -453,6 +452,7 @@ if (!Container.prototype.initLayout)
453452
if (!this.layout)
454453
{
455454
this.layout = new LayoutSystem(options, this);
455+
this.isPixiLayout = true;
456456
}
457457

458458
return this;

src/controllers/AlignController.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ export class AlignController
119119
let childMarginTop = 0;
120120
let childMarginBottom = 0;
121121

122-
if (child instanceof Layout)
122+
if (child.isPixiLayout)
123123
{
124-
childDisplay = child.style.display;
125-
const childPosition = child.style.position;
124+
const childLayout = child.layout as LayoutSystem;
126125

127-
childMarginLeft = child.style.marginLeft;
128-
childMarginRight = child.style.marginRight;
129-
childMarginTop = child.style.marginTop;
130-
childMarginBottom = child.style.marginBottom;
126+
childDisplay = childLayout.style.display;
127+
childMarginLeft = childLayout.style.marginLeft;
128+
childMarginRight = childLayout.style.marginRight;
129+
childMarginTop = childLayout.style.marginTop;
130+
childMarginBottom = childLayout.style.marginBottom;
131131

132-
if (childPosition !== undefined)
132+
if (childLayout.style.position !== undefined)
133133
{
134134
// this layout position will be handled by it's own controller
135135
return;

src/controllers/ContentController.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ export class ContentController
226226
{
227227
this.children.forEach((child) =>
228228
{
229-
if (child instanceof Layout)
229+
if (child.isPixiLayout)
230230
{
231-
child.resize(width, height);
231+
child.layout.resize(width, height);
232232
}
233233
});
234234
}
@@ -269,15 +269,16 @@ export class ContentController
269269
{
270270
if (typeof content === 'string') return 'string';
271271

272-
if (content instanceof Layout) return 'layout';
273-
274272
if (content instanceof Text) return 'text';
275273

276-
if (content instanceof Sprite) return 'container';
277-
278-
if (content instanceof Graphics) return 'container';
274+
if (content instanceof Sprite
275+
|| content instanceof Graphics
276+
|| content instanceof Container)
277+
{
278+
if (content.isPixiLayout) return 'layout';
279279

280-
if (content instanceof Container) return 'container';
280+
return 'container';
281+
}
281282

282283
if (Array.isArray(content)) return 'array';
283284

0 commit comments

Comments
 (0)