Pages: a pane's handle dragged at once resizes it, as a splitter

On a phone, a pane's tab or the band above its title moved up or down at
once (before the 380 ms hold) drags the pane's top edge with the finger:
the pane grows or shrinks and the pane above takes the difference; a tab
at the limit is pushed along (stack.ts resize, from the sizes the drag
began with, so moving back gives back what was pushed). Never less than a
tab, never past the page. Released barely taller than a tab, a pane folds
(a 120 ms ease). Direction known after 8 px: up or down resizes (the
handles of every pane but a page's first are touch-action: pan-x, so the
browser never scrolls first), sideways is the browser's swipe. A hold
still picks the pane up; a tap still selects it.

Sizes by hand hold while the page keeps its panes and the pane looked at
is shown open, across swipes; going to a folded pane there, a pane opening
or closing there, or a double tap on a handle lays the page out
automatically again. Only heights are set during a drag. Desktop panes
unchanged.

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 12:40:50 -05:00
1 parent 60b035ab38
commit d8654fdd19
7 files changed
+621 -27

No files matched your search

+13 -3
View File
@@ -142,8 +142,18 @@ Press `?` for every key. The short version:
above its title, always shown. A press held still on a pane's tab, or on the band above its title
(two faint lines mark it), picks the pane up in a page it shares: it fades, its tab rides above
the finger, a line shows where it will go, a crowded page scrolls near its top and foot, and
lifting the finger puts it there (a second finger puts it back); a swipe or a scroll that starts
there is still a swipe or a scroll. The pane's ⋯ has Move this pane up and down too. No curves are drawn (the panes
lifting the finger puts it there (a second finger puts it back); a swipe sideways that starts
there still turns the page. Moved up or down at once instead, the handle drags the pane's top
edge with the finger, as a splitter: the pane grows or shrinks and the pane above takes the
difference (a tab there opens; once it is a tab, the tab is pushed along and the pane above it
gives), never less than a tab and never past the page; a folded tab dragged up opens its pane as
far as it is dragged, and a pane dragged down to barely more than its tab folds when the finger
lifts. A page's first pane has no edge above it, so its handle sizes nothing (on a crowded page
it still scrolls the page). Sizes set so hold while the page keeps its panes and the pane looked
at there is one shown open, swiped away and back too: going to a pane folded to its tab (a tap on
the tab, the trail, the map, the keys), a pane opening or closing there, or a double tap on a
handle lays the page out automatically again (not kept across a reload). A pane looked at that is
dragged shut hands that to the pane across the edge. The pane's ⋯ has Move this pane up and down too. No curves are drawn (the panes
are never side by side): what each pane was opened from, its link's underline, a note's dotted
rule or its row's edge and arrow, takes the pane's colour instead, the colour of the rule under the
pane's title. Every step from pane to pane is a step in the browser's history, so Back, the button
@@ -359,7 +369,7 @@ What is sent where:
the store's `trail` is its focused branch); `stack.ts` is the stacking shared by the strip and its
columns (and how a column shares or stacks its height), `lanes.ts` orders the curves' lanes. The
pages layout is the same panes (`Panes.tsx`, which also glides the strip and carries a pane held
by touch) laid out a column per page, with `Pages.tsx` (the trail and the map) and `pages.ts`
or resizes one by touch, the sizes by hand being `stack.ts` `resize`, `release` and `fit`) laid out a column per page, with `Pages.tsx` (the trail and the map) and `pages.ts`
(which pane a page brings forward, the history entries a pane per step, and the map's tree lines,
pure functions).
+239
View File
@@ -970,3 +970,242 @@ test("a tap on a link only opens it: no hover card from the tap's mouse events,
await expect(page.locator(".menu.sheet .menu-card .lcard")).toBeVisible();
await expect(page.locator(".popup")).toHaveCount(0);
});
// ---- the third round: a pane's handle dragged at once resizes it ----
/** The second page's panes, measured: the page's top, foot and height, and each pane's top and height, whether it shows its tab, and which is active. */
const column = (page: Page, n = 1) =>
page.evaluate((n) => {
const col = document.querySelectorAll<HTMLElement>(".strip > .col")[n];
const c = col.getBoundingClientRect();
const ps = [...col.querySelectorAll<HTMLElement>(":scope > .pane")];
return {
top: c.top,
bottom: c.bottom,
h: c.height,
sized: col.classList.contains("sized"),
crowded: col.classList.contains("crowded"),
scroll: col.scrollTop,
panes: ps.map((p) => {
const r = p.getBoundingClientRect();
return { top: r.top, h: r.height, tab: p.hasAttribute("data-tab"), active: p.classList.contains("active"), title: p.querySelector(".tabtitle")!.textContent! };
}),
};
}, n);
type Column = Awaited<ReturnType<typeof column>>;
/** Where a finger takes pane i's handle: its tab, or the band above its title. */
const handle = (c: Column, i: number) => ({ x: 70, y: c.panes[i].top + 22 });
/**
* A finger put down on pane i's handle and moved at once by dy, a frame a step, then lifted (unless
* `lift` is false); after each step past the browser's touch slop, the pane's top edge is where the
* finger has taken it (within 1.5 px), the panes fill the page, none shorter than its tab. Returns what the page was before and
* at the end of the move.
*/
async function edgeDrag(page: Page, i: number, dy: number, opts: { steps?: number; lift?: boolean; shot?: string; dx?: number } = {}) {
const before = await column(page);
const from = handle(before, i);
const lo = before.top + i * 44;
const hi = before.bottom - (before.panes.length - i) * 44;
const n = opts.steps ?? 12;
const cdp = await page.context().newCDPSession(page);
await cdp.send("Input.dispatchTouchEvent", { type: "touchStart", touchPoints: [from] });
let last = before;
for (let k = 1; k <= n; k++) {
const d = (dy * k) / n;
await cdp.send("Input.dispatchTouchEvent", { type: "touchMove", touchPoints: [{ x: from.x + ((opts.dx ?? 0) * k) / n, y: from.y + d }] });
await page.waitForTimeout(16);
last = await column(page);
// The browser sends no move inside its touch slop (about 15 px) while the touch may still be a tap or a scroll: from the first it sends, the edge is where the finger is.
if (Math.abs(d) <= 16) continue;
const want = Math.max(lo, Math.min(hi, before.panes[i].top + d));
expect(Math.abs(last.panes[i].top - want), `step ${k}: the edge at ${last.panes[i].top}, the finger took it to ${want}`).toBeLessThanOrEqual(1.5);
expect(last.sized).toBe(true);
const sum = last.panes.reduce((s, p) => s + p.h, 0);
expect(Math.abs(sum - last.h)).toBeLessThanOrEqual(1);
for (const p of last.panes) expect(p.h).toBeGreaterThanOrEqual(43.5);
// One under another, nothing stacked.
for (let j = 1; j < last.panes.length; j++) expect(Math.abs(last.panes[j].top - (last.panes[j - 1].top + last.panes[j - 1].h))).toBeLessThanOrEqual(1);
}
if (opts.shot) await shot(page, opts.shot);
if (opts.lift !== false) await cdp.send("Input.dispatchTouchEvent", { type: "touchEnd", touchPoints: [] });
await cdp.detach();
await page.waitForTimeout(200);
return { before, last };
}
/** Make the pane at index i of the second page the active one, by a tap on its tab (or its band). */
async function tapPane(page: Page, i: number) {
const c = await column(page);
await touchTap(page, handle(c, i).x, handle(c, i).y);
await expect.poll(async () => (await column(page)).panes[i].active).toBe(true);
}
for (const [width, height] of [
[390, 844],
[360, 640],
] as const)
test(`at ${width}×${height}, a pane's handle dragged at once moves its edge with the finger: a tab opens, a pane folds, the limits hold; a tap, a hold, a swipe do what they did; the sizes stay`, async ({ page }) => {
await page.setViewportSize({ width, height });
await start(page);
await stackFromLibrary(page, ["Fixed points", "Octopus minds"]);
// The first pane looked at: the second folded to its tab at the foot.
let c = await column(page);
if (!c.panes[0].active) await tapPane(page, 0);
c = await column(page);
expect(c.crowded).toBe(true);
expect(c.panes[1].tab).toBe(true);
const H = c.h;
// The folded tab dragged up: the pane opens as far as it is dragged, the pane above gives it the room.
let r = await edgeDrag(page, 1, -260, { shot: `40-tab-dragged-open-${width}` });
c = await column(page);
expect(c.sized).toBe(true);
expect(c.crowded).toBe(false);
expect(Math.abs(c.panes[1].top - (r.before.panes[1].top - 260))).toBeLessThanOrEqual(1);
expect(Math.abs(c.panes[0].h - (c.panes[1].top - c.top))).toBeLessThanOrEqual(1);
expect(c.panes.map((p) => p.tab)).toEqual([false, false]);
expect(c.panes[0].active).toBe(true);
// The page neither turned nor scrolled.
expect(await pageIndex(page)).toBe(1);
expect(c.scroll).toBe(0);
await shot(page, `41-two-sized-${width}`);
// Its band dragged down: smaller again, the pane above taller.
r = await edgeDrag(page, 1, 90);
c = await column(page);
expect(Math.abs(c.panes[1].top - (r.before.panes[1].top + 90))).toBeLessThanOrEqual(1);
// Up past the top: the pane above is a tab, no less; the pane looked at folded hands that to the one across the edge.
await edgeDrag(page, 1, -2000, { steps: 16 });
c = await column(page);
expect(Math.abs(c.panes[1].top - (c.top + 44))).toBeLessThanOrEqual(1);
expect(c.panes.map((p) => p.tab)).toEqual([true, false]);
await expect.poll(async () => (await column(page)).panes[1].active).toBe(true);
expect((await column(page)).sized).toBe(true);
await shot(page, `42-dragged-to-the-top-${width}`);
// Down past the foot: folded to its tab at the foot, the pane above all the rest.
await edgeDrag(page, 1, 2000, { steps: 16 });
c = await column(page);
expect(Math.abs(c.panes[1].h - 44)).toBeLessThanOrEqual(1);
expect(Math.abs(c.panes[1].top - (c.bottom - 44))).toBeLessThanOrEqual(1);
expect(c.panes.map((p) => p.tab)).toEqual([false, true]);
await expect.poll(async () => (await column(page)).panes[0].active).toBe(true);
// Barely opened, it folds back when the finger lifts; dragged down to barely more than a tab, it folds.
await edgeDrag(page, 1, -30);
await expect.poll(async () => Math.round((await column(page)).panes[1].h)).toBe(44);
expect((await column(page)).panes[1].tab).toBe(true);
await edgeDrag(page, 1, -300);
c = await column(page);
expect(c.panes[1].h).toBeGreaterThan(300);
await edgeDrag(page, 1, c.panes[1].h - 44 - 25);
await expect.poll(async () => Math.round((await column(page)).panes[1].h)).toBe(44);
// Open again to a middle height, then: swiped away and back, the sizes stay.
await edgeDrag(page, 1, -Math.round(H * 0.45));
const kept = await column(page);
expect(kept.panes.every((p) => !p.tab)).toBe(true);
await swipe(page, 260);
await at(page, "Library", 0);
await swipe(page, -260);
await expect.poll(() => pageIndex(page)).toBe(1);
await expect.poll(() => snapped(page)).toBe(true);
c = await column(page);
expect(c.sized).toBe(true);
for (const [j, p] of c.panes.entries()) expect(Math.abs(p.h - kept.panes[j].h)).toBeLessThanOrEqual(1);
// A swipe sideways starting on a handle still turns the page, and the sizes stay.
await swipe(page, 260, 0, { x: 80, y: c.panes[1].top + 22 });
await at(page, "Library", 0);
await swipe(page, -260, 0, { x: 310, y: 520 });
await expect.poll(() => pageIndex(page)).toBe(1);
await expect.poll(() => snapped(page)).toBe(true);
c = await column(page);
for (const [j, p] of c.panes.entries()) expect(Math.abs(p.h - kept.panes[j].h)).toBeLessThanOrEqual(1);
// A tap on the other pane's band makes it the one looked at; it is open, so the sizes stay.
const other = c.panes.findIndex((p) => !p.active);
await tapPane(page, other);
c = await column(page);
expect(c.sized).toBe(true);
for (const [j, p] of c.panes.entries()) expect(Math.abs(p.h - kept.panes[j].h)).toBeLessThanOrEqual(1);
// A hold, then a drag: still moves the pane (each keeps its size).
const titles = c.panes.map((p) => p.title);
const sizeOf = new Map(c.panes.map((p) => [p.title, p.h]));
await press(page, handle(c, 1), { hold: 500, to: [{ x: 70, y: c.top + 10 }] });
await expect.poll(async () => (await column(page)).panes.map((p) => p.title)).toEqual([titles[1], titles[0]]);
c = await column(page);
expect(c.sized).toBe(true);
for (const p of c.panes) expect(Math.abs(p.h - sizeOf.get(p.title)!)).toBeLessThanOrEqual(1);
await shot(page, `43-reordered-sized-${width}`);
// A double tap on a handle: the automatic sizes again, the pane tapped has the page's height.
const h1 = handle(c, 1);
await touchTap(page, h1.x, h1.y);
await page.waitForTimeout(60);
await touchTap(page, h1.x, h1.y);
await expect.poll(async () => (await column(page)).sized).toBe(false);
c = await column(page);
expect(c.crowded).toBe(true);
expect(c.panes[1].active).toBe(true);
expect(c.panes[0].tab).toBe(true);
});
test("three panes: the edge pushes the tabs ahead of it and gives back what it pushed; the pane gone to while folded brings the automatic sizes back", async ({ page }) => {
await start(page);
await stackFromLibrary(page, ["Fixed points", "Octopus minds", "Where the elements come from"]);
// The middle pane looked at: a tab above it, a tab below.
let c = await column(page);
if (!c.panes[1].active) {
await state(page, (s) => s.toPane(s.paneColumns.get(1)[1].node.id));
await expect.poll(async () => (await column(page)).panes[1].active).toBe(true);
}
c = await column(page);
expect(c.panes.map((p) => p.tab)).toEqual([true, false, true]);
const T = c.top;
// The last tab dragged up past the middle pane: the middle one is pushed up as a tab, and back down, given back its height, all in one drag.
const from = handle(c, 2);
const cdp = await page.context().newCDPSession(page);
await cdp.send("Input.dispatchTouchEvent", { type: "touchStart", touchPoints: [from] });
const path = [-40, -120, -240, -400, -600, -900, -2000, -900, -240];
for (const d of path) {
await cdp.send("Input.dispatchTouchEvent", { type: "touchMove", touchPoints: [{ x: from.x, y: from.y + d }] });
await page.waitForTimeout(16);
const now = await column(page);
const want = Math.max(T + 88, from.y - 22 + d);
expect(Math.abs(now.panes[2].top - want), `at ${d}`).toBeLessThanOrEqual(1.5);
// The first pane stays a tab throughout; the middle one is a tab at the limit, pushed along.
expect(Math.abs(now.panes[0].h - 44)).toBeLessThanOrEqual(1);
expect(Math.abs(now.panes[1].h - Math.max(44, want - (T + 44)))).toBeLessThanOrEqual(1.5);
if (d === -2000) await shot(page, "44-three-pushed");
}
await cdp.send("Input.dispatchTouchEvent", { type: "touchEnd", touchPoints: [] });
await cdp.detach();
await page.waitForTimeout(200);
c = await column(page);
expect(c.panes.map((p) => p.tab)).toEqual([true, false, false]);
expect(c.panes[1].active).toBe(true);
await shot(page, "45-three-sized");
// The middle pane's band dragged down: the tab above it opens.
const r = await edgeDrag(page, 1, 160);
c = await column(page);
expect(Math.abs(c.panes[0].h - (44 + 160))).toBeLessThanOrEqual(1);
expect(Math.abs(c.panes[2].h - r.before.panes[2].h)).toBeLessThanOrEqual(1);
expect(c.panes.every((p) => !p.tab)).toBe(true);
await shot(page, "46-three-open");
// The first pane's handle has no edge above it: moved down, nothing changes, and it is not picked up.
const before = await column(page);
await press(page, handle(before, 0), { to: [{ x: 70, y: before.panes[0].top + 22 + 120 }] });
c = await column(page);
for (const [j, p] of c.panes.entries()) expect(Math.abs(p.h - before.panes[j].h)).toBeLessThanOrEqual(1);
expect(c.panes.map((p) => p.title)).toEqual(before.panes.map((p) => p.title));
// Folded again, and gone to by a tap on its tab: the page is laid out automatically, that pane with the height.
await edgeDrag(page, 1, -2000, { steps: 10 });
c = await column(page);
expect(c.panes[0].tab).toBe(true);
await tapPane(page, 0);
await expect.poll(async () => (await column(page)).sized).toBe(false);
c = await column(page);
expect(c.panes[0].h).toBeGreaterThan(c.h - 2 * 44 - 2);
expect(c.panes.map((p) => p.tab)).toEqual([false, true, true]);
// A pane opened on the page: automatic too.
await edgeDrag(page, 2, -200);
expect((await column(page)).sized).toBe(true);
await stackFromLibrary(page, ["What a proof is"]);
await expect.poll(async () => (await column(page)).panes.length).toBe(4);
expect((await column(page)).sized).toBe(false);
});
+233 -18
View File
@@ -19,7 +19,7 @@ import { Component, type ComponentChildren } from "preact";
import { useEffect, useLayoutEffect, useRef } from "preact/hooks";
import { ancestors, label, sections, staleness, type NodeId } from "../core/model";
import { LANES, LANE_FIRST, LANE_LAST, LANE_PITCH, laneOrder } from "./lanes";
import { ACROSS, DOWN, crowds, fill, mark, offsets, reveal, starts, stick, unmark, whole } from "./stack";
import { ACROSS, DOWN, crowds, fill, fit, folded, mark, offsets, release, resize, reveal, starts, stick, unmark, whole } from "./stack";
import { NodeBacklinks, NodeRelated, PaneCtx, TargetRow } from "./Links";
import { pageAt, paneOfPage } from "./pages";
import { Abstract, Flags, NodeBody, PendingSections, Row, TitleEditor, TopMatter, isPrompt } from "./Node";
@@ -139,7 +139,7 @@ function Chrome({ props, title, mark }: { props: PaneProps; title: string; mark?
{title}
</span>
</div>
<div class="grip" data-grip={tid} title="Drag to move this pane up or down its column (on a phone, hold it first)" onTouchMove={onHandleMove} />
<div class="grip" data-grip={tid} title="Drag to move this pane up or down its column (on a phone, hold it first; dragged at once, it resizes the pane)" onTouchMove={onHandleMove} />
<div class="tabline" data-spine={props.index} title={title} onTouchMove={onHandleMove}>
{mark}
<span class="tabtitle">{title}</span>
@@ -344,6 +344,78 @@ const onHandleMove = (e: TouchEvent) => handleMove?.(e);
/** How long the mouse rests on a covered pane before it peeks out. */
export const PEEK_MS = 200;
/** As pages, how far a finger moves on a pane's handle before its direction is known: up or down resizes the pane, sideways is the browser's (the page turns). */
export const LOCK_PX = 8;
/** As pages, a pane sized by hand left less than this much taller than its tab folds to it when the finger lifts. */
export const FOLD_SNAP = 40;
/** As pages, how long a released edge takes to come to rest at a fold, easing out. */
export const SNAP_MS = 120;
/** As pages, two taps on a pane's handle this close together put its page back to the automatic sizes. */
export const DOUBLE_TAP_MS = 320;
/**
* As pages, a page sized by hand (Panes' touch handlers, stack.ts `resize`): each pane's height
* by its id, the panes it holds (their ids, sorted), and the pane looked at there. By column. The
* sizes hold while the same panes are on the page and the pane looked at is one shown open; when
* another pane there becomes the one looked at while folded to its tab (a tap on its tab, the trail,
* the map, the keys), when a pane opens or closes there, or on a double tap on a handle, the page
* is laid out automatically again.
*/
interface Hand {
set: string;
sizes: Map<number, number>;
here: number | undefined;
}
const hands = new Map<number, Hand>();
/** The page whose released edge is easing to rest: laid out by its animation alone meanwhile. */
let easing: HTMLElement | null = null;
const setOf = (tids: number[]) => [...tids].sort((a, b) => a - b).join();
/** A column's sizes by hand, fitted to its height, if they hold (else they are dropped). */
function handSizes(col: number, tids: number[], here: number | undefined, h: number): number[] | null {
const m = hands.get(col);
if (!m) return null;
const drop = () => (hands.delete(col), null);
if (m.set !== setOf(tids)) return drop();
if (here !== m.here) {
if (here === undefined || folded(m.sizes.get(here) ?? 0, TAB)) return drop();
m.here = here;
}
let hs = tids.map((t) => m.sizes.get(t) ?? TAB);
if (Math.abs(hs.reduce((a, b) => a + b, 0) - h) >= 0.5) {
const f = fit(hs, h, TAB);
if (!f) return drop();
hs = f;
tids.forEach((t, i) => m.sizes.set(t, f[i]));
}
return hs;
}
/** Set the panes' heights, and show the tab of each folded to it. Only heights: nothing is measured. */
function setHeights(ps: HTMLElement[], hs: number[]) {
ps.forEach((p, i) => {
const v = `${hs[i]}px`;
if (p.style.height !== v) p.style.height = v;
setAttr(p, "data-tab", folded(hs[i], TAB));
});
}
/** Lay a column out by hand: its panes one under another at these heights, filling it; nothing stacked, nothing stuck. */
function sizeBy(c: HTMLElement, ps: HTMLElement[], hs: number[]) {
if (!c.classList.contains("sized")) {
c.classList.add("sized");
c.classList.remove("crowded");
unmark(ps);
}
for (const p of ps) {
if (p.style.top) p.style.top = "";
if (p.style.bottom) p.style.bottom = "";
if (p.style.flex !== "none") p.style.flex = "none";
}
setHeights(ps, hs);
if (c.scrollTop) c.scrollTop = 0;
}
/** The panes drawn, by their id in the forest. */
const paneEls = (el: HTMLElement) => {
const m = new Map<number, HTMLElement>();
@@ -431,16 +503,30 @@ export function Panes() {
const ps = [...c.children].filter((p): p is HTMLElement => p.classList.contains("pane"));
if (ps.length < 2) {
for (const p of ps) if (p.style.height) (p.style.height = ""), (p.style.flex = ""), (p.style.top = ""), (p.style.bottom = "");
c.classList.remove("crowded");
c.classList.remove("crowded", "sized", "tight");
unmark(ps);
continue;
}
const h = c.clientHeight;
const col = Number(c.dataset.col);
const tids = ps.map((p) => Number(p.dataset.tid));
// The pane to show whole: on the focused branch, or the one last on it here.
const here = tids.find((t) => onBranch.has(t)) ?? (tids.includes(lastIn.current.get(col)!) ? lastIn.current.get(col)! : tids[0]);
const sig = tids.map((t, i) => `${t}${ps[i].classList.contains("pinned") ? "^" : ""}`).join();
// As pages, a page too short for a tab for each of its panes is never sized by hand (its handles scroll it).
c.classList.toggle("tight", pages && ps.length * TAB > h);
// As pages, sized by hand (a pane's handle dragged): those sizes, while they hold.
const hand = pages ? handSizes(col, tids, here, h) : null;
if (hand) {
if (easing !== c) sizeBy(c, ps, hand);
laid.current.set(c, sig);
shown.current.set(c, here);
continue;
}
c.classList.remove("sized");
const sc = ps[0].querySelector<HTMLElement>(".pane-scroll")!;
const cs = getComputedStyle(sc);
const pad = parseFloat(cs.paddingTop) + parseFloat(cs.paddingBottom) + 1;
const tids = ps.map((p) => Number(p.dataset.tid));
// What each pane needs to show all it holds; a buried pane is not laid out, so it keeps what it last needed.
const need = ps.map((p, i) => {
if (p.hasAttribute("data-buried") && needs.current.has(tids[i])) return needs.current.get(tids[i])!;
@@ -449,8 +535,6 @@ export function Panes() {
return n;
});
const pinned = ps.map((p) => p.classList.contains("pinned"));
// The pane to show whole: on the focused branch, or the one last on it here.
const here = tids.find((t) => onBranch.has(t)) ?? (tids.includes(lastIn.current.get(col)!) ? lastIn.current.get(col)! : tids[0]);
const k = tids.indexOf(here);
// As pages the pane looked at has the screen's height whenever a share would cut it short: the others fold to their tabs.
const crowded = crowds(h, need, PANE_MIN, pages ? k : undefined);
@@ -484,7 +568,6 @@ export function Panes() {
const st = starts(heights);
const want = crowded ? reveal(c.scrollTop, h - below[k], st[k], heights[k], tops[k], st[st.length - 1] + heights[heights.length - 1] - h) : 0;
// As the focus moves, the active pane's column scrolls at once and the others once the keys pause (each brings whole panes into view, which costs a frame's painting); any other change, at once.
const sig = tids.map((t, i) => `${t}${pinned[i] ? "^" : ""}`).join();
const same = laid.current.get(c) === sig;
laid.current.set(c, sig);
const moved = shown.current.get(c) !== here;
@@ -518,6 +601,8 @@ export function Panes() {
else mark(el, colEls, ACROSS, false, colEls[0]?.querySelector<HTMLElement>(".spine")?.offsetWidth ?? 0);
for (const c of colEls) {
const ps = [...c.querySelectorAll<HTMLElement>(":scope > .pane")];
// Sized by hand: its tabs are those panes folded (sizeBy).
if (c.classList.contains("sized")) continue;
if (!c.classList.contains("crowded")) {
for (const p of ps) setAttr(p, "data-tab", false);
continue;
@@ -925,12 +1010,12 @@ export function Panes() {
/*
* As pages, by touch: a press held still on a pane's tab, or on the band above its title
* (HOLD_MS, never moving more than a few pixels, so a swipe still turns the page and a drag down
* still scrolls) picks the pane up: it fades where it is, its tab rides with the finger, and the
* line shows where it will go. Near the column's top or foot a crowded column scrolls on its
* own. Lifting the finger puts it there; a second finger, or the touch being cancelled, puts it
* back. Only the handles listen to touchmove blocking (Chrome `onTouchMove`), and only a lifted
* pane's moves are held from the browser's scrolling.
* (HOLD_MS, never moving more than a few pixels, so a swipe still turns the page and a drag up
* or down still resizes, below) picks the pane up: it fades where it is, its tab rides with the
* finger, and the line shows where it will go. Near the column's top or foot a crowded column
* scrolls on its own. Lifting the finger puts it there; a second finger, or the touch being
* cancelled, puts it back. Only the handles listen to touchmove blocking (Chrome `onTouchMove`),
* and only a lifted pane's moves, or an edge's, are held from the browser.
*/
let hold: { timer: ReturnType<typeof setTimeout>; x: number; y: number; id: number; pane: HTMLElement; col: HTMLElement } | null = null;
let ghost: HTMLElement | null = null;
@@ -978,22 +1063,118 @@ export function Panes() {
dropAt(lastY);
if (drag.col.scrollTop !== was) edge = requestAnimationFrame(edgeScroll);
};
/*
* As pages, by touch, a pane's handle (its tab, or the band above its title) moved up or down at
* once, before the hold picks the pane up, drags the pane's top edge with the finger, as a
* splitter (stack.ts `resize`): the pane grows or shrinks, the pane above it takes the
* difference, a tab is pushed along at the limit. The direction is known after LOCK_PX: up or
* down resizes (the handles' touch-action leaves only sideways to the browser, so nothing
* scrolls first), sideways is the browser's, a swipe that turns the page. During the drag only
* the panes' heights are set. When the finger lifts, a pane left barely taller than its tab
* folds (SNAP_MS). The sizes hold as `hands` says; a double tap on a handle drops them.
*/
let press: { x: number; y: number; id: number; pane: HTMLElement; col: HTMLElement; i: number; lock: "v" | null; start: number[]; ps: HTMLElement[]; now: number[]; dy: number } | null = null;
let lastTap: { col: HTMLElement; t: number; x: number; y: number } | null = null;
let snapping = 0;
/** The handle's page laid out by hand from what shows of each pane now (no jump): false if it cannot be (a tab each does not fit). */
const startResize = (r: NonNullable<typeof press>): boolean => {
const ps = [...r.col.querySelectorAll<HTMLElement>(":scope > .pane")];
const h = r.col.clientHeight;
if (r.i < 1 || ps.length * TAB > h || !ps.includes(r.pane)) return false;
const c = r.col.getBoundingClientRect();
const crowded = r.col.classList.contains("crowded");
const tops = ps.map((p) => p.getBoundingClientRect());
const vis = ps.map((_, k) => Math.max(0, Math.min(tops[k].bottom, c.bottom, crowded ? (tops[k + 1]?.top ?? Infinity) : Infinity) - Math.max(tops[k].top, c.top)));
const start = fit(vis, h, TAB);
if (!start) return false;
cancelAnimationFrame(snapping);
easing = null;
unpeek();
const tids = ps.map((p) => Number(p.dataset.tid));
const was = hands.get(Number(r.col.dataset.col));
hands.set(Number(r.col.dataset.col), { set: setOf(tids), sizes: new Map(tids.map((t, k) => [t, start[k]])), here: was?.here ?? shown.current.get(r.col) });
sizeBy(r.col, ps, start);
Object.assign(r, { ps, start, now: start, i: ps.indexOf(r.pane) });
wrap.classList.add("resizing");
return true;
};
const moveResize = (r: NonNullable<typeof press>, dy: number) => {
r.dy = dy;
r.now = resize(r.start, r.i, dy, TAB);
setHeights(r.ps, r.now);
const m = hands.get(Number(r.col.dataset.col));
if (m) r.ps.forEach((p, k) => m.sizes.set(Number(p.dataset.tid), r.now[k]));
};
/** The finger lifted: the edge comes to rest, at a fold if a pane is left barely taller than its tab; a pane looked at folded away hands that to the pane across the edge. */
const endResize = (r: NonNullable<typeof press>) => {
wrap.classList.remove("resizing");
const to = release(r.start, r.i, r.dy, TAB, FOLD_SNAP);
const tids = r.ps.map((p) => Number(p.dataset.tid));
const col = Number(r.col.dataset.col);
const m = hands.get(col);
// Dropped while the finger was down (its panes changed): laid out automatically.
if (!m) return void (latest.current(true), measure(), schedule());
tids.forEach((t, k) => m.sizes.set(t, to[k]));
const from = r.now;
cancelAnimationFrame(snapping);
easing = null;
if (reducedMotion() || from.every((x, k) => Math.abs(x - to[k]) < 0.5)) setHeights(r.ps, to);
else {
let t0 = -1;
easing = r.col;
const step = (now: number) => {
if (t0 < 0) t0 = now - 1000 / 60;
const p = Math.min(1, (now - t0) / SNAP_MS);
const e = 1 - (1 - p) ** 3;
// Its panes changed meanwhile: the layout has it now.
if (!r.ps.every((x) => x.isConnected) || !hands.has(col)) return void (easing = null, latest.current(true));
setHeights(r.ps, p < 1 ? from.map((x, k) => x + (to[k] - x) * e) : to);
if (p < 1) snapping = requestAnimationFrame(step);
else easing = null;
};
snapping = requestAnimationFrame(step);
}
const active = store.branchNodes[store.paneAt]?.id;
const a = active === undefined ? -1 : tids.indexOf(active);
if (a < 0 || !folded(to[a], TAB)) return;
const across = a === r.i ? r.i - 1 : a === r.i - 1 ? r.i : -1;
const k = across >= 0 && !folded(to[across], TAB) ? across : to.indexOf(Math.max(...to));
m.here = tids[k];
store.toPane(tids[k]);
};
/** A double tap on a handle: the page laid out automatically again. */
const unsize = (col: HTMLElement) => {
if (!hands.delete(Number(col.dataset.col))) return;
cancelAnimationFrame(snapping);
easing = null;
latest.current(true);
measure();
schedule();
};
const onHoldStart = (e: TouchEvent) => {
if (!store.pages) return;
// A second finger: whatever was being picked up or carried goes back.
if (e.touches.length > 1) return void (hold || drag?.touch ? end(false) : undefined);
// A second finger: whatever was being picked up or carried goes back; an edge being dragged stays where it is.
if (e.touches.length > 1) {
if (press?.lock) endResize(press);
press = null;
return void (hold || drag?.touch ? end(false) : undefined);
}
press = null;
const t = e.target as HTMLElement;
if (t.closest("[data-close], [data-pin], [data-more]")) return;
const handle = t.closest<HTMLElement>("[data-grip], .tabline");
const pane = handle?.closest<HTMLElement>(".pane");
const col = pane?.parentElement as HTMLElement | undefined;
if (!handle || !pane || !col || col.querySelectorAll(":scope > .pane").length < 2) return;
if (!handle || !pane || !col) return;
const ps = [...col.querySelectorAll<HTMLElement>(":scope > .pane")];
if (ps.length < 2) return;
const p = e.changedTouches[0];
cancelHold();
press = { x: p.clientX, y: p.clientY, id: p.identifier, pane, col, i: ps.indexOf(pane), lock: null, start: [], ps: [], now: [], dy: 0 };
hold = { timer: setTimeout(lift, HOLD_MS), x: p.clientX, y: p.clientY, id: p.identifier, pane, col };
};
const touchOf = (e: TouchEvent, id: number) => [...e.touches].find((x) => x.identifier === id);
// Passive, on the strip: a press that moves before it is held long enough is a swipe or a scroll, and picks nothing up.
// Passive, on the strip: a press that moves before it is held long enough is a swipe, a scroll or a resize, and picks nothing up.
const onHoldMove = (e: TouchEvent) => {
if (!hold) return;
const p = touchOf(e, hold.id);
@@ -1001,21 +1182,55 @@ export function Panes() {
};
// Blocking, on the handles only (Chrome's onTouchMove): a lifted pane follows the finger, and the page does not scroll.
handleMove = (e: TouchEvent) => {
if (!drag?.touch) return;
if (drag?.touch) {
e.preventDefault();
const p = [...e.touches][0];
if (!p) return;
lastY = p.clientY;
dropAt(lastY);
if (!edge) edge = requestAnimationFrame(edgeScroll);
return;
}
const r = press;
const p = r && touchOf(e, r.id);
if (!r || !p) return;
const dx = p.clientX - r.x;
const dy = p.clientY - r.y;
if (!r.lock) {
if (Math.max(Math.abs(dx), Math.abs(dy)) < LOCK_PX) return;
// Sideways: a swipe, the browser's. Up or down on the first pane's handle: it has no edge above it to move.
if (Math.abs(dy) <= Math.abs(dx) || !startResize(r)) return void (press = null);
r.lock = "v";
cancelHold();
}
// Held from the browser: the page neither turns nor scrolls under the edge.
if (e.cancelable) e.preventDefault();
moveResize(r, dy);
};
const onHoldEnd = (e: TouchEvent) => {
if (drag?.touch) {
// No click after it: the drop is all it does.
if (e.cancelable) e.preventDefault();
press = null;
return end(e.type === "touchend");
}
cancelHold();
const r = press;
if (!r || [...e.touches].some((x) => x.identifier === r.id)) return;
press = null;
if (r.lock) {
// No click after it either: the edge is all it moved.
if (e.cancelable) e.preventDefault();
return endResize(r);
}
// A tap: the browser's click selects the pane. A second soon after on a handle of the same page: the automatic sizes again.
const p = e.changedTouches[0];
const now = performance.now();
if (e.type === "touchend" && lastTap && lastTap.col === r.col && now - lastTap.t < DOUBLE_TAP_MS && p && Math.hypot(p.clientX - lastTap.x, p.clientY - lastTap.y) < 40) {
lastTap = null;
return unsize(r.col);
}
lastTap = e.type === "touchend" && p ? { col: r.col, t: now, x: p.clientX, y: p.clientY } : null;
};
// The browser's own long press (a menu, a callout) has nothing to offer while a pane is held or carried.
const onLongPress = (e: Event) => {
+1 -1
View File
@@ -31,7 +31,7 @@ export const HELP: [string, [string, string][]][] = [
["", "right-click (a long press on a phone) on words, a row, a link, a note or a pane: what can be done with it, Copy first. Shift+right-click is the browser's own menu"],
["", "⋯ by a row, a pane's pin, a page's byline or a note (shown when pointed at): the same menu. A stale flag, clicked, offers what to do about it"],
["", "the top bar: the library's name (it opens the libraries panel), undo, redo, and menu: libraries, jump, history, links, layout and settings. A key named in the status line or a panel's head is a button that presses it"],
["", "on a phone the panes are pages, a column each: a tap on a row or a link goes to its pane, a swipe sideways goes from page to page, Back goes back a pane. The pane gone to has the page's height; the others in its column fold to their tabs. The trail at the foot names the panes on the way, each in its colour (a tap goes there), with a dot for each pane in that page's column, the one on the way filled; its map draws every open pane as a tree, each branch in its colour, to go to, pin or close. What a pane was opened from takes its colour. A long press on a link shows what it opens; a tap on one only opens it. A press held on a pane's tab, or on the band above its title, picks the pane up to move it up or down its page (the pane's ⋯ has Move up and Move down too)"],
["", "on a phone the panes are pages, a column each: a tap on a row or a link goes to its pane, a swipe sideways goes from page to page, Back goes back a pane. The pane gone to has the page's height; the others in its column fold to their tabs. The trail at the foot names the panes on the way, each in its colour (a tap goes there), with a dot for each pane in that page's column, the one on the way filled; its map draws every open pane as a tree, each branch in its colour, to go to, pin or close. What a pane was opened from takes its colour. A long press on a link shows what it opens; a tap on one only opens it. A press held on a pane's tab, or on the band above its title, picks the pane up to move it up or down its page (the pane's ⋯ has Move up and Move down too); dragged up or down at once, it moves the pane's top edge with the finger, resizing it against the pane above (a tab dragged up opens, a pane dragged down to its tab folds); the sizes hold until a folded pane there is gone to, its panes change, or a double tap on a handle"],
["", "in the libraries panel a click on a row opens that library; its ⋯ (or a right-click) offers open, rename, delete and a new library; a press outside the panel closes it"],
],
],
+63
View File
@@ -75,6 +75,69 @@ export function crowds(h: number, needs: number[], least: number, here?: number)
/** Where each item begins when nothing is stuck: one after another. */
export const starts = (sizes: number[]) => sizes.map((_, i) => sizes.slice(0, i).reduce((a, b) => a + b, 0));
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. */
const fromEdges = (e: number[]) => e.slice(1).map((x, k) => Math.round(x) - Math.round(e[k]));
/**
* As pages, a column sized by hand: the heights of its panes, top to bottom, filling the column,
* each at least `min` (a tab; a pane that height is folded). Dragging a pane's handle moves its top
* edge, the edge it shares with the pane above, to where it was when the drag began plus dy, as far
* as the panes can give: moved up, the pane above gives, and once that is a tab the one above it,
* pushed up as a tab, and so on; moved down, the dragged pane gives, then the ones below it. The
* pane on the other side of the edge takes what is given (a tab there opens). Always from the sizes
* the drag began with, so moving back gives back what was pushed. The first pane's top is the
* column's: it has no edge to move.
*/
export function resize(start: number[], i: number, dy: number, min: number): number[] {
const n = start.length;
if (i <= 0 || i >= n) return start.slice();
const total = sum(start);
const e = [...starts(start), total];
e[i] = Math.max(i * min, Math.min(total - (n - i) * min, e[i] + dy));
for (let k = i - 1; k >= 1; k--) e[k] = Math.min(e[k], e[k + 1] - min);
for (let k = i + 1; k < n; k++) e[k] = Math.max(e[k], e[k - 1] + min);
return e.slice(1).map((x, k) => x - e[k]);
}
/**
* Where a drag of pane i's edge by dy comes to rest when the finger lifts: as `resize`, except that
* a pane on either side of the edge left less than `snap` taller than a tab folds to its tab (the
* pane across the edge taking the rest), the shorter of the two if both are; in whole pixels.
*/
export function release(start: number[], i: number, dy: number, min: number, snap: number): number[] {
const h = resize(start, i, dy, min);
if (i <= 0 || i >= h.length) return fromEdges([...starts(h), sum(h)]);
const below = h[i] - min;
const above = h[i - 1] - min;
const foldBelow = below > 0.5 && below < snap;
const foldAbove = above > 0.5 && above < snap;
const d = foldBelow && (!foldAbove || below <= above) ? dy + below : foldAbove ? dy - above : dy;
const out = resize(start, i, d, min);
return fromEdges([...starts(out), sum(out)]);
}
/**
* Sizes made to fill a column of height h, each at least `min`: what each has beyond a tab is
* scaled to what the column has beyond a tab each (a folded pane stays folded); null if the column
* cannot hold a tab for every pane. For sizes measured off the screen, and for a column whose
* height changed (the window, an on-screen keyboard).
*/
export function fit(sizes: number[], h: number, min: number): number[] | null {
const n = sizes.length;
if (!n || n * min > h) return null;
if (Math.abs(sum(sizes) - h) < 0.5 && sizes.every((s) => s >= min)) return sizes.slice();
const extra = sizes.map((s) => Math.max(0, s - min));
const ex = sum(extra);
const room = h - n * min;
const out = ex > 0 ? extra.map((x) => min + (x * room) / ex) : sizes.map((_, k) => min + (k === n - 1 ? room : 0));
return fromEdges([...starts(out), h]);
}
/** Whether a pane of this height, sized by hand, is folded to its tab. */
export const folded = (size: number, min: number) => size <= min + 1;
/**
* How covered each item is, from where each begins on screen now, its size and where the box ends:
* an item shows up to where the next begins (or the box's end); overlapped when any of it is
+14 -4
View File
@@ -425,7 +425,7 @@ kbd, .help code { font-family: var(--mono); font-size: 0.86em; border: 1px solid
}
.tabline .tabtitle { overflow: hidden; text-overflow: ellipsis; }
.tabline:hover { color: var(--fg); }
.col.crowded > .pane[data-tab] > .tabline { opacity: 1; pointer-events: auto; }
.col.crowded > .pane[data-tab] > .tabline, .col.sized > .pane[data-tab] > .tabline { opacity: 1; pointer-events: auto; }
/* A pane scrolled past its own title shows its tab at its top as well, over its text (Panes.tsx watchHead). */
.pane[data-scrolled] > .tabline { opacity: 1; pointer-events: auto; }
/* Its title centred between the rule across the pane's top (heavy on the active pane) and its foot. */
@@ -452,14 +452,14 @@ kbd, .help code { font-family: var(--mono); font-size: 0.86em; border: 1px solid
.grip { position: absolute; z-index: 3; top: 0; left: var(--spine); right: 4.6rem; height: 1.15rem; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.grip::before { content: ""; position: absolute; left: 50%; top: 0.42rem; width: 1.1rem; margin-left: -0.55rem; height: 3px; border-top: 1px solid var(--faint); border-bottom: 1px solid var(--faint); opacity: 0; transition: opacity 0.12s; }
.col.split .grip:hover::before { opacity: 0.8; }
.col:not(.split) .grip, .col.crowded > .pane[data-tab] > .grip { display: none; }
.col:not(.split) .grip, .col.crowded > .pane[data-tab] > .grip, .col.sized > .pane[data-tab] > .grip { display: none; }
.tabline { touch-action: none; }
.panes.dragging, .panes.dragging * { cursor: grabbing !important; user-select: none; }
.drop-line { position: absolute; z-index: 7; height: 2px; background: var(--link); pointer-events: none; }
/* A pane's pin and ×, top right, in the margin above its title: quiet until pointed at. A pinned pane's pin is filled. */
.pane-ctl { position: absolute; z-index: 3; top: 0.25rem; right: 0.3rem; display: flex; gap: 0.05rem; }
.col.crowded > .pane[data-tab] > .pane-ctl { top: 2px; }
.col.crowded > .pane[data-tab] > .pane-ctl, .col.sized > .pane[data-tab] > .pane-ctl { top: 2px; }
.pane-btn { display: block; width: 1.3rem; height: 1.3rem; padding: 0.3rem; border-radius: 2px; cursor: pointer; color: var(--rule); }
.pane-btn svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.pane:hover .pane-btn { color: var(--faint); }
@@ -970,11 +970,21 @@ html { scroll-padding-top: 48px; }
/*
* A pane in a page shared with others is moved up or down it by a press held on its tab or on the
* band above its title, left of its buttons (Panes.tsx): two faint lines mark that band. A swipe
* across either still turns the page, and one down still scrolls; held, the pane lifts.
* across either still turns the page; held, the pane lifts; dragged up or down at once, its top
* edge moves (below).
*/
.panes[data-layout="pages"] .grip { left: var(--spine); right: 132px; height: 44px; touch-action: pan-x pan-y; cursor: default; -webkit-touch-callout: none; }
.panes[data-layout="pages"] .grip::before { top: 20px; opacity: 0.6; }
.panes[data-layout="pages"] .tabline { padding: 0 128px 0 var(--spine); font-size: 0.8rem; touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
/*
* Moved up or down at once, the handle of any pane but a page's first drags the pane's top edge
* (Panes.tsx): so the browser may only pan it sideways, a swipe that turns the page. A page too
* short for a tab for each of its panes (tight) is never sized so: its handles scroll it, as before.
* A page sized by hand lays its panes one under another, filling it, nothing stacked.
*/
.panes[data-layout="pages"] .col.split:not(.tight) > .pane:not(:first-child) > :is(.grip, .tabline) { touch-action: pan-x; }
.panes[data-layout="pages"] .col.sized { overflow-y: hidden; }
.panes.resizing, .panes.resizing * { user-select: none; -webkit-user-select: none; }
/* Lifted: the pane fades where it is; its tab rides just above the finger; a line shows where it will go. */
.pane[data-lifted] { opacity: 0.4; }
.drag-ghost {
+58 -1
View File
@@ -1,6 +1,6 @@
/** The stacking shared by the panes view's strip and its crowded columns (src/ui/stack.ts). */
import { describe, expect, it } from "vitest";
import { coverage, crowds, fill, offsets, reveal, starts, whole } from "../src/ui/stack";
import { coverage, crowds, fill, fit, folded, offsets, release, resize, reveal, starts, whole } from "../src/ui/stack";
describe("stack", () => {
it("sticks each item a strip after the one before, a pinned one its whole size, never past where the rest can still be reached", () => {
@@ -58,4 +58,61 @@ describe("stack", () => {
// One pane: nothing to fold.
expect(crowds(720, [3000], 260, 0)).toBe(false);
});
it("as pages, a pane's handle dragged moves its top edge: the pane above takes or gives the difference, a tab pushed along at the limit", () => {
const T = 44;
// Two panes: the second's edge follows the drag both ways.
expect(resize([600, 44], 1, -200, T)).toEqual([400, 244]);
expect(resize([400, 244], 1, 100, T)).toEqual([500, 144]);
// Never past a tab either side: the column never overflows.
expect(resize([600, 44], 1, -1000, T)).toEqual([44, 600]);
expect(resize([300, 344], 1, 1000, T)).toEqual([600, 44]);
// A folded tab at the top opens as the edge below it is dragged down.
expect(resize([44, 556, 44], 1, 150, T)).toEqual([194, 406, 44]);
// Three panes, the middle open: the last tab dragged up takes from the middle; once that is a tab, the tab is pushed up and the first gives.
expect(resize([44, 556, 44], 2, -200, T)).toEqual([44, 356, 244]);
expect(resize([44, 556, 44], 2, -600, T)).toEqual([44, 44, 556]);
expect(resize([200, 400, 44], 2, -500, T)).toEqual([56, 44, 544]);
// Dragged down, the dragged pane gives, then those below it.
expect(resize([200, 300, 144], 1, 350, T)).toEqual([550, 44, 50]);
expect(resize([200, 300, 144], 1, 1000, T)).toEqual([556, 44, 44]);
// From the sizes the drag began with: back where it started, what was pushed is given back.
expect(resize([200, 400, 44], 2, 0, T)).toEqual([200, 400, 44]);
// The total is kept, and so is every tab, wherever the finger goes.
for (const dy of [-700, -333.4, -50, 0, 17.6, 260, 700]) {
const h = resize([120, 300, 44, 180], 2, dy, T);
expect(h.reduce((a, b) => a + b, 0)).toBeCloseTo(644, 6);
for (const x of h) expect(x).toBeGreaterThanOrEqual(T - 1e-9);
}
// The first pane has no edge above it to move.
expect(resize([300, 344], 0, 100, T)).toEqual([300, 344]);
});
it("as pages, a hand-sized pane left barely taller than its tab folds when the finger lifts; sizes fit a column whose height changed", () => {
const T = 44;
// Left 20 px over a tab: it folds, the pane above takes the rest.
expect(release([600, 44], 1, -20, T, 40)).toEqual([600, 44]);
expect(release([300, 344], 1, 280, T, 40)).toEqual([600, 44]);
// The pane above left nearly a tab: it folds instead.
expect(release([300, 344], 1, -230, T, 40)).toEqual([44, 600]);
// Well inside: where the finger left it, in whole pixels.
expect(release([600, 44], 1, -200.4, T, 40)).toEqual([400, 244]);
expect(release([600, 44], 1, -200.6, T, 40)).toEqual([399, 245]);
// Both nearly tabs (a short column): the shorter folds.
expect(release([100, 100], 1, 10, T, 80)).toEqual([156, 44]);
expect(folded(44, T)).toBe(true);
expect(folded(45, T)).toBe(true);
expect(folded(46, T)).toBe(false);
// Fit: what each has beyond its tab scales; a folded pane stays folded.
expect(fit([44, 300, 300], 544, T)).toEqual([44, 250, 250]);
expect(fit([44, 556, 44], 644, T)).toEqual([44, 556, 44]);
expect(fit([44, 556, 44], 744, T)).toEqual([44, 656, 44]);
// Measured sizes under a tab come up to one.
expect(fit([20, 580, 44], 644, T)).toEqual([44, 556, 44]);
// Whole pixels, filling the column exactly.
const f = fit([100, 200, 300], 641, T)!;
expect(f.reduce((a, b) => a + b, 0)).toBe(641);
for (const x of f) expect(Number.isInteger(x)).toBe(true);
// Too short for a tab each: none.
expect(fit([44, 44, 44], 120, T)).toBeNull();
});
});