forked from MapComplete/MapComplete
Some work on stabilizing the popups, WIP
This commit is contained in:
parent
8f8ef690a4
commit
1f4b06ae55
5 changed files with 55 additions and 44 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue