diff --git a/src/lib/Main.svelte b/src/lib/Main.svelte index 5a4c825..13cfad6 100644 --- a/src/lib/Main.svelte +++ b/src/lib/Main.svelte @@ -458,6 +458,7 @@ {/each} @@ -465,6 +466,7 @@ {/if} @@ -532,11 +534,9 @@ - {@const displayPath = dragging && trimPreviewPath ? trimPreviewPath : previewPath} - {@const displayBust = dragging && trimPreviewPath ? trimPreviewBust : previewCacheBust} - {#if displayPath} + {#if (dragging && trimPreviewPath ? trimPreviewPath : previewPath)}
- + {#if previewLoading && !dragging}
rendering
{/if} {#if dragging}
original
{/if}
diff --git a/src/lib/Overlay.svelte b/src/lib/Overlay.svelte index adbfd31..f2032f9 100644 --- a/src/lib/Overlay.svelte +++ b/src/lib/Overlay.svelte @@ -13,10 +13,9 @@ let fps: number = $state(30) let elapsed: number = $state(0) let timer: number | null = null - let lockedRatio: number | null = null - let resizeDebounce: number | null = null - let enforcing = false - let resizing = false + let lockedRatio: number | null = $state(null) + let enforceTimer: number | null = null + let skipEnforce = false onMount(() => { const updateSize = async () => { @@ -25,28 +24,31 @@ width = Math.round(sz.width / sf) height = Math.round(sz.height / sf) } - // Query aspect ratio from Rust on startup - const syncRatio = async () => { - try { lockedRatio = await invoke("get_overlay_aspect") } catch {} - } + updateSize() - syncRatio() + // Get initial ratio + invoke("get_overlay_aspect").then(r => { lockedRatio = r }).catch(() => {}) + let cleanup: (() => void)[] = [] + // Listen for ratio changes from Main window via event + listen<{ ratio: number | null }>("overlay-set-ratio", (e) => { + lockedRatio = e.payload.ratio + }).then(fn => cleanup.push(fn)) + win.onResized(async () => { - if (enforcing) return + if (skipEnforce) return await updateSize() - // Re-sync ratio from Rust in case it changed (e.g. preset clicked) - await syncRatio() if (lockedRatio === null) return - // Small debounce to break the SetWindowPos → onResized loop - if (resizeDebounce !== null) clearTimeout(resizeDebounce) - resizeDebounce = window.setTimeout(async () => { - enforcing = true + // Debounce: only enforce after resize settles (user released mouse) + if (enforceTimer !== null) clearTimeout(enforceTimer) + enforceTimer = window.setTimeout(async () => { + skipEnforce = true try { await invoke("enforce_overlay_aspect") } catch {} await updateSize() - enforcing = false - }, 30) + // Skip events from our own enforcement for a bit + setTimeout(() => { skipEnforce = false }, 100) + }, 200) }).then(fn => cleanup.push(fn)) listen<{ phase: "idle"|"recording"|"paused"; fps: number }>( @@ -74,7 +76,7 @@ return () => { stopTimer() - if (resizeDebounce !== null) clearTimeout(resizeDebounce) + if (enforceTimer !== null) clearTimeout(enforceTimer) cleanup.forEach(fn => fn()) } }) @@ -104,6 +106,7 @@