Corner sun moves to take in the whole list when the window holds it small
Held by the column's width, the stuck circle's center moves down the screen's edge until the list's corners are inside it, then off the screen to the left (growing as much, so its right edge stays put). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c335774db5
commit
5e77da9a66
1 changed files with 31 additions and 6 deletions
|
|
@ -124,6 +124,9 @@ const STUCK_TOP = 16;
|
|||
const stickAt = (listTop: number) => `calc(var(--header-h, 5rem) + ${STUCK_TOP - listTop}px)`;
|
||||
const LIST_LEFT = 16;
|
||||
const CIRCLE_GAP = 8 + 4;
|
||||
/* How far off the screen's left edge the stuck circle's center may
|
||||
go to take in a long list on a narrow window. */
|
||||
const MAX_BACK = 1200;
|
||||
|
||||
/* The circle's color family for a section's accent (PageShell.css):
|
||||
green and amber their own, teal and deep teal (and any other) teal. */
|
||||
|
|
@ -198,15 +201,37 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
|
|||
// the corner, centered on the header's bottom left so the header
|
||||
// and the screen's edge hide three quarters of it, big enough to
|
||||
// reach past the list's far corner, but never wider than the column
|
||||
// (it'd show a cut edge at the content).
|
||||
// (it'd show a cut edge at the content). When a narrow window holds
|
||||
// it smaller than that, it moves to take the whole list in anyway:
|
||||
// first its center down the screen's edge, then (if that isn't
|
||||
// enough) off the screen to the left, growing by as much, so its
|
||||
// right edge stays put while its arc flattens over the list.
|
||||
const circleBox = (() => {
|
||||
if (!listBox || !circle) return null;
|
||||
if (stuck) {
|
||||
const radius = Math.min(
|
||||
Math.hypot(LIST_LEFT + listBox.width + 24, STUCK_TOP + listBox.height + 24),
|
||||
columnWidth - 8,
|
||||
);
|
||||
return { size: radius * 2, left: -radius, top: listTop - STUCK_TOP - radius };
|
||||
const edge = columnWidth - 8; // the furthest right it may reach
|
||||
const roomy = Math.hypot(LIST_LEFT + listBox.width + 24, STUCK_TOP + listBox.height + 24);
|
||||
if (roomy <= edge) return { size: roomy * 2, left: -roomy, top: listTop - STUCK_TOP - roomy };
|
||||
|
||||
// From the header's bottom left, with a slim margin: how far
|
||||
// right the list reaches, and its top and bottom.
|
||||
const right = LIST_LEFT + listBox.width + 8;
|
||||
const top = STUCK_TOP - 4;
|
||||
const bottom = STUCK_TOP + listBox.height + 8;
|
||||
const reach = Math.sqrt(Math.max(edge * edge - right * right, 0));
|
||||
const drop = Math.min(Math.max(0, bottom - reach), (top + bottom) / 2);
|
||||
// Off screen by `back`, if the list's corners are still out; at
|
||||
// most MAX_BACK, since a list as wide as its column can't be
|
||||
// taken in without crossing into the content (it nearly can't
|
||||
// happen: titles wrap first).
|
||||
const half = (bottom - top) / 2;
|
||||
const gap = Math.max(edge - right, 1);
|
||||
const back =
|
||||
Math.hypot(right, Math.max(bottom - drop, drop - top)) <= edge
|
||||
? 0
|
||||
: Math.min(MAX_BACK, Math.max(0, (half * half - gap * gap) / (2 * gap) - right));
|
||||
const radius = edge + back;
|
||||
return { size: radius * 2, left: -back - radius, top: listTop - STUCK_TOP + drop - radius };
|
||||
}
|
||||
return {
|
||||
size: circle,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue