From 59f00a30bf6f6d5db00b8e9978a7e85ac12a4559 Mon Sep 17 00:00:00 2001 From: Pihkaal Date: Mon, 16 Feb 2026 12:19:49 +0100 Subject: [PATCH] feat(nds): fullscreen button --- app/assets/app.css | 1 + app/pages/index.vue | 75 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/app/assets/app.css b/app/assets/app.css index c37c484..9050fd3 100644 --- a/app/assets/app.css +++ b/app/assets/app.css @@ -41,6 +41,7 @@ body { background: #000000; + overflow: hidden; } @theme { diff --git a/app/pages/index.vue b/app/pages/index.vue index 200b2f1..b059305 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -12,6 +12,43 @@ const bottomScreen = useTemplateRef("bottomScreen"); const topScreenCanvas = computed(() => topScreen.value?.canvas ?? null); const bottomScreenCanvas = computed(() => bottomScreen.value?.canvas ?? null); + +const isIOS = () => /iPad|iPhone|iPod/.test(navigator.userAgent); +const isTouchDevice = () => + "ontouchstart" in window || navigator.maxTouchPoints > 0; + +const showFullscreenBtn = ref(true); + +const toggleFullscreen = () => { + if (document.fullscreenElement) { + document.exitFullscreen(); + } else { + document.documentElement.requestFullscreen(); + } +}; + +onMounted(() => { + if (isIOS()) { + showFullscreenBtn.value = false; + return; + } + + if (!isTouchDevice()) return; + + const landscape = window.matchMedia("(orientation: landscape)"); + + const onOrientationChange = (e: MediaQueryListEvent | MediaQueryList) => { + if (e.matches && !document.fullscreenElement) { + document.documentElement.requestFullscreen().catch(() => {}); + } + }; + + landscape.addEventListener("change", onOrientationChange); + + onUnmounted(() => { + landscape.removeEventListener("change", onOrientationChange); + }); +}); + + + +