Transitions never actually animated: Svelte scopes @keyframes names but does NOT rewrite animation references in inline style attributes, so the inline 'animation: crossfade-in ...' never matched its scoped keyframe — a hard cut, no fade (Ken Burns' zoom was dead too). Move the animation into scoped classes and pass dynamic values via CSS custom properties. - Real two-layer crossfade: hold the outgoing frame opaque beneath the incoming one (which is decode-gated), so there's no black flash and no decode pop. - New slide transitions (from below/left/right) as one reusable component; the previous frame is pushed off the opposite edge in step (a conveyor/push), easeInOutSine 1s. - Fullscreen toggle button (Fullscreen API) + 'f' shortcut; Esc in fullscreen no longer also navigates away. - Controls now reveal on pointer/keyboard activity and fade when idle (cursor hides too) instead of being always visible. - wakelock: null the sentinel on the OS 'release' event so re-acquire-on-visible actually fires (previously the screen could sleep after the tab was first hidden). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
46 lines
1.4 KiB
Svelte
46 lines
1.4 KiB
Svelte
<script lang="ts">
|
|
// Simplest transition: render whatever the parent gave us, full-bleed, with a CSS
|
|
// opacity fade. Tied to the parent's `{#key}` block — when the src changes, the
|
|
// parent re-mounts this component and the `in:` transition runs.
|
|
|
|
interface Props {
|
|
src: string;
|
|
isVideo: boolean;
|
|
durationMs: number;
|
|
/** Fired when a video slide finishes so the parent can advance early. */
|
|
onended?: () => void;
|
|
}
|
|
|
|
let { src, isVideo, durationMs, onended }: Props = $props();
|
|
</script>
|
|
|
|
<!-- The fade lives in a scoped class (not an inline `style="animation:…"`): Svelte scopes
|
|
`@keyframes` names and only rewrites `animation` references inside this <style> block —
|
|
an inline animation name stays unscoped and silently never matches, so the fade would
|
|
never run. The dynamic duration is passed through as a CSS custom property instead. -->
|
|
<div
|
|
class="slide absolute inset-0 flex items-center justify-center bg-black"
|
|
style="--fade-dur: {durationMs}ms"
|
|
>
|
|
{#if isVideo}
|
|
<!-- svelte-ignore a11y_media_has_caption -->
|
|
<video {src} autoplay muted playsinline {onended} class="h-full w-full object-contain"></video>
|
|
{:else}
|
|
<img {src} alt="" class="h-full w-full object-contain" />
|
|
{/if}
|
|
</div>
|
|
|
|
<style>
|
|
.slide {
|
|
animation: crossfade-in var(--fade-dur, 400ms) ease-out forwards;
|
|
}
|
|
@keyframes crossfade-in {
|
|
from {
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
}
|
|
}
|
|
</style>
|