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
+627 -33

No files matched your search

+239 -24
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;
e.preventDefault();
const p = [...e.touches][0];
if (!p) return;
lastY = p.clientY;
dropAt(lastY);
if (!edge) edge = requestAnimationFrame(edgeScroll);
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 {