From 16fc60e1f081254c6cab6d9b7cc8ef9598405841 Mon Sep 17 00:00:00 2001 From: "mr. M" Date: Wed, 30 Oct 2024 13:18:25 +0100 Subject: [PATCH] Refactor ZenGlanceManager.mjs to improve animation handling and visibility toggling --- src/ZenGlanceManager.mjs | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/ZenGlanceManager.mjs b/src/ZenGlanceManager.mjs index 576c3c3..817fc96 100644 --- a/src/ZenGlanceManager.mjs +++ b/src/ZenGlanceManager.mjs @@ -130,7 +130,7 @@ setTimeout(() => { this.browserWrapper.setAttribute("animate-end", true); this.#animating = false; - }, 500); + }, 400); }); } @@ -140,15 +140,27 @@ } if (noAnimation) { - this.overlay.setAttribute("hidden", true); - this.overlay.removeAttribute("fade-out"); - this.browserWrapper.removeAttribute("animate"); - this.browserWrapper.removeAttribute("animate-end"); - this.#currentBrowser?.remove(); - this.#currentTab?.remove(); - this.#currentBrowser = null; - this.#currentTab = null; - this.originalOverlayParent.appendChild(this.overlay); + this.overlay.style.opacity = 0; + this.overlay.visivility = "collapse"; + window.requestAnimationFrame(() => { + this.overlay.setAttribute("hidden", true); + this.overlay.removeAttribute("fade-out"); + this.browserWrapper.removeAttribute("animate"); + this.browserWrapper.removeAttribute("animate-end"); + + setTimeout(() => { + this.#currentBrowser?.remove(); + this.#currentTab?.remove(); + this.#currentBrowser = null; + this.#currentTab = null; + this.originalOverlayParent.appendChild(this.overlay); + + this.overlay.style.opacity = 1; + this.overlay.visivility = "visible"; + + this.#animating = false; + }, 500); + }); return; } @@ -205,11 +217,11 @@ setTimeout(() => { this.animatingFullOpen = false; this.closeGlance({ noAnimation: true }); - }, 400); + }, 600); }); }); }); - }, 200); + }, 300); } }