mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
some more functions
This commit is contained in:
@@ -18,6 +18,8 @@ export class DivManager extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
this.#reset();
|
||||
// INFO: we do this to avoid binding issues with the event listener
|
||||
this.boundHandleClickOutside = this.handleClickOutside.bind(this);
|
||||
}
|
||||
|
||||
#reset() {
|
||||
@@ -88,8 +90,17 @@ export class DivManager extends HTMLElement {
|
||||
|
||||
if (this._menu.classList.contains(TAILWIND_HIDDEN_CLASS)) {
|
||||
this._menu.classList.remove(TAILWIND_HIDDEN_CLASS);
|
||||
document.addEventListener("click", this.handleClickOutside);
|
||||
} else {
|
||||
this._menu.classList.add(TAILWIND_HIDDEN_CLASS);
|
||||
document.removeEventListener("click", this.handleClickOutside);
|
||||
}
|
||||
}
|
||||
|
||||
handleClickOutside(event) {
|
||||
if (!this._menu) return;
|
||||
if (!this._menu.contains(event.target) && !this._button.contains(event.target)) {
|
||||
this._menu.classList.add(TAILWIND_HIDDEN_CLASS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user