Follow feature completed

This commit is contained in:
Pax1601
2023-04-19 10:19:56 +02:00
parent cfd98e74ea
commit f24c57cc18
10 changed files with 117 additions and 77 deletions

View File

@@ -0,0 +1,26 @@
import { Panel } from "../panels/panel";
export class Popup extends Panel {
#fadeTime: number = 2000; // Milliseconds
#hideTimer: number | undefined = undefined;
#visibilityTimer: number | undefined = undefined;
setFadeTime(fadeTime: number) {
this.#fadeTime = fadeTime;
}
setText(text: string) {
(<HTMLElement> this.getElement().querySelector("div")).innerText = text;
this.show();
this.getElement().classList.remove("invisible");
this.getElement().classList.add("visible");
clearTimeout(this.#visibilityTimer);
clearTimeout(this.#hideTimer);
this.#visibilityTimer = setTimeout(() => {
this.getElement().classList.remove("visible");
this.getElement().classList.add("invisible");
this.#hideTimer = setTimeout(() => this.hide(), 2000);
}, this.#fadeTime);
}
}