From 65c12bc7169a240bf9aa3f67fd3123ab0eeaf85a Mon Sep 17 00:00:00 2001 From: a2nr Date: Wed, 15 Apr 2026 20:03:36 +0700 Subject: [PATCH] remove reset button, move auto save indicator in velxio --- .../lib/components/CrosshairOverlay.svelte | 21 ++++++--- .../src/routes/lesson/[slug]/+page.svelte | 43 +++++++++---------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/frontend/src/lib/components/CrosshairOverlay.svelte b/frontend/src/lib/components/CrosshairOverlay.svelte index 3333c9b..ff65feb 100644 --- a/frontend/src/lib/components/CrosshairOverlay.svelte +++ b/frontend/src/lib/components/CrosshairOverlay.svelte @@ -27,7 +27,8 @@ const LONG_PRESS_MS = 400; const DOUBLE_TAP_MS = 300; const HOLDING_TIMEOUT_MS = 5000; - const CURSOR_OFFSET_Y = -(parseInt(env.PUBLIC_CURSOR_OFFSET_Y || '50', 10)); + const BASE_OFFSET_Y = -(parseInt(env.PUBLIC_CURSOR_OFFSET_Y || '50', 10)); + let currentOffset = $derived(isTouchDevice ? BASE_OFFSET_Y : 0); /** * State machine: @@ -46,12 +47,18 @@ $effect(() => { if (typeof window === 'undefined') return; const mql = window.matchMedia('(hover: none) and (pointer: coarse)'); - isTouchDevice = mql.matches; - const handler = (e: MediaQueryListEvent) => { - isTouchDevice = e.matches; + const checkTouch = () => { + isTouchDevice = mql.matches && window.innerWidth < 768; + }; + + checkTouch(); + mql.addEventListener('change', checkTouch); + window.addEventListener('resize', checkTouch); + + return () => { + mql.removeEventListener('change', checkTouch); + window.removeEventListener('resize', checkTouch); }; - mql.addEventListener('change', handler); - return () => mql.removeEventListener('change', handler); }); function getIframeTarget(x: number, y: number): Element | null { @@ -142,7 +149,7 @@ if (!overlayEl) return; const rect = overlayEl.getBoundingClientRect(); crosshairX = viewportX - rect.left; - crosshairY = viewportY - rect.top + CURSOR_OFFSET_Y; + crosshairY = viewportY - rect.top + currentOffset; } function getCrosshairViewport(): { x: number; y: number } { diff --git a/frontend/src/routes/lesson/[slug]/+page.svelte b/frontend/src/routes/lesson/[slug]/+page.svelte index e0183c4..64b5dd1 100644 --- a/frontend/src/routes/lesson/[slug]/+page.svelte +++ b/frontend/src/routes/lesson/[slug]/+page.svelte @@ -101,7 +101,7 @@ // Auto-save Velxio state periodically $effect(() => { - if (velxioReady && auth.isLoggedIn && !showSolution) { + if (velxioReady && $authLoggedIn && !showSolution) { const interval = setInterval(() => { const state = getVelxioState(); if (!state) return; @@ -921,17 +921,14 @@ Hubungi guru jika masalah berlanjut. {:else} -
- - {#if auth.isLoggedIn} -
- - {velxioSaving ? '●' : '☁'} - - Auto-save -
- {/if} -
+ {#if $authLoggedIn} +
+ + {velxioSaving ? '●' : '☁'} + + Auto-save +
+ {/if}