From 4b67c94494ded98ca7deb548c1f869b167358aa3 Mon Sep 17 00:00:00 2001 From: 1xDed Date: Tue, 1 Dec 2026 11:02:11 +0300 Subject: [PATCH] feat(player): plain crossfade between covers - dropped the SVG turbulence/displacement filter entirely - the previous sleeve now simply dissolves over the next one, 0.55s ease - cover swap still waits for the new image to load --- src/routes/_api/player/audio.scss | 27 +++--------- src/routes/_api/player/audio.tsx | 71 +++---------------------------- 2 files changed, 12 insertions(+), 86 deletions(-) diff --git a/src/routes/_api/player/audio.scss b/src/routes/_api/player/audio.scss index 61a5272..9de67e7 100644 --- a/src/routes/_api/player/audio.scss +++ b/src/routes/_api/player/audio.scss @@ -124,24 +124,15 @@ object-fit: cover; } - // Both layers melt under the same turbulence filter while the old - // sleeve fades out over the new one. - &.is-melting { - filter: url(#music-liquid-filter); - - img { - transform: scale(1.02); - } - } - + // The old sleeve layers over the new one and simply fades away. &-prev { z-index: 2; - animation: cover-melt-out 0.8s ease forwards; + animation: cover-fade-out 0.55s ease forwards; } &-current { z-index: 1; - animation: cover-melt-in 0.8s cubic-bezier(0.22, 1, 0.36, 1); + animation: cover-fade-in 0.55s ease; } > .material-symbols-rounded { @@ -150,12 +141,6 @@ } } - &-liquid { - position: absolute; - width: 0; - height: 0; - } - &-meta { width: min(560px, 100%); margin-top: clamp(1.2rem, 3vh, 2rem); @@ -666,18 +651,16 @@ html.is-macos .music-player-chrome { } -@keyframes cover-melt-in { +@keyframes cover-fade-in { from { opacity: 0; - transform: scale(1.015); } to { opacity: 1; - transform: scale(1); } } -@keyframes cover-melt-out { +@keyframes cover-fade-out { from { opacity: 1; } diff --git a/src/routes/_api/player/audio.tsx b/src/routes/_api/player/audio.tsx index 9510799..7906a1b 100644 --- a/src/routes/_api/player/audio.tsx +++ b/src/routes/_api/player/audio.tsx @@ -123,20 +123,16 @@ const QueueRow = ({ ); -const MELT_MS = 800; +const COVER_FADE_MS = 600; /** - * Sleeve that melts into the next track: the previous cover stays on top while - * a turbulence + displacement filter ripples both layers, then fades away. + * Sleeve that crossfades into the next track: the previous cover stays on top + * while the next one loads, then simply dissolves over it. */ -const LiquidCover = ({ src, alt }: { src?: string; alt: string }) => { +const CoverArt = ({ src, alt }: { src?: string; alt: string }) => { const [current, setCurrent] = useState(src); const [previous, setPrevious] = useState(); - const [melting, setMelting] = useState(false); const currentRef = useRef(src); - const turbRef = useRef(null); - const dispRef = useRef(null); - const rafRef = useRef(0); const timerRef = useRef | null>(null); useEffect(() => { @@ -150,33 +146,10 @@ const LiquidCover = ({ src, alt }: { src?: string; alt: string }) => { setPrevious(currentRef.current); currentRef.current = src; setCurrent(src); - setMelting(true); - - const started = performance.now(); - const step = (now: number) => { - const t = Math.min((now - started) / MELT_MS, 1); - const wave = Math.sin(Math.PI * t); - dispRef.current?.setAttribute( - "scale", - String(Math.round(wave * 10)), - ); - turbRef.current?.setAttribute( - "baseFrequency", - String(0.005 + wave * 0.003), - ); - if (t < 1) { - rafRef.current = requestAnimationFrame(step); - } else { - dispRef.current?.setAttribute("scale", "0"); - setMelting(false); - } - }; - cancelAnimationFrame(rafRef.current); - rafRef.current = requestAnimationFrame(step); if (timerRef.current) clearTimeout(timerRef.current); timerRef.current = setTimeout( () => setPrevious(undefined), - MELT_MS + 60, + COVER_FADE_MS + 40, ); }; @@ -188,49 +161,19 @@ const LiquidCover = ({ src, alt }: { src?: string; alt: string }) => { return () => { cancelled = true; - cancelAnimationFrame(rafRef.current); if (timerRef.current) clearTimeout(timerRef.current); }; }, [src]); useEffect( () => () => { - cancelAnimationFrame(rafRef.current); if (timerRef.current) clearTimeout(timerRef.current); }, [], ); return ( -
- +
{previous && (
-