feat(player): plain crossfade between covers
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
- 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
This commit is contained in:
1 parent
f20578a552
commit
4b67c94494
2 files changed
+12
-86
No files matched your search
@@ -124,24 +124,15 @@
|
|||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Both layers melt under the same turbulence filter while the old
|
// The old sleeve layers over the new one and simply fades away.
|
||||||
// sleeve fades out over the new one.
|
|
||||||
&.is-melting {
|
|
||||||
filter: url(#music-liquid-filter);
|
|
||||||
|
|
||||||
img {
|
|
||||||
transform: scale(1.02);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-prev {
|
&-prev {
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
animation: cover-melt-out 0.8s ease forwards;
|
animation: cover-fade-out 0.55s ease forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-current {
|
&-current {
|
||||||
z-index: 1;
|
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 {
|
> .material-symbols-rounded {
|
||||||
@@ -150,12 +141,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-liquid {
|
|
||||||
position: absolute;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
&-meta {
|
&-meta {
|
||||||
width: min(560px, 100%);
|
width: min(560px, 100%);
|
||||||
margin-top: clamp(1.2rem, 3vh, 2rem);
|
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 {
|
from {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: scale(1.015);
|
|
||||||
}
|
}
|
||||||
to {
|
to {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transform: scale(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes cover-melt-out {
|
@keyframes cover-fade-out {
|
||||||
from {
|
from {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,20 +123,16 @@ const QueueRow = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
const MELT_MS = 800;
|
const COVER_FADE_MS = 600;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sleeve that melts into the next track: the previous cover stays on top while
|
* Sleeve that crossfades into the next track: the previous cover stays on top
|
||||||
* a turbulence + displacement filter ripples both layers, then fades away.
|
* 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<string | undefined>(src);
|
const [current, setCurrent] = useState<string | undefined>(src);
|
||||||
const [previous, setPrevious] = useState<string | undefined>();
|
const [previous, setPrevious] = useState<string | undefined>();
|
||||||
const [melting, setMelting] = useState(false);
|
|
||||||
const currentRef = useRef<string | undefined>(src);
|
const currentRef = useRef<string | undefined>(src);
|
||||||
const turbRef = useRef<SVGFETurbulenceElement | null>(null);
|
|
||||||
const dispRef = useRef<SVGFEDisplacementMapElement | null>(null);
|
|
||||||
const rafRef = useRef(0);
|
|
||||||
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -150,33 +146,10 @@ const LiquidCover = ({ src, alt }: { src?: string; alt: string }) => {
|
|||||||
setPrevious(currentRef.current);
|
setPrevious(currentRef.current);
|
||||||
currentRef.current = src;
|
currentRef.current = src;
|
||||||
setCurrent(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);
|
if (timerRef.current) clearTimeout(timerRef.current);
|
||||||
timerRef.current = setTimeout(
|
timerRef.current = setTimeout(
|
||||||
() => setPrevious(undefined),
|
() => setPrevious(undefined),
|
||||||
MELT_MS + 60,
|
COVER_FADE_MS + 40,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -188,49 +161,19 @@ const LiquidCover = ({ src, alt }: { src?: string; alt: string }) => {
|
|||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
cancelAnimationFrame(rafRef.current);
|
|
||||||
if (timerRef.current) clearTimeout(timerRef.current);
|
if (timerRef.current) clearTimeout(timerRef.current);
|
||||||
};
|
};
|
||||||
}, [src]);
|
}, [src]);
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => () => {
|
() => () => {
|
||||||
cancelAnimationFrame(rafRef.current);
|
|
||||||
if (timerRef.current) clearTimeout(timerRef.current);
|
if (timerRef.current) clearTimeout(timerRef.current);
|
||||||
},
|
},
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`music-player-art${melting ? " is-melting" : ""}`}>
|
<div className="music-player-art">
|
||||||
<svg className="music-player-liquid" aria-hidden="true">
|
|
||||||
<defs>
|
|
||||||
<filter
|
|
||||||
id="music-liquid-filter"
|
|
||||||
x="-25%"
|
|
||||||
y="-25%"
|
|
||||||
width="150%"
|
|
||||||
height="150%"
|
|
||||||
>
|
|
||||||
<feTurbulence
|
|
||||||
ref={turbRef}
|
|
||||||
type="fractalNoise"
|
|
||||||
baseFrequency="0.005"
|
|
||||||
numOctaves="1"
|
|
||||||
seed="4"
|
|
||||||
result="noise"
|
|
||||||
/>
|
|
||||||
<feDisplacementMap
|
|
||||||
ref={dispRef}
|
|
||||||
in="SourceGraphic"
|
|
||||||
in2="noise"
|
|
||||||
scale="0"
|
|
||||||
xChannelSelector="R"
|
|
||||||
yChannelSelector="G"
|
|
||||||
/>
|
|
||||||
</filter>
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
||||||
{previous && (
|
{previous && (
|
||||||
<img
|
<img
|
||||||
key={previous}
|
key={previous}
|
||||||
@@ -403,7 +346,7 @@ function AudioPlayerRoute() {
|
|||||||
<div className="music-player-stage">
|
<div className="music-player-stage">
|
||||||
<div className="music-player-row">
|
<div className="music-player-row">
|
||||||
<div className="music-player-main">
|
<div className="music-player-main">
|
||||||
<LiquidCover
|
<CoverArt
|
||||||
src={imageUrl}
|
src={imageUrl}
|
||||||
alt={item?.Name ?? "Обложка"}
|
alt={item?.Name ?? "Обложка"}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user