Skip to content

Commit

Permalink
fix styles visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberDex committed Sep 3, 2023
1 parent 1c56f47 commit 48b2bf0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
34 changes: 19 additions & 15 deletions src/controllers/StyleController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class StyleController
if (styles)
{
this.set(styles);
this.applyConditionalStyles();
}
}

Expand Down Expand Up @@ -125,7 +124,7 @@ export class StyleController

this.styles.aspectRatio = styles?.aspectRatio ?? this.styles.aspectRatio ?? 'static';

this.styles.visible = styles?.visible ?? this.styles.visible ?? true;
this.visible = styles?.visible ?? this.styles.visible ?? true;

this._textStyle = stylesToPixiTextStyles(styles);

Expand Down Expand Up @@ -166,24 +165,29 @@ export class StyleController
return this.styles.opacity;
}

/** Set visibility of the layout */
set visible(value: boolean)
{
this.layout.container.visible = value;
}

/** Returns visibility of the layout */
get visible(): boolean
{
return this.layout.container.visible;
}

/** Checks and applies conditional styles basing on parent size */
applyConditionalStyles()
{
if (!this.hasConditionalStyles) return;

let finalStyles = { ...this.defaultStyles };

if (this.conditionalStyles.portrait && this.layout.isRootLayoutPortrait)
{
finalStyles = { ...finalStyles, ...this.conditionalStyles.portrait };
}

if (this.conditionalStyles.landscape && !this.layout.isRootLayoutPortrait)
{
finalStyles = { ...finalStyles, ...this.conditionalStyles.landscape };
}

this.set(finalStyles);
this.set({
...this.defaultStyles,
...this.layout.isRootLayoutPortrait
? this.conditionalStyles.portrait
: this.conditionalStyles.landscape
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class LayoutStory
},
});

this.resize(this.w, this.h);

this.view.addChild(this.layout);
}

Expand Down
1 change: 0 additions & 1 deletion src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export type Styles = Partial<TextStyle> & {
anchorY?: GradeToOne;
aspectRatio?: AspectRatio;
wordWrap?: boolean;
visible?: boolean;
};

export type LayoutStyles = {
Expand Down

0 comments on commit 48b2bf0

Please sign in to comment.