From 680e82a76234012e71468d07b53a4585ec67d60f Mon Sep 17 00:00:00 2001 From: rei1024 Date: Thu, 3 Oct 2024 14:40:42 +0900 Subject: [PATCH] feat: end full screen --- src/main.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 3c43d1f..71b9134 100644 --- a/src/main.ts +++ b/src/main.ts @@ -191,10 +191,17 @@ colorInput.addEventListener("input", () => { }); const fullScreen = document.querySelector("#full-screen") as HTMLElement; -if (document.body.requestFullscreen) { +if (document.fullscreenEnabled) { fullScreen.addEventListener("click", () => { - document.body.requestFullscreen(); - settingsDialog.close(); + if (document.fullscreenElement) { + document.exitFullscreen(); + settingsDialog.close(); + fullScreen.textContent = "Full Screen"; + } else { + document.body.requestFullscreen(); + settingsDialog.close(); + fullScreen.textContent = "End Full Screen"; + } }); } else { fullScreen.remove();