Panes: one controller for the listeners, shared helpers for repeated lookups

- The panes' effect registered 25 listeners and removed each by hand;
  they share an AbortController now.
- One relayout() for the four places that laid out, measured and drew;
  one uncurve() for "curves off" and the start of the pages' marks (so
  schedule just calls curves(), which goes to pageMarks as pages);
  one handleAt() for the mouse and touch drags' handle lookup (the
  close/pin/⋯ checks before it could never match inside a grip or tab);
  ruleOf() for the rule a pane's head draws, written three times;
  setAttr from stack.ts instead of a copy; paneOfPage for the desktop
  column's pane to show, the same rule; the pin, close and W icons from
  Pages.tsx instead of copies in Chrome.
- The curves' `box` offset was a constant zero subtracted everywhere.
- Gone: glideTo's ms parameter (never passed), the "lifting" class
  (nothing reads it), Axis fields nothing reads, a dead branch in the
  map's rails, a linear search per pane in forks reorder, a stale and a
  superseded comment. Exports used only in their own file are not
  exported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
thalladaandClaude Opus 5.5 committed 2026-11-17 16:25:27 -05:00
1 parent 5d6b7a8215
commit 3aa8778427
5 files changed
+128 -170

No files matched your search

+8 -10
View File
@@ -12,22 +12,19 @@
* height less a tab for each other pane) and applies what comes back.
*/
export interface Axis {
/** The sticky inset, and the start and end of a box along the axis. */
interface Axis {
/** The sticky inset, where a box starts along the axis. */
start: "left" | "top";
end: "right" | "bottom";
size: "offsetWidth" | "offsetHeight";
client: "clientWidth" | "clientHeight";
scroll: "scrollLeft" | "scrollTop";
scrollSize: "scrollWidth" | "scrollHeight";
}
/** Across: the columns of the strip. */
export const ACROSS: Axis = { start: "left", end: "right", size: "offsetWidth", client: "clientWidth", scroll: "scrollLeft", scrollSize: "scrollWidth" };
export const ACROSS: Axis = { start: "left", size: "offsetWidth", client: "clientWidth" };
/** Down: the panes of a crowded column. */
export const DOWN: Axis = { start: "top", end: "bottom", size: "offsetHeight", client: "clientHeight", scroll: "scrollTop", scrollSize: "scrollHeight" };
export const DOWN: Axis = { start: "top", size: "offsetHeight", client: "clientHeight" };
/** An item covered to less than this share of its size shows only its strip (spine or tab). */
export const COVERED = 0.4;
const COVERED = 0.4;
/**
* Each item's sticky offset: every item before it leaves its strip, a pinned one its whole size;
@@ -77,7 +74,7 @@ export const starts = (sizes: number[]) => sizes.map((_, i) => sizes.slice(0, i)
const sum = (xs: number[]) => xs.reduce((a, b) => a + b, 0);
/** Sizes from edges (each item's start, then the end of the last), each edge rounded to a whole pixel: an item at least `min` before stays so after. */
/** Sizes from edges (each item's start, then the end of the last), each edge rounded to a whole pixel. */
const fromEdges = (e: number[]) => e.slice(1).map((x, k) => Math.round(x) - Math.round(e[k]));
/**
@@ -160,7 +157,8 @@ export function reveal(scroll: number, view: number, start: number, size: number
/** Whether an item is shown whole at this scroll. */
export const whole = (scroll: number, view: number, start: number, size: number, stuck: number) => scroll >= start + size - view - 1 && scroll <= start - stuck + 1;
const setAttr = (el: Element | undefined, name: string, on: boolean) => {
/** Set or remove a boolean attribute, touching the DOM only when it changes. */
export const setAttr = (el: Element | undefined, name: string, on: boolean) => {
if (el && el.hasAttribute(name) !== on) on ? el.setAttribute(name, "") : el.removeAttribute(name);
};