fix: spam clicking outside a popup restarts closing animation, and remove multiple close popup functions

This commit is contained in:
Jones8683
2025-11-10 16:57:14 +10:30
parent 6c5320007f
commit 9c08d0bac2
+26 -12
View File
@@ -4,22 +4,36 @@ import stringToHTML from "./stringToHTML";
import browser from "webextension-polyfill"; import browser from "webextension-polyfill";
import kofi from "@/resources/kofi.png?base64"; import kofi from "@/resources/kofi.png?base64";
export async function DeleteWhatsNew() { let isClosing = false;
const bkelement = document.getElementById("whatsnewbk");
const popup = document.getElementsByClassName("whatsnewContainer")[0];
if (!settingsState.animations) { export async function DeleteWhatsNew() {
bkelement?.remove(); if (isClosing) return;
isClosing = true;
const bkelement = document.getElementById("whatsnewbk");
const popup = document.getElementsByClassName(
"whatsnewContainer",
)[0] as HTMLElement;
if (!bkelement || !popup) {
isClosing = false;
return; return;
} }
animate( if (!settingsState.animations) {
[popup, bkelement!], bkelement.remove();
{ opacity: [1, 0], scale: [1, 0] }, isClosing = false;
{ ease: [0.22, 0.03, 0.26, 1] }, return;
).then(() => { }
bkelement?.remove();
}); await animate(
[popup, bkelement as HTMLElement],
{ opacity: [1, 0], scale: [1, 0.95] } as any,
{ duration: 0.25, ease: [0.22, 0.03, 0.26, 1] },
);
bkelement.remove();
isClosing = false;
} }
export function OpenWhatsNewPopup() { export function OpenWhatsNewPopup() {