From d2105b0ea4fb3edb0bf1a5d46d8a2f2053bf3d2e Mon Sep 17 00:00:00 2001 From: Nulo Date: Tue, 6 Jul 2021 22:13:18 +0000 Subject: [PATCH] =?UTF-8?q?Ocultar=20bot=C3=B3n=20de=20pantalla=20completa?= =?UTF-8?q?=20si=20no=20es=20posible?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main.ts b/src/main.ts index f415b80..8d45ce5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -295,12 +295,17 @@ async function initJuego() { window.requestAnimationFrame(loop); } -document.getElementById("full-screen")!.addEventListener("click", async () => { - document.documentElement.requestFullscreen && - (await document.documentElement.requestFullscreen({ - navigationUI: "hide", - })); - await screen.orientation.lock("landscape"); -}); +const fullscreenEl = document.getElementById("full-screen")!; +if ("requestFullscreen" in document.documentElement) { + fullscreenEl.addEventListener("click", async () => { + document.documentElement.requestFullscreen && + (await document.documentElement.requestFullscreen({ + navigationUI: "hide", + })); + await screen.orientation.lock("landscape"); + }); +} else { + fullscreenEl.hidden = true; +} initJuego();