Compare commits
No commits in common. "1d7f497594b0710c628560f8a8aba003292f11c6" and "8755d167357146501e483caaee0dad962f8777d9" have entirely different histories.
1d7f497594
...
8755d16735
12 changed files with 60 additions and 157 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
|
@ -1,21 +1,5 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 0.1.0-beta.14
|
|
||||||
|
|
||||||
Full screen stays on with the miniplayer, a smoother colour wash, and a round of playback and download fixes.
|
|
||||||
|
|
||||||
- Going back from the full-screen player to the miniplayer now keeps Kaleido in full screen, so you can browse full screen while the video plays in the corner. Press Esc to go back to a window, or on Windows use the new Exit full screen button beside the window controls. Closing the miniplayer leaves the window as it is.
|
|
||||||
- The colour wash behind the featured titles and title pages now blends into the next title's colours instead of jumping when the artwork changes. Clicking quickly through featured titles no longer blanks the background for a moment.
|
|
||||||
- Playback stays with the server it started on: progress and watched marks never go to a server you switch to later, and switching account, profile or server ends playback from the old one. Downloads report only to their own server.
|
|
||||||
- When Plex converts a video, the audio and subtitle tracks you chose (and your language preferences) are now applied, and kept when you change quality.
|
|
||||||
- Watching a download offline now saves where you stopped and marks it watched.
|
|
||||||
- Fixed: playing something offline could crash the player.
|
|
||||||
- Fixed: closing or switching titles while a video was still starting could start it anyway.
|
|
||||||
- Fixed: Home and the libraries could still show the previous account's or profile's titles after switching.
|
|
||||||
- Fixed: titles split into several files were downloaded only in part; Kaleido now picks a single-file version, or says it can't download the title.
|
|
||||||
- Fixed: episodes downloaded into the same season folder could overwrite or delete each other's artwork, and pause or remove could stop working after a download restarted.
|
|
||||||
- Library grids refresh fully when something changes, slow server responses time out properly, and the featured titles start rotating again when you scroll back to them.
|
|
||||||
|
|
||||||
## 0.1.0-beta.13
|
## 0.1.0-beta.13
|
||||||
|
|
||||||
A gentler automatic intro skip, and home screens that keep up with your other Plex apps.
|
A gentler automatic intro skip, and home screens that keep up with your other Plex apps.
|
||||||
|
|
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "kaleido-desktop",
|
"name": "kaleido-desktop",
|
||||||
"version": "0.1.0-beta.14",
|
"version": "0.1.0-beta.13",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "kaleido-desktop",
|
"name": "kaleido-desktop",
|
||||||
"version": "0.1.0-beta.14",
|
"version": "0.1.0-beta.13",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource-variable/inter": "^5.3.0",
|
"@fontsource-variable/inter": "^5.3.0",
|
||||||
"@tanstack/react-query": "^5.105.0",
|
"@tanstack/react-query": "^5.105.0",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "kaleido-desktop",
|
"name": "kaleido-desktop",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.1.0-beta.14",
|
"version": "0.1.0-beta.13",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|
|
||||||
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
|
|
@ -2173,7 +2173,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kaleido"
|
name = "kaleido"
|
||||||
version = "0.1.0-beta.14"
|
version = "0.1.0-beta.13"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fs2",
|
"fs2",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "kaleido"
|
name = "kaleido"
|
||||||
version = "0.1.0-beta.14"
|
version = "0.1.0-beta.13"
|
||||||
description = "Kaleido — a Plex client for Windows"
|
description = "Kaleido — a Plex client for Windows"
|
||||||
authors = ["Elijah"]
|
authors = ["Elijah"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Kaleido",
|
"productName": "Kaleido",
|
||||||
"version": "0.1.0-beta.14",
|
"version": "0.1.0-beta.13",
|
||||||
"identifier": "tv.kaleido.desktop",
|
"identifier": "tv.kaleido.desktop",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "npm run dev",
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import { PageLoader } from '../ui/primitives';
|
||||||
import { Splash } from '../screens/Splash';
|
import { Splash } from '../screens/Splash';
|
||||||
import { SignIn } from '../screens/SignIn';
|
import { SignIn } from '../screens/SignIn';
|
||||||
import { ServerPicker } from '../screens/ServerPicker';
|
import { ServerPicker } from '../screens/ServerPicker';
|
||||||
import { isMac, isNative, win } from '../platform/native';
|
import { isMac, win } from '../platform/native';
|
||||||
import { usePlayer } from '../player/store';
|
import { usePlayer } from '../player/store';
|
||||||
import { PlayerOverlay } from '../player/PlayerOverlay';
|
import { PlayerOverlay } from '../player/PlayerOverlay';
|
||||||
import { DialogHost } from '../screens/dialogs/DialogHost';
|
import { DialogHost } from '../screens/dialogs/DialogHost';
|
||||||
|
|
@ -111,9 +111,7 @@ function useGlobalShortcuts() {
|
||||||
win.isFullscreen().then((fs) => win.setFullscreen(!fs));
|
win.isFullscreen().then((fs) => win.setFullscreen(!fs));
|
||||||
} else if ((e.key === 'Escape' || e.key === 'Backspace') && !isTyping(e.target) && !document.querySelector('.menu-layer, .dialog-layer')) {
|
} else if ((e.key === 'Escape' || e.key === 'Backspace') && !isTyping(e.target) && !document.querySelector('.menu-layer, .dialog-layer')) {
|
||||||
if (e.key === 'Escape' && document.fullscreenElement) return;
|
if (e.key === 'Escape' && document.fullscreenElement) return;
|
||||||
// Esc leaves full screen first (kept from the player when it went to the corner).
|
useRouter.getState().back();
|
||||||
if (e.key === 'Escape' && isNative) win.isFullscreen().then((fs) => (fs ? win.setFullscreen(false) : useRouter.getState().back()));
|
|
||||||
else useRouter.getState().back();
|
|
||||||
} else if ((e.ctrlKey || e.metaKey) && e.key === ',') {
|
} else if ((e.ctrlKey || e.metaKey) && e.key === ',') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
navigate({ name: 'settings', mode: 'app', tab: 'general' });
|
navigate({ name: 'settings', mode: 'app', tab: 'general' });
|
||||||
|
|
|
||||||
|
|
@ -19,21 +19,13 @@ const NAV = [
|
||||||
/** Caption buttons drawn by the page; macOS shows its own traffic lights instead. */
|
/** Caption buttons drawn by the page; macOS shows its own traffic lights instead. */
|
||||||
export function WindowControls() {
|
export function WindowControls() {
|
||||||
const [maximized, setMaximized] = useState(false);
|
const [maximized, setMaximized] = useState(false);
|
||||||
const [fullscreen, setFullscreen] = useState(false);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isNative || isMac) return;
|
if (!isNative || isMac) return;
|
||||||
let off: (() => void) | undefined;
|
let off: (() => void) | undefined;
|
||||||
let gone = false;
|
const sync = () => win.isMaximized().then(setMaximized);
|
||||||
const sync = () => {
|
|
||||||
win.isMaximized().then((m) => !gone && setMaximized(m));
|
|
||||||
win.isFullscreen().then((f) => !gone && setFullscreen(f));
|
|
||||||
};
|
|
||||||
sync();
|
sync();
|
||||||
win.onResized(sync).then((u) => (gone ? u() : (off = u)));
|
win.onResized(sync).then((u) => (off = u));
|
||||||
return () => {
|
return () => off?.();
|
||||||
gone = true;
|
|
||||||
off?.();
|
|
||||||
};
|
|
||||||
}, []);
|
}, []);
|
||||||
if (!isNative || isMac) return null;
|
if (!isNative || isMac) return null;
|
||||||
return (
|
return (
|
||||||
|
|
@ -41,15 +33,9 @@ export function WindowControls() {
|
||||||
<button aria-label="Minimize" onClick={() => win.minimize()}>
|
<button aria-label="Minimize" onClick={() => win.minimize()}>
|
||||||
<Icon name="minimize" size={15} strokeWidth={1.4} />
|
<Icon name="minimize" size={15} strokeWidth={1.4} />
|
||||||
</button>
|
</button>
|
||||||
{fullscreen ? (
|
|
||||||
<button aria-label="Exit full screen" title="Exit full screen (Esc)" onClick={() => win.setFullscreen(false)}>
|
|
||||||
<Icon name="collapse" size={14} strokeWidth={1.4} />
|
|
||||||
</button>
|
|
||||||
) : (
|
|
||||||
<button aria-label={maximized ? 'Restore' : 'Maximize'} onClick={() => win.toggleMaximize()}>
|
<button aria-label={maximized ? 'Restore' : 'Maximize'} onClick={() => win.toggleMaximize()}>
|
||||||
<Icon name={maximized ? 'restore' : 'maximize'} size={13} strokeWidth={1.4} />
|
<Icon name={maximized ? 'restore' : 'maximize'} size={13} strokeWidth={1.4} />
|
||||||
</button>
|
</button>
|
||||||
)}
|
|
||||||
<button aria-label="Close" className="close" onClick={() => win.close()}>
|
<button aria-label="Close" className="close" onClick={() => win.close()}>
|
||||||
<Icon name="x" size={15} strokeWidth={1.4} />
|
<Icon name="x" size={15} strokeWidth={1.4} />
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -174,24 +174,17 @@ export function plural(n: number, word: string, pluralWord = `${word}s`) {
|
||||||
return `${n.toLocaleString()} ${n === 1 ? word : pluralWord}`;
|
return `${n.toLocaleString()} ${n === 1 ? word : pluralWord}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hex UltraBlur colors → the wash's four corner colours, each at its own strength. */
|
/** Hex UltraBlur colors → CSS gradient layers for the artwork colour wash. */
|
||||||
export function washColors(u: Item['ultraBlur'], strength = 1) {
|
export function washGradient(u: Item['ultraBlur'], strength = 1): string {
|
||||||
if (!u) return null;
|
if (!u) return '';
|
||||||
const c = (hex: string, a: number) => {
|
const c = (hex: string, a: number) => {
|
||||||
const n = parseInt(hex, 16);
|
const n = parseInt(hex, 16);
|
||||||
return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${(a * strength).toFixed(3)})`;
|
return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${(a * strength).toFixed(3)})`;
|
||||||
};
|
};
|
||||||
return { topRight: c(u.topRight, 0.95), topLeft: c(u.topLeft, 0.7), bottomRight: c(u.bottomRight, 0.55), bottomLeft: c(u.bottomLeft, 0.45) };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Hex UltraBlur colors → CSS gradient layers for the artwork colour wash. */
|
|
||||||
export function washGradient(u: Item['ultraBlur'], strength = 1): string {
|
|
||||||
const c = washColors(u, strength);
|
|
||||||
if (!c) return '';
|
|
||||||
return [
|
return [
|
||||||
`radial-gradient(ellipse at 100% 0%, ${c.topRight} 0%, transparent 62%)`,
|
`radial-gradient(ellipse at 100% 0%, ${c(u.topRight, 0.95)} 0%, transparent 62%)`,
|
||||||
`radial-gradient(ellipse at 0% 0%, ${c.topLeft} 0%, transparent 55%)`,
|
`radial-gradient(ellipse at 0% 0%, ${c(u.topLeft, 0.7)} 0%, transparent 55%)`,
|
||||||
`radial-gradient(ellipse at 100% 100%, ${c.bottomRight} 0%, transparent 60%)`,
|
`radial-gradient(ellipse at 100% 100%, ${c(u.bottomRight, 0.55)} 0%, transparent 60%)`,
|
||||||
`radial-gradient(ellipse at 0% 100%, ${c.bottomLeft} 0%, transparent 60%)`,
|
`radial-gradient(ellipse at 0% 100%, ${c(u.bottomLeft, 0.45)} 0%, transparent 60%)`,
|
||||||
].join(', ');
|
].join(', ');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -702,12 +702,10 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
||||||
playServer = s;
|
playServer = s;
|
||||||
playDownload = download;
|
playDownload = download;
|
||||||
localScrobbled = false;
|
localScrobbled = false;
|
||||||
// From the miniplayer the window may have gone full screen (or left it) since.
|
|
||||||
const fullscreenNow = await win.isFullscreen().catch(() => false);
|
|
||||||
if (stale()) return;
|
|
||||||
if (!previous.open) {
|
if (!previous.open) {
|
||||||
triedFallback = false;
|
triedFallback = false;
|
||||||
wasFullscreenBeforePlay = fullscreenNow;
|
wasFullscreenBeforePlay = await win.isFullscreen().catch(() => false);
|
||||||
|
if (stale()) return;
|
||||||
}
|
}
|
||||||
set({
|
set({
|
||||||
open: true,
|
open: true,
|
||||||
|
|
@ -732,7 +730,7 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
||||||
audioKey: opts.tracks?.audioKey ?? '',
|
audioKey: opts.tracks?.audioKey ?? '',
|
||||||
subKey: opts.tracks?.subKey ?? '__init',
|
subKey: opts.tracks?.subKey ?? '__init',
|
||||||
video: null,
|
video: null,
|
||||||
fullscreen: fullscreenNow,
|
fullscreen: wasFullscreenBeforePlay,
|
||||||
mini: false,
|
mini: false,
|
||||||
videoGamma: '',
|
videoGamma: '',
|
||||||
enhance: { ...previous.enhance, bypass: false, preparing: false },
|
enhance: { ...previous.enhance, bypass: false, preparing: false },
|
||||||
|
|
@ -858,12 +856,8 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
||||||
await mpv.show(false).catch(() => {});
|
await mpv.show(false).catch(() => {});
|
||||||
}
|
}
|
||||||
set({ open: false, mini: false, item: null, delivery: null, error: '', terminated: false, countdown: null, nextUp: null, prevUp: null, firstFrame: false });
|
set({ open: false, mini: false, item: null, delivery: null, error: '', terminated: false, countdown: null, nextUp: null, prevUp: null, firstFrame: false });
|
||||||
// Closing the full player hands back the window it found; closing the
|
|
||||||
// miniplayer leaves browsing as it is, full screen or not.
|
|
||||||
if (!st.mini) {
|
|
||||||
const fs = await win.isFullscreen().catch(() => false);
|
const fs = await win.isFullscreen().catch(() => false);
|
||||||
if (fs && !wasFullscreenBeforePlay) win.setFullscreen(false);
|
if (fs && !wasFullscreenBeforePlay) win.setFullscreen(false);
|
||||||
}
|
|
||||||
if (st.item) invalidateLibrary();
|
if (st.item) invalidateLibrary();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -919,8 +913,12 @@ export const usePlayer = create<PlayerState>((set, get) => ({
|
||||||
async minimize() {
|
async minimize() {
|
||||||
const st = get();
|
const st = get();
|
||||||
if (!st.open || st.mini) return;
|
if (!st.open || st.mini) return;
|
||||||
// Full screen stays for browsing; Esc or the window controls leave it.
|
|
||||||
set({ mini: true });
|
set({ mini: true });
|
||||||
|
// Full screen was for the video; browsing goes back to the window.
|
||||||
|
if (st.fullscreen && !wasFullscreenBeforePlay) {
|
||||||
|
await win.setFullscreen(false).catch(() => {});
|
||||||
|
set({ fullscreen: false });
|
||||||
|
}
|
||||||
if (separateMini) {
|
if (separateMini) {
|
||||||
// Once the page is opaque again (no video in it), the video moves into
|
// Once the page is opaque again (no video in it), the video moves into
|
||||||
// the miniplayer's own window (miniWindow.ts).
|
// the miniplayer's own window (miniWindow.ts).
|
||||||
|
|
@ -1027,13 +1025,6 @@ usePlayer.subscribe((st, prev) => {
|
||||||
|
|
||||||
bridgeMiniWindow(usePlayer);
|
bridgeMiniWindow(usePlayer);
|
||||||
|
|
||||||
// Full screen can change outside the player (Esc or the window controls while
|
|
||||||
// browsing with the miniplayer, the OS): the player's controls follow it.
|
|
||||||
win.onResized(() => {
|
|
||||||
if (!usePlayer.getState().open) return;
|
|
||||||
win.isFullscreen().then((fs) => usePlayer.getState().fullscreen !== fs && usePlayer.setState({ fullscreen: fs }), () => {});
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signing out, or switching server or profile, ends a stream from the old one: its
|
* Signing out, or switching server or profile, ends a stream from the old one: its
|
||||||
* progress belongs to that account. A download keeps playing, without reporting.
|
* progress belongs to that account. A download keeps playing, without reporting.
|
||||||
|
|
|
||||||
|
|
@ -515,12 +515,6 @@ html.splash-arrival .auth-screen {
|
||||||
.backdrop-layer.ready {
|
.backdrop-layer.ready {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
/* The outgoing art fades too, a beat behind the incoming, so nothing of it is
|
|
||||||
left to vanish through the new art's faded edges. */
|
|
||||||
.backdrop-layer.ready.leaving {
|
|
||||||
opacity: 0;
|
|
||||||
transition-delay: 180ms;
|
|
||||||
}
|
|
||||||
/* The colour wash lives outside the clipped backdrop so it can carry on down
|
/* The colour wash lives outside the clipped backdrop so it can carry on down
|
||||||
the page behind the rows, fading out as it goes. */
|
the page behind the rows, fading out as it goes. */
|
||||||
.backdrop-tint {
|
.backdrop-tint {
|
||||||
|
|
@ -534,42 +528,14 @@ html.splash-arrival .auth-screen {
|
||||||
-webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%);
|
-webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%);
|
||||||
mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%);
|
mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.75) 45%, transparent 100%);
|
||||||
}
|
}
|
||||||
/* Registered as colours so a change of title blends the wash from one set of
|
|
||||||
colours to the next, instead of swapping the gradient outright. */
|
|
||||||
@property --wash-tr {
|
|
||||||
syntax: '<color>';
|
|
||||||
inherits: false;
|
|
||||||
initial-value: transparent;
|
|
||||||
}
|
|
||||||
@property --wash-tl {
|
|
||||||
syntax: '<color>';
|
|
||||||
inherits: false;
|
|
||||||
initial-value: transparent;
|
|
||||||
}
|
|
||||||
@property --wash-br {
|
|
||||||
syntax: '<color>';
|
|
||||||
inherits: false;
|
|
||||||
initial-value: transparent;
|
|
||||||
}
|
|
||||||
@property --wash-bl {
|
|
||||||
syntax: '<color>';
|
|
||||||
inherits: false;
|
|
||||||
initial-value: transparent;
|
|
||||||
}
|
|
||||||
.backdrop-wash {
|
.backdrop-wash {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 420ms var(--ease);
|
||||||
|
}
|
||||||
|
.backdrop-wash.ready {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
background:
|
|
||||||
radial-gradient(ellipse at 100% 0%, var(--wash-tr) 0%, transparent 62%),
|
|
||||||
radial-gradient(ellipse at 0% 0%, var(--wash-tl) 0%, transparent 55%),
|
|
||||||
radial-gradient(ellipse at 100% 100%, var(--wash-br) 0%, transparent 60%),
|
|
||||||
radial-gradient(ellipse at 0% 100%, var(--wash-bl) 0%, transparent 60%);
|
|
||||||
transition:
|
|
||||||
--wash-tr 700ms var(--ease),
|
|
||||||
--wash-tl 700ms var(--ease),
|
|
||||||
--wash-br 700ms var(--ease),
|
|
||||||
--wash-bl 700ms var(--ease);
|
|
||||||
}
|
}
|
||||||
.backdrop-art {
|
.backdrop-art {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,21 @@
|
||||||
import { useEffect, useRef, useState, type CSSProperties } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import type { Item } from '../plex/types';
|
import type { Item } from '../plex/types';
|
||||||
import { useServer } from '../app/session';
|
import { useServer } from '../app/session';
|
||||||
import { useSettings } from '../app/settings';
|
import { useSettings } from '../app/settings';
|
||||||
import { art, washColors } from '../app/format';
|
import { art, washGradient } from '../app/format';
|
||||||
|
|
||||||
interface Layer {
|
interface Layer {
|
||||||
key: number;
|
key: number;
|
||||||
src: string;
|
src: string;
|
||||||
blur: Item['ultraBlur'];
|
wash: string;
|
||||||
ready: boolean;
|
ready: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** How long an outgoing layer lingers: its fade (with delay) plus a margin. */
|
|
||||||
const LEAVE_MS = 700;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Artwork-led page background. The image sits top-right and fades into the
|
* Artwork-led page background. The image sits top-right and fades into the
|
||||||
* page toward its left and bottom edges; the UltraBlur colour wash tints the
|
* page toward its left and bottom edges; the UltraBlur colour wash tints the
|
||||||
* page beneath it and carries on down behind the rows. Artwork crossfades
|
* page beneath it and carries on down behind the rows. Changes crossfade; the
|
||||||
* once the new image has decoded, and the wash's colours blend into the new
|
* outgoing layer stays until the new image has decoded.
|
||||||
* title's at the same moment (registered custom properties, app.css).
|
|
||||||
*/
|
*/
|
||||||
export function Backdrop({ item, className = '', width = 1600, height = 900, wash: forceWash }: { item: Item | null | undefined; className?: string; width?: number; height?: number; wash?: Item['ultraBlur'] }) {
|
export function Backdrop({ item, className = '', width = 1600, height = 900, wash: forceWash }: { item: Item | null | undefined; className?: string; width?: number; height?: number; wash?: Item['ultraBlur'] }) {
|
||||||
const server = useServer();
|
const server = useServer();
|
||||||
|
|
@ -29,50 +25,39 @@ export function Backdrop({ item, className = '', width = 1600, height = 900, was
|
||||||
const path = item ? art.backdrop(item) : '';
|
const path = item ? art.backdrop(item) : '';
|
||||||
const src = path ? server.image(path, width, height) : '';
|
const src = path ? server.image(path, width, height) : '';
|
||||||
const blur = forceWash ?? item?.ultraBlur ?? null;
|
const blur = forceWash ?? item?.ultraBlur ?? null;
|
||||||
const blurKey = blur ? `${blur.topLeft}${blur.topRight}${blur.bottomRight}${blur.bottomLeft}` : '';
|
const wash = colorWash && blur ? washGradient(blur) : '';
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!src && !blur) return;
|
if (!src && !wash) return;
|
||||||
setLayers((prev) => {
|
setLayers((prev) => {
|
||||||
const last = prev[prev.length - 1];
|
if (prev.length && prev[prev.length - 1].src === src) {
|
||||||
// Same art, maybe new colours: the wash blends to them in place.
|
// Same art, maybe new wash.
|
||||||
if (last && last.src === src) return prev.map((l) => (l === last ? { ...l, blur } : l));
|
return prev.map((l, i) => (i === prev.length - 1 ? { ...l, wash } : l));
|
||||||
// Keep only what is on screen (the newest layer that has shown) under the new one.
|
}
|
||||||
const shown = prev.filter((l) => l.ready).slice(-1);
|
return [...prev.slice(-1), { key: ++counter.current, src, wash, ready: !src }];
|
||||||
return [...shown, { key: ++counter.current, src, blur, ready: !src }];
|
|
||||||
});
|
});
|
||||||
}, [src, blurKey]);
|
}, [src, wash]);
|
||||||
|
|
||||||
const onReady = (key: number) => setLayers((prev) => (prev.some((l) => l.key === key && !l.ready) ? prev.map((l) => (l.key === key ? { ...l, ready: true } : l)) : prev));
|
const onReady = (key: number) =>
|
||||||
|
setLayers((prev) => {
|
||||||
// Once the newest layer is in, the ones beneath fade out and then go.
|
const idx = prev.findIndex((l) => l.key === key);
|
||||||
const newest = layers[layers.length - 1];
|
if (idx < 0) return prev;
|
||||||
useEffect(() => {
|
const next = prev.map((l) => (l.key === key ? { ...l, ready: true } : l));
|
||||||
if (!newest?.ready || layers.length < 2) return;
|
// Drop older layers once the newest is visible (after its fade).
|
||||||
const t = setTimeout(() => setLayers((p) => (p[p.length - 1]?.key === newest.key ? p.slice(-1) : p)), LEAVE_MS);
|
setTimeout(() => setLayers((p) => (p.length > 1 && p[p.length - 1].key === key ? p.slice(-1) : p)), 500);
|
||||||
return () => clearTimeout(t);
|
return next;
|
||||||
}, [newest?.key, newest?.ready, layers.length]);
|
});
|
||||||
|
|
||||||
let top = -1;
|
|
||||||
layers.forEach((l, i) => l.ready && (top = i));
|
|
||||||
const colors = top >= 0 ? washColors(layers[top].blur) : null;
|
|
||||||
const washStyle = {
|
|
||||||
'--wash-tr': colors?.topRight ?? 'transparent',
|
|
||||||
'--wash-tl': colors?.topLeft ?? 'transparent',
|
|
||||||
'--wash-br': colors?.bottomRight ?? 'transparent',
|
|
||||||
'--wash-bl': colors?.bottomLeft ?? 'transparent',
|
|
||||||
} as CSSProperties;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{colorWash && (
|
{colorWash && (
|
||||||
<div className={`backdrop-tint ${className}`} aria-hidden="true">
|
<div className={`backdrop-tint ${className}`} aria-hidden="true">
|
||||||
<div className="backdrop-wash" style={washStyle} />
|
{layers.map((l) => l.wash && <div key={l.key} className={`backdrop-wash${l.ready ? ' ready' : ''}`} style={{ background: l.wash }} />)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className={`backdrop ${className}${colorWash ? ' washed' : ''}`} aria-hidden="true">
|
<div className={`backdrop ${className}${colorWash ? ' washed' : ''}`} aria-hidden="true">
|
||||||
{layers.map((l, i) => (
|
{layers.map((l) => (
|
||||||
<div key={l.key} className={`backdrop-layer${l.ready ? ' ready' : ''}${i < top ? ' leaving' : ''}`}>
|
<div key={l.key} className={`backdrop-layer${l.ready ? ' ready' : ''}`}>
|
||||||
{l.src && <img className="backdrop-art" src={l.src} alt="" draggable={false} decoding="async" onLoad={() => onReady(l.key)} onError={() => onReady(l.key)} />}
|
{l.src && <img className="backdrop-art" src={l.src} alt="" draggable={false} decoding="async" onLoad={() => onReady(l.key)} onError={() => onReady(l.key)} />}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue