Skip to content

Commit

Permalink
clear opening timeout when closing
Browse files Browse the repository at this point in the history
  • Loading branch information
Kakadus committed Jul 7, 2024
1 parent 8d4fed9 commit b292222
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion evap/static/ts/src/infobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class InfoboxLogic {
private readonly infobox: HTMLDivElement;
private readonly closeButton: HTMLButtonElement;
private readonly storageKey: string;
private timeout?: number;

constructor(infobox_id: string) {
this.infobox = selectOrError("#infobox-" + infobox_id);
Expand All @@ -18,6 +19,7 @@ export class InfoboxLogic {
this.closeButton.addEventListener("click", event => {
this.infobox.classList.add("closing");
this.infobox.classList.remove("opening");
clearTimeout(this.timeout);
setTimeout(() => {
this.infobox.classList.replace("closing", "closed");
}, OPEN_CLOSE_TIMEOUT);
Expand All @@ -29,7 +31,7 @@ export class InfoboxLogic {
this.infobox.addEventListener("click", _ => {
if (this.infobox.className.includes("closed")) {
this.infobox.classList.replace("closed", "opening");
setTimeout(() => {
this.timeout = setTimeout(() => {
this.infobox.classList.remove("opening");
}, OPEN_CLOSE_TIMEOUT);
localStorage[this.storageKey] = "show";
Expand Down
7 changes: 6 additions & 1 deletion evap/static/ts/tsconfig.compile.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"rootDir": "./src",
"outDir": "../../static/js",
"incremental": true,
"tsBuildInfoFile": ".tsbuildinfo.json"
"tsBuildInfoFile": ".tsbuildinfo.json",
"types": [
"bootstrap",
"jquery",
"sortablejs"
]
},
"include": ["src/**/*.ts"]
}

0 comments on commit b292222

Please sign in to comment.