Some work on stabilizing the popups, WIP

This commit is contained in:
Pieter Vander Vennet 2021-02-05 18:58:06 +01:00
parent 8f8ef690a4
commit 1f4b06ae55
5 changed files with 55 additions and 44 deletions

View file

@ -1,24 +1,21 @@
import {UIElement} from "../UIElement";
export default class LazyElement<T extends UIElement> extends UIElement {
export default class LazyElement extends UIElement {
public Activate: (onElement?: (element: T) => void) => void;
private _content: T = undefined;
public Activate: () => void;
private _content: UIElement = undefined;
private readonly _loadingContent: string;
constructor(content: (() => T), loadingContent = "Rendering...") {
constructor(content: (() => UIElement), loadingContent = "Rendering...") {
super();
this._loadingContent = loadingContent;
this.dumbMode = false;
const self = this;
this.Activate = (onElement?: (element: T) => void) => {
this.Activate = () => {
if (this._content === undefined) {
self._content = content();
}
if (onElement) {
onElement(self._content)
}
self.Update();
}
}