fix(player): stop the cover flicker after the crossfade
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
- the incoming sleeve keeps its static class after the old one is removed, so its fade-in animation no longer restarts ~0.6s later (the flicker)
This commit is contained in:
1 parent
8e9e5eeff2
commit
d80db29a02
1 file changed
+3
-1
@@ -133,6 +133,7 @@ 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 currentRef = useRef<string | undefined>(src);
|
const currentRef = useRef<string | undefined>(src);
|
||||||
|
const hasSwappedRef = useRef(false);
|
||||||
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -143,6 +144,7 @@ const CoverArt = ({ src, alt }: { src?: string; alt: string }) => {
|
|||||||
const start = () => {
|
const start = () => {
|
||||||
if (cancelled || begun) return;
|
if (cancelled || begun) return;
|
||||||
begun = true;
|
begun = true;
|
||||||
|
hasSwappedRef.current = true;
|
||||||
setPrevious(currentRef.current);
|
setPrevious(currentRef.current);
|
||||||
currentRef.current = src;
|
currentRef.current = src;
|
||||||
setCurrent(src);
|
setCurrent(src);
|
||||||
@@ -186,7 +188,7 @@ const CoverArt = ({ src, alt }: { src?: string; alt: string }) => {
|
|||||||
<img
|
<img
|
||||||
key={current}
|
key={current}
|
||||||
className={`music-player-art-current${
|
className={`music-player-art-current${
|
||||||
previous ? " is-static" : ""
|
hasSwappedRef.current ? " is-static" : ""
|
||||||
}`}
|
}`}
|
||||||
src={current}
|
src={current}
|
||||||
alt={alt}
|
alt={alt}
|
||||||
|
|||||||
Reference in new issue
Block a user