Refactoring fullscreenhandling

This commit is contained in:
Pieter Vander Vennet 2021-01-25 03:12:09 +01:00
parent e1a4c75391
commit 00f610c589
23 changed files with 346 additions and 245 deletions

View file

@ -1,22 +1,25 @@
import {UIElement} from "../UIElement";
export default class LazyElement extends UIElement {
export default class LazyElement<T extends UIElement> extends UIElement {
private _content: UIElement = undefined;
public Activate: (onElement?: (element: T) => void) => void;
private _content: T = undefined;
private readonly _loadingContent: string;
public Activate: () => void;
private _loadingContent: string;
constructor(content: (() => UIElement), loadingContent = "Rendering...") {
constructor(content: (() => T), loadingContent = "Rendering...") {
super();
this._loadingContent = loadingContent;
this.dumbMode = false;
const self = this;
this.Activate = () => {
this.Activate = (onElement?: (element: T) => void) => {
console.log("ACTIVATED")
if (this._content === undefined) {
self._content = content();
}
if (onElement) {
onElement(self._content)
}
self.Update();
}
}
@ -27,5 +30,7 @@ export default class LazyElement extends UIElement {
}
return this._content.InnerRender();
}
}