mirror of
https://github.com/narrrl/pl8list-rewind.git
synced 2026-11-18 17:25:03 +01:00
Stop repainting the playing card every frame, sharpen the drop on phones
--energy is now set only on the art and the glow, and only when it changes, so the card is no longer restyled every frame. The halo pulses through transform and opacity, without forcing layout or paint. The card background is blurred and darkened once on a small canvas, so the full-screen CSS blur is gone. The action rings no longer use backdrop-filter, and neither do the mode tabs and the up-next pill on phones. The chrome layer reads the layout only after a resize or a font load. The drop's fragment shader skips the icon, the ring and the frost while none of them shows. That saves enough to render the drop at up to 1.5 canvas px per CSS px on phones, up from 1. ?debug=drop shows fps, the worst frame and chrome draws per second, refreshed once a second.
This commit is contained in:
1 parent
3de51b2517
commit
b29062db3e
6 files changed
+187
-43
No files matched your search
+19
-2
@@ -2,7 +2,7 @@
|
||||
// and dropped again once it is far behind, so a long session stays light.
|
||||
|
||||
import { type Track, artistImg, artistUrl, trackUrl } from "./api";
|
||||
import { accentFor, accentForName } from "./color";
|
||||
import { accentFor, accentForName, backdrop } from "./color";
|
||||
|
||||
export interface CardActions {
|
||||
like(card: Card): void;
|
||||
@@ -36,6 +36,8 @@ export class Card {
|
||||
private drawn = "";
|
||||
private dragging = false;
|
||||
private accent: string | null = null;
|
||||
/// The blurred background, once made.
|
||||
private backdrop: string | null = null;
|
||||
|
||||
/// `station`: the artist radio this card was picked for, if any.
|
||||
constructor(
|
||||
@@ -66,7 +68,17 @@ export class Card {
|
||||
const $ = <T extends HTMLElement>(sel: string) => el.querySelector(sel) as T;
|
||||
const img = artistImg(t);
|
||||
if (img) {
|
||||
$(".bg").style.backgroundImage = `url("${img}")`;
|
||||
const bg = $(".bg");
|
||||
if (this.backdrop) this.showBackdrop(bg);
|
||||
else {
|
||||
// The plain image under a CSS blur until the blurred one is ready.
|
||||
bg.style.backgroundImage = `url("${img}")`;
|
||||
backdrop(img).then((b) => {
|
||||
this.backdrop = b;
|
||||
const bg = this.el?.querySelector<HTMLElement>(".bg");
|
||||
if (b && bg) this.showBackdrop(bg);
|
||||
}, () => {});
|
||||
}
|
||||
$(".art").style.backgroundImage = `url("${img}")`;
|
||||
$(".artist-avatar").style.backgroundImage = `url("${img}")`;
|
||||
if (this.accent) el.style.setProperty("--card-accent", this.accent);
|
||||
@@ -129,6 +141,11 @@ export class Card {
|
||||
return el;
|
||||
}
|
||||
|
||||
private showBackdrop(bg: HTMLElement): void {
|
||||
bg.style.backgroundImage = `url("${this.backdrop}")`;
|
||||
bg.classList.add("baked");
|
||||
}
|
||||
|
||||
/// Where a radio track comes from, e.g. "Lower radio · via Motus".
|
||||
private whyText(): string {
|
||||
const { station } = this;
|
||||
|
||||
Reference in new issue
Block a user