Panes: a covered pane peeks only with Shift or Control held, and a column is laid out again after a click on a peeking pane
A plain hover no longer peeks, so text being read does not jump and an edge stays put to be dragged. A click on a peeking pane laid its column out while the peek skewed the measurements; it is laid out again once the pane is back, so the active pane takes its full height. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
9dec4df1fd
commit
3f89c3cd2c
9 files changed
+302
-36
No files matched your search
@@ -189,11 +189,19 @@ Press `?` for every key. The short version:
|
|||||||
A pane scrolled past its own title shows the same tab at its top, over its text; a pane shows its
|
A pane scrolled past its own title shows the same tab at its top, over its text; a pane shows its
|
||||||
tab only while the rule under its title does not show, never both. A click anywhere
|
tab only while the rule under its title does not show, never both. A click anywhere
|
||||||
in a pane that is not text, a row or a link makes it the active pane; a click anywhere else, or
|
in a pane that is not text, a row or a link makes it the active pane; a click anywhere else, or
|
||||||
Esc, clears a selection. Mouse resting on a pane that is cut off for any reason (covered across
|
Esc, clears a selection. A pane made the active one, however (a click in it, `[` `]`, `Alt+k`
|
||||||
or down, too small a share of its column, past its foot): after a moment it peeks out whole over
|
`Alt+j`, the keys moving along the branch), is laid out again in its column: it has what its text
|
||||||
its neighbours, its column across and the pane down its column, as tall as its text needs (a pane
|
needs, up to the column less a tab for each other pane, and the others give way down to their
|
||||||
longer than its column: the column less a tab for each other pane, clear of their tabs; one shown
|
tabs (a pinned one keeps its height). With Shift or Control held, the mouse on a pane that is
|
||||||
that tall already does not peek down its column), and stays out while the pointer is on it (the wheel scrolls it); a click makes it the active pane. A
|
cut off for any reason (covered across or down, too small a share of its column, past its foot)
|
||||||
|
peeks it out whole over its neighbours, its column across and the pane down its column, as tall
|
||||||
|
as its text needs (a pane longer than its column: the column less a tab for each other pane,
|
||||||
|
clear of their tabs; one shown that tall already does not peek down its column): pressed with
|
||||||
|
the mouse resting on it, or held as the mouse comes onto it. It stays out while the key is held
|
||||||
|
and the pointer is on it (the wheel, with Shift, scrolls it); letting go of both keys, any other
|
||||||
|
key, or the pointer leaving puts it back. A plain hover never peeks, so the text being read does
|
||||||
|
not jump, and an edge between panes (below) never peeks. A click on a peeking pane makes it the
|
||||||
|
active pane; a Shift- or Ctrl-click on a row or link in it does what it does anywhere. A
|
||||||
pane's grip (the band above its title, by the pin and x, shown when pointed at) or its tab drags
|
pane's grip (the band above its title, by the pin and x, shown when pointed at) or its tab drags
|
||||||
it up or down its column; Esc cancels; `Alt+Shift+k` `Alt+Shift+j` (or the pane menu's Move this
|
it up or down its column; Esc cancels; `Alt+Shift+k` `Alt+Shift+j` (or the pane menu's Move this
|
||||||
pane up and down) move the active pane a place; the column keeps that order, and a pane opened
|
pane up and down) move the active pane a place; the column keeps that order, and a pane opened
|
||||||
@@ -203,7 +211,8 @@ Press `?` for every key. The short version:
|
|||||||
dragged, the edge follows it, as a finger drags a pane's top edge on a phone: down a column the
|
dragged, the edge follows it, as a finger drags a pane's top edge on a phone: down a column the
|
||||||
panes either side give and take (a tab at the limit pushed along, never less than a tab, a pane
|
panes either side give and take (a tab at the limit pushed along, never less than a tab, a pane
|
||||||
left barely taller than its tab folds), across the strip the column after the edge gives what the
|
left barely taller than its tab folds), across the strip the column after the edge gives what the
|
||||||
one before takes (never narrower than 240 px, one at the limit pushed along). The column's top
|
one before takes (never narrower than 240 px, one at the limit pushed along). Nothing peeks over
|
||||||
|
an edge, or while one is dragged, Shift held or not. The column's top
|
||||||
and foot, the strip's outer edges and an edge a column covers are not edges. Esc while dragging
|
and foot, the strip's outer edges and an edge a column covers are not edges. Esc while dragging
|
||||||
puts the edge back; a double click on an edge lays its column (across, the strip) out
|
puts the edge back; a double click on an edge lays its column (across, the strip) out
|
||||||
automatically again. Only a pinned pane's size sticks: once another pane is the active one, or a
|
automatically again. Only a pinned pane's size sticks: once another pane is the active one, or a
|
||||||
|
|||||||
+14
-3
@@ -3,7 +3,7 @@
|
|||||||
* drawn by the curve into it, in the pane's colour, as one stroke (measured in the pixels, at several
|
* drawn by the curve into it, in the pane's colour, as one stroke (measured in the pixels, at several
|
||||||
* device pixel ratios); a pane folded or scrolled past its title shows its tab and the curve lands in
|
* device pixel ratios); a pane folded or scrolled past its title shows its tab and the curve lands in
|
||||||
* the tab's foot, and a curve out of a folded pane leaves from that foot; a pane's colour depends on
|
* the tab's foot, and a curve out of a folded pane leaves from that foot; a pane's colour depends on
|
||||||
* the forest only; a covered pane peeks out across and down at once, and the wheel scrolls it; the
|
* the forest only; a covered pane peeks out across and down at once with Shift held, and the wheel scrolls it; the
|
||||||
* selection bar sits at its pane's level. Same build, mock model and mock Wikipedia as the others.
|
* selection bar sits at its pane's level. Same build, mock model and mock Wikipedia as the others.
|
||||||
*/
|
*/
|
||||||
import { expect, test, type Page } from "@playwright/test";
|
import { expect, test, type Page } from "@playwright/test";
|
||||||
@@ -268,7 +268,7 @@ test("a pane folded or scrolled past its title shows its tab, and its curve land
|
|||||||
expect(near(l.end.y, l.rule!.y)).toBe(true);
|
expect(near(l.end.y, l.rule!.y)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a pane covered across and down peeks out whole on both axes; the wheel scrolls it and it stays out; the selection bar of a pane under it is covered", async ({ page }) => {
|
test("a pane covered across and down peeks out whole on both axes with Shift held (not on a plain hover); the wheel scrolls it and it stays out; the selection bar of a pane under it is covered", async ({ page }) => {
|
||||||
await page.setViewportSize({ width: 1920, height: 760 });
|
await page.setViewportSize({ width: 1920, height: 760 });
|
||||||
await library(page);
|
await library(page);
|
||||||
for (const t of ["The tides", "What a proof is", "The invention of writing", "Fixed points"]) await clickOpen(page, "Library", t);
|
for (const t of ["The tides", "What a proof is", "The invention of writing", "Fixed points"]) await clickOpen(page, "Library", t);
|
||||||
@@ -283,7 +283,13 @@ test("a pane covered across and down peeks out whole on both axes; the wheel scr
|
|||||||
await expect(tides).toHaveAttribute("data-covered", "");
|
await expect(tides).toHaveAttribute("data-covered", "");
|
||||||
const tb = (await tides.boundingBox())!;
|
const tb = (await tides.boundingBox())!;
|
||||||
const sp = { x: tb.x + 4, y: tb.y - 45, width: 20 };
|
const sp = { x: tb.x + 4, y: tb.y - 45, width: 20 };
|
||||||
|
// A plain hover, however long, leaves it covered.
|
||||||
await page.mouse.move(sp.x + sp.width / 2, sp.y + 60);
|
await page.mouse.move(sp.x + sp.width / 2, sp.y + 60);
|
||||||
|
await page.waitForTimeout(450);
|
||||||
|
await expect(col).not.toHaveAttribute("data-peek", "");
|
||||||
|
await expect(tides).not.toHaveAttribute("data-peek", "");
|
||||||
|
// Shift pressed with the mouse resting there: out.
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
await expect(col).toHaveAttribute("data-peek", "");
|
await expect(col).toHaveAttribute("data-peek", "");
|
||||||
await expect(tides).toHaveAttribute("data-peek", "");
|
await expect(tides).toHaveAttribute("data-peek", "");
|
||||||
const vp = page.viewportSize()!;
|
const vp = page.viewportSize()!;
|
||||||
@@ -306,6 +312,7 @@ test("a pane covered across and down peeks out whole on both axes; the wheel scr
|
|||||||
// Away: back.
|
// Away: back.
|
||||||
await page.mouse.move(vp.width - 10, vp.height / 2);
|
await page.mouse.move(vp.width - 10, vp.height / 2);
|
||||||
await expect(col).not.toHaveAttribute("data-peek", "");
|
await expect(col).not.toHaveAttribute("data-peek", "");
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
|
||||||
// The selection bar: shown in its pane; a pane peeking over it covers it.
|
// The selection bar: shown in its pane; a pane peeking over it covers it.
|
||||||
const rec = pane(page, "Recursion without names");
|
const rec = pane(page, "Recursion without names");
|
||||||
@@ -322,7 +329,8 @@ test("a pane covered across and down peeks out whole on both axes; the wheel scr
|
|||||||
const b = (await bar.boundingBox())!;
|
const b = (await bar.boundingBox())!;
|
||||||
const at = { x: b.x + b.width / 2, y: b.y + b.height / 2 };
|
const at = { x: b.x + b.width / 2, y: b.y + b.height / 2 };
|
||||||
expect(await page.evaluate(({ x, y }) => !!document.elementFromPoint(x, y)?.closest(".selbar"), at)).toBe(true);
|
expect(await page.evaluate(({ x, y }) => !!document.elementFromPoint(x, y)?.closest(".selbar"), at)).toBe(true);
|
||||||
// Peek the top-level trees' column (to the left, covered): it slides out over the pane with the bar.
|
// Peek the top-level trees' column (to the left, covered), Shift held as the mouse comes onto it: it slides out over the pane with the bar.
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
await page.mouse.move(sp.x + sp.width / 2, sp.y + 60);
|
await page.mouse.move(sp.x + sp.width / 2, sp.y + 60);
|
||||||
await expect(col).toHaveAttribute("data-peek", "");
|
await expect(col).toHaveAttribute("data-peek", "");
|
||||||
const over = await page.evaluate(({ x, y }) => {
|
const over = await page.evaluate(({ x, y }) => {
|
||||||
@@ -333,4 +341,7 @@ test("a pane covered across and down peeks out whole on both axes; the wheel scr
|
|||||||
expect(at.x).toBeLessThan(cb.x + cb.width);
|
expect(at.x).toBeLessThan(cb.x + cb.width);
|
||||||
expect(over).toEqual({ bar: false, peeked: true });
|
expect(over).toEqual({ bar: false, peeked: true });
|
||||||
expect(await state(page, (s) => s.selectedText())).not.toBeNull();
|
expect(await state(page, (s) => s.selectedText())).not.toBeNull();
|
||||||
|
// Shift let go: back.
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
await expect(col).not.toHaveAttribute("data-peek", "");
|
||||||
});
|
});
|
||||||
+104
-5
@@ -480,12 +480,16 @@ test("a crowded column stacks its panes as the strip stacks columns: covered par
|
|||||||
expect(b[kids[0]].whole).toBe(true);
|
expect(b[kids[0]].whole).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a pane resting covered peeks out under the mouse, over its neighbours without moving them; a click makes it active", async ({ page }) => {
|
test("a covered pane peeks out under the mouse only with Shift or Control held, over its neighbours without moving them; letting go puts it back; a click makes it active", async ({ page }) => {
|
||||||
const kids = await five(page);
|
const kids = await five(page);
|
||||||
const before = await boxes(page);
|
const before = await boxes(page);
|
||||||
const tab = pane(page, kids[1]).locator(".tabline");
|
const tab = pane(page, kids[1]).locator(".tabline");
|
||||||
|
// A plain hover, however long, peeks nothing.
|
||||||
await tab.hover();
|
await tab.hover();
|
||||||
// Not at once: passing the mouse across does not flicker.
|
await page.waitForTimeout(450);
|
||||||
|
expect(await pane(page, kids[1]).getAttribute("data-peek")).toBeNull();
|
||||||
|
// Shift pressed with the mouse resting on it: out (not at once, so a capital typed does not flash it).
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
expect(await pane(page, kids[1]).getAttribute("data-peek")).toBeNull();
|
expect(await pane(page, kids[1]).getAttribute("data-peek")).toBeNull();
|
||||||
await expect(pane(page, kids[1])).toHaveAttribute("data-peek", "");
|
await expect(pane(page, kids[1])).toHaveAttribute("data-peek", "");
|
||||||
const peeked = (await pane(page, kids[1]).boundingBox())!;
|
const peeked = (await pane(page, kids[1]).boundingBox())!;
|
||||||
@@ -494,15 +498,35 @@ test("a pane resting covered peeks out under the mouse, over its neighbours with
|
|||||||
// Nothing else moved.
|
// Nothing else moved.
|
||||||
const after = await boxes(page);
|
const after = await boxes(page);
|
||||||
for (const t of kids) if (t !== kids[1]) expect(after[t].y).toBeCloseTo(before[t].y, 0);
|
for (const t of kids) if (t !== kids[1]) expect(after[t].y).toBeCloseTo(before[t].y, 0);
|
||||||
// Leaving puts it back.
|
// Letting go puts it back.
|
||||||
await page.mouse.move(5, 500);
|
await page.keyboard.up("Shift");
|
||||||
await expect(pane(page, kids[1])).not.toHaveAttribute("data-peek", "");
|
await expect(pane(page, kids[1])).not.toHaveAttribute("data-peek", "");
|
||||||
// A click on it makes it the active pane, whole.
|
// Control works as Shift does; any other key, or the window losing the focus, puts it back too.
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await expect(pane(page, kids[1])).toHaveAttribute("data-peek", "");
|
||||||
|
await page.evaluate(() => window.dispatchEvent(new Event("blur")));
|
||||||
|
await expect(pane(page, kids[1])).not.toHaveAttribute("data-peek", "");
|
||||||
|
await page.keyboard.up("Control");
|
||||||
|
// Held as the mouse comes onto it: out; leaving puts it back.
|
||||||
|
await page.mouse.move(5, 500);
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
await tab.hover();
|
await tab.hover();
|
||||||
await expect(pane(page, kids[1])).toHaveAttribute("data-peek", "");
|
await expect(pane(page, kids[1])).toHaveAttribute("data-peek", "");
|
||||||
|
await page.keyboard.press("Shift+Escape");
|
||||||
|
await expect(pane(page, kids[1])).not.toHaveAttribute("data-peek", "");
|
||||||
|
await page.mouse.move(5, 500);
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
// A click on it makes it the active pane, whole, and it goes back: the column laid out for it once it is back.
|
||||||
|
await tab.hover();
|
||||||
|
await page.keyboard.down("Control");
|
||||||
|
await expect(pane(page, kids[1])).toHaveAttribute("data-peek", "");
|
||||||
await pane(page, kids[1]).locator(".pane-head").click();
|
await pane(page, kids[1]).locator(".pane-head").click();
|
||||||
|
await page.keyboard.up("Control");
|
||||||
await expect(page.locator(".pane.active .pane-head h2")).toHaveText(kids[1]);
|
await expect(page.locator(".pane.active .pane-head h2")).toHaveText(kids[1]);
|
||||||
|
await expect(pane(page, kids[1])).not.toHaveAttribute("data-peek", "");
|
||||||
|
await still(page);
|
||||||
expect((await boxes(page))[kids[1]].whole).toBe(true);
|
expect((await boxes(page))[kids[1]].whole).toBe(true);
|
||||||
|
expect(await pane(page, kids[1]).evaluate((el) => ["data-tab", "data-covered", "data-buried"].filter((a) => el.hasAttribute(a)))).toEqual([]);
|
||||||
// A column covered across the strip peeks too, raised over the columns past it.
|
// A column covered across the strip peeks too, raised over the columns past it.
|
||||||
await page.setViewportSize({ width: 1600, height: 1000 });
|
await page.setViewportSize({ width: 1600, height: 1000 });
|
||||||
await page.evaluate(() => localStorage.clear());
|
await page.evaluate(() => localStorage.clear());
|
||||||
@@ -511,7 +535,45 @@ test("a pane resting covered peeks out under the mouse, over its neighbours with
|
|||||||
await expect.poll(async () => (await columns(page)).length).toBe(4);
|
await expect.poll(async () => (await columns(page)).length).toBe(4);
|
||||||
await expect.poll(() => page.evaluate(() => document.querySelectorAll(".strip > .col")[0].hasAttribute("data-covered"))).toBe(true);
|
await expect.poll(() => page.evaluate(() => document.querySelectorAll(".strip > .col")[0].hasAttribute("data-covered"))).toBe(true);
|
||||||
await page.locator(".strip > .col").nth(0).locator(".spine-title").hover();
|
await page.locator(".strip > .col").nth(0).locator(".spine-title").hover();
|
||||||
|
await page.waitForTimeout(300);
|
||||||
|
await expect(page.locator(".strip > .col").nth(0)).not.toHaveAttribute("data-peek", "");
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
await expect(page.locator(".strip > .col").nth(0)).toHaveAttribute("data-peek", "");
|
await expect(page.locator(".strip > .col").nth(0)).toHaveAttribute("data-peek", "");
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a Shift- or Ctrl-click on a row of a peeking pane does what it does on any pane: Shift opens in place, Ctrl beside", async ({ page }) => {
|
||||||
|
const kids = await five(page);
|
||||||
|
/** Peek a covered pane, the modifier held, and click one of its rows with it. */
|
||||||
|
const peekRow = async (mod: "Shift" | "Control", inPane: string, row: string) => {
|
||||||
|
await page.mouse.move(5, 500);
|
||||||
|
// On what shows of it, below its grip.
|
||||||
|
const at = await pane(page, inPane).evaluate((el) => {
|
||||||
|
const r = el.getBoundingClientRect();
|
||||||
|
const c = el.parentElement!.getBoundingClientRect();
|
||||||
|
return { x: r.left + 60, y: Math.max(r.top, c.top) + 22 };
|
||||||
|
});
|
||||||
|
await page.mouse.move(at.x, at.y);
|
||||||
|
await page.keyboard.down(mod);
|
||||||
|
await expect(pane(page, inPane)).toHaveAttribute("data-peek", "");
|
||||||
|
await pane(page, inPane).locator(".row", { hasText: row }).first().click({ modifiers: [mod] });
|
||||||
|
await page.keyboard.up(mod);
|
||||||
|
await still(page);
|
||||||
|
};
|
||||||
|
const a = await childTitles(page, kids[1]);
|
||||||
|
const b = await childTitles(page, kids[3]);
|
||||||
|
// Shift: in place of the focused branch's pane in the next column (none there yet: it opens there).
|
||||||
|
await peekRow("Shift", kids[1], a[0]);
|
||||||
|
expect(await trail(page)).toEqual(["Explicata", kids[1], a[0]]);
|
||||||
|
expect((await columns(page))[2]).toEqual([a[0]]);
|
||||||
|
// Ctrl, in another pane covered in that column: beside what is open there, a fork of its own.
|
||||||
|
await peekRow("Control", kids[3], b[0]);
|
||||||
|
expect(await trail(page)).toEqual(["Explicata", kids[3], b[0]]);
|
||||||
|
expect((await columns(page))[2]).toEqual([a[0], b[0]]);
|
||||||
|
// Shift, back in the first: in place of its pane there; the other fork stays.
|
||||||
|
await peekRow("Shift", kids[1], a[1]);
|
||||||
|
expect(await trail(page)).toEqual(["Explicata", kids[1], a[1]]);
|
||||||
|
expect((await columns(page))[2]).toEqual([a[1], b[0]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a pane is dragged by its grip, or its tab, up or down its column; the order is kept, and Esc cancels", async ({ page }) => {
|
test("a pane is dragged by its grip, or its tab, up or down its column; the order is kept, and Esc cancels", async ({ page }) => {
|
||||||
@@ -940,3 +1002,40 @@ test("side by side, a crowded column's edges resize too: the column is laid out
|
|||||||
for (let i = 0; i < n - 2; i++) expect(Math.abs(c.panes[i].h - shown[i])).toBeLessThanOrEqual(1.5);
|
for (let i = 0; i < n - 2; i++) expect(Math.abs(c.panes[i].h - shown[i])).toBeLessThanOrEqual(1.5);
|
||||||
for (let i = 1; i < n; i++) expect(Math.abs(c.panes[i].top - (c.panes[i - 1].top + c.panes[i - 1].h))).toBeLessThanOrEqual(1);
|
for (let i = 1; i < n; i++) expect(Math.abs(c.panes[i].top - (c.panes[i - 1].top + c.panes[i - 1].h))).toBeLessThanOrEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("an edge stays an edge with Shift held: resting on it, or pressing Shift there, peeks nothing, and it drags as without", async ({ page }) => {
|
||||||
|
await five(page);
|
||||||
|
let c = (await measured(page))[1];
|
||||||
|
const x = c.left + c.w / 2;
|
||||||
|
const n = c.panes.length;
|
||||||
|
const peeking = () => page.evaluate(() => document.querySelectorAll("[data-peek]").length);
|
||||||
|
// Plain hover on a covered pane, then Shift pressed on the edge between two of the column's tabs: no peek.
|
||||||
|
await page.mouse.move(x, c.panes[1].top + 12);
|
||||||
|
await page.waitForTimeout(300);
|
||||||
|
expect(await peeking()).toBe(0);
|
||||||
|
expect(await cursorAt(page, x, c.panes[2].top)).toBe("row-resize");
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
|
await page.waitForTimeout(300);
|
||||||
|
expect(await peeking()).toBe(0);
|
||||||
|
// Moving along the edges with Shift held: still none.
|
||||||
|
const y = c.panes[n - 1].top;
|
||||||
|
expect(await cursorAt(page, x, y)).toBe("row-resize");
|
||||||
|
await page.waitForTimeout(300);
|
||||||
|
expect(await peeking()).toBe(0);
|
||||||
|
// Dragged with Shift still held: the edge follows, nothing peeks on the way or after.
|
||||||
|
const shown = c.panes.map((p, i) => (i < n - 1 ? c.panes[i + 1].top : c.bottom) - p.top);
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(x, y + 100, { steps: 4 });
|
||||||
|
await page.waitForTimeout(250);
|
||||||
|
expect(await peeking()).toBe(0);
|
||||||
|
await page.mouse.move(x, y + 200, { steps: 4 });
|
||||||
|
await page.mouse.up();
|
||||||
|
await frames(page);
|
||||||
|
await page.waitForTimeout(250);
|
||||||
|
expect(await peeking()).toBe(0);
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
c = (await measured(page))[1];
|
||||||
|
expect(c.sized).toBe(true);
|
||||||
|
expect(Math.abs(c.panes[n - 1].top - (y + 200))).toBeLessThanOrEqual(1.5);
|
||||||
|
expect(Math.abs(c.panes[n - 2].h - (shown[n - 2] + 200))).toBeLessThanOrEqual(1.5);
|
||||||
|
});
|
||||||
+4
-1
@@ -349,7 +349,7 @@ test.describe("panes", () => {
|
|||||||
// A Shift-click on a row opens it in place of the pane there.
|
// A Shift-click on a row opens it in place of the pane there.
|
||||||
await paneOf(page, "Tuning and temperament").locator(".row", { hasText: "The comma" }).click({ modifiers: ["Shift"] });
|
await paneOf(page, "Tuning and temperament").locator(".row", { hasText: "The comma" }).click({ modifiers: ["Shift"] });
|
||||||
await expect.poll(() => trail(page)).toEqual(["Tuning and temperament", "The comma"]);
|
await expect.poll(() => trail(page)).toEqual(["Tuning and temperament", "The comma"]);
|
||||||
// Five panes in one column: a covered one peeks under the mouse; with room, a pane drags by its grip (the ⋯ beside it does not drag).
|
// Five panes in one column: a covered one peeks under the mouse with Shift held; with room, a pane drags by its grip (the ⋯ beside it does not drag).
|
||||||
await page.evaluate(() => localStorage.clear());
|
await page.evaluate(() => localStorage.clear());
|
||||||
await open(page);
|
await open(page);
|
||||||
await keys(page, "z j Enter j Enter j Enter j Enter j Enter");
|
await keys(page, "z j Enter j Enter j Enter j Enter j Enter");
|
||||||
@@ -359,7 +359,10 @@ test.describe("panes", () => {
|
|||||||
const covered = col.locator(":scope > .pane[data-covered]").first();
|
const covered = col.locator(":scope > .pane[data-covered]").first();
|
||||||
await expect(covered).toHaveCount(1);
|
await expect(covered).toHaveCount(1);
|
||||||
await covered.locator(".tabline").hover();
|
await covered.locator(".tabline").hover();
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
await expect(covered).toHaveAttribute("data-peek", "");
|
await expect(covered).toHaveAttribute("data-peek", "");
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
await expect(covered).not.toHaveAttribute("data-peek", "");
|
||||||
await page.mouse.move(5, 500);
|
await page.mouse.move(5, 500);
|
||||||
await page.setViewportSize({ width: 1920, height: 2000 });
|
await page.setViewportSize({ width: 1920, height: 2000 });
|
||||||
await expect.poll(() => col.getAttribute("class")).not.toContain("crowded");
|
await expect.poll(() => col.getAttribute("class")).not.toContain("crowded");
|
||||||
|
|||||||
+98
-4
@@ -2,7 +2,7 @@
|
|||||||
* The panes view: a click anywhere in a pane makes it active and anywhere clears a
|
* The panes view: a click anywhere in a pane makes it active and anywhere clears a
|
||||||
* selection; a column's panes stand in the order of their sources; every pane in a crowded column
|
* selection; a column's panes stand in the order of their sources; every pane in a crowded column
|
||||||
* shows at least its tab, above or below; the active pane is never cut short by its share of a
|
* shows at least its tab, above or below; the active pane is never cut short by its share of a
|
||||||
* column; a pane cut off for any reason peeks out at its fullest, and one that already has all its
|
* column; a pane cut off for any reason peeks out at its fullest with Shift held, and one that already has all its
|
||||||
* column gives it beside the others' tabs does not peek; the curves
|
* column gives it beside the others' tabs does not peek; the curves
|
||||||
* keep to their sources and landing lines through every kind of layout change (curveFaults); the
|
* keep to their sources and landing lines through every kind of layout change (curveFaults); the
|
||||||
* selection bar keeps clear of a tab; a dotted curve turns toward its source; Alt with h j k l moves
|
* selection bar keeps clear of a tab; a dotted curve turns toward its source; Alt with h j k l moves
|
||||||
@@ -205,12 +205,102 @@ test("the active pane is never cut short by its share of a column: the others gi
|
|||||||
await noFaults(page, "the active pane elsewhere");
|
await noFaults(page, "the active pane elsewhere");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a pane cut off for any reason peeks out at its fullest (whole, if it fits in its column), across and down, and the curves follow it: covered from below or above, by its share, by the column's foot, beside a pinned pane, and with its column covered", async ({ page }) => {
|
test("a pane made active in a column takes the height its text needs, up to the column less a tab for each other pane, and the others give way: by a click, by [ and ], and by a click on it while it peeks", async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 1700, height: 1000 });
|
||||||
|
await library(page);
|
||||||
|
for (const t of ["The tides", "What a proof is", "Fixed points"]) await clickOpen(page, "Library", t);
|
||||||
|
const col = page.locator(".strip > .col").nth(1);
|
||||||
|
/** Each pane of the column: what shows of it (down to the pane after it, in a crowded column), what it needs, whether it is active, its marks. */
|
||||||
|
const shown = () =>
|
||||||
|
col.evaluate((c) => {
|
||||||
|
const ps = [...c.querySelectorAll<HTMLElement>(":scope > .pane")];
|
||||||
|
const cb = c.getBoundingClientRect();
|
||||||
|
return {
|
||||||
|
h: c.clientHeight,
|
||||||
|
ps: ps.map((p, i) => {
|
||||||
|
const r = p.getBoundingClientRect();
|
||||||
|
const next = c.classList.contains("crowded") ? (ps[i + 1]?.getBoundingClientRect().top ?? Infinity) : Infinity;
|
||||||
|
const sc = getComputedStyle(p.querySelector(".pane-scroll")!);
|
||||||
|
return {
|
||||||
|
t: p.querySelector(".pane-head h2")?.textContent?.trim() ?? "",
|
||||||
|
shown: Math.max(0, Math.min(r.bottom, cb.bottom, next) - Math.max(r.top, cb.top)),
|
||||||
|
need: p.querySelector<HTMLElement>(".pane-body")!.offsetHeight + parseFloat(sc.paddingTop) + parseFloat(sc.paddingBottom),
|
||||||
|
active: p.classList.contains("active"),
|
||||||
|
marks: ["data-tab", "data-covered", "data-buried", "data-peek"].filter((a) => p.hasAttribute(a)),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
/** The active pane has what it needs (or the cap), shows no tab and is not covered; the others have given way. */
|
||||||
|
const expectGrown = async (label: string, title: string, before: Awaited<ReturnType<typeof shown>>) => {
|
||||||
|
await still(page);
|
||||||
|
const now = await shown();
|
||||||
|
const i = now.ps.findIndex((p) => p.t === title);
|
||||||
|
const a = now.ps[i];
|
||||||
|
expect(a.active, `${label}: ${title} is active`).toBe(true);
|
||||||
|
const cap = now.h - (now.ps.length - 1) * TAB;
|
||||||
|
expect(a.shown, `${label}: ${title} shows what it needs, or the cap`).toBeGreaterThanOrEqual(Math.min(a.need, cap) - 2);
|
||||||
|
expect(a.marks, `${label}: ${title} has no tab or cover left`).toEqual([]);
|
||||||
|
expect(a.shown, `${label}: ${title} grew`).toBeGreaterThan(before.ps[i].shown + 50);
|
||||||
|
for (const [j, p] of now.ps.entries()) {
|
||||||
|
if (j === i) continue;
|
||||||
|
expect(p.shown, `${label}: ${p.t} gave way`).toBeLessThanOrEqual(Math.max(TAB, before.ps[j].shown) + 1);
|
||||||
|
expect(p.shown, `${label}: ${p.t} keeps its tab`).toBeGreaterThanOrEqual(TAB - 1);
|
||||||
|
}
|
||||||
|
expect(now.ps.reduce((s, p) => s + p.shown, 0), `${label}: the column is filled, nothing more`).toBeLessThanOrEqual(now.h + 1);
|
||||||
|
};
|
||||||
|
const library0 = async () => {
|
||||||
|
await pane(page, "Library").locator(".top h1").first().dispatchEvent("click");
|
||||||
|
await still(page);
|
||||||
|
await page.mouse.move(5, 990);
|
||||||
|
};
|
||||||
|
// The active pane elsewhere: the three share the column, each cut short.
|
||||||
|
await library0();
|
||||||
|
let before = await shown();
|
||||||
|
expect(before.ps.every((p) => p.shown < p.need - 50)).toBe(true);
|
||||||
|
// A click on the last one's head.
|
||||||
|
const titles = before.ps.map((p) => p.t);
|
||||||
|
const head = (t: string) => pane(page, t).locator(".pane-head h2");
|
||||||
|
await head(titles[2]).click();
|
||||||
|
await expectGrown("a click", titles[2], before);
|
||||||
|
// [ moves up the column: the one above it grows, the last gives way.
|
||||||
|
before = await shown();
|
||||||
|
await keys(page, "[");
|
||||||
|
await expectGrown("[", titles[1], before);
|
||||||
|
before = await shown();
|
||||||
|
await keys(page, "]");
|
||||||
|
await expectGrown("]", titles[2], before);
|
||||||
|
// From the shared column again, each in turn: a click on it while it peeks (Shift held, resting on it), the way a reader clicks a pane that has come out.
|
||||||
|
for (const t of titles) {
|
||||||
|
await library0();
|
||||||
|
before = await shown();
|
||||||
|
const at = await pane(page, t).evaluate((el) => {
|
||||||
|
const r = el.getBoundingClientRect();
|
||||||
|
return { x: r.left + 80, y: r.top + 60 };
|
||||||
|
});
|
||||||
|
await page.mouse.move(at.x, at.y);
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
|
await expect(pane(page, t)).toHaveAttribute("data-peek", "");
|
||||||
|
const hb = (await head(t).boundingBox())!;
|
||||||
|
await page.mouse.click(hb.x + 5, hb.y + hb.height / 2);
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
await expect(pane(page, t)).not.toHaveAttribute("data-peek", "");
|
||||||
|
await expectGrown(`a click while it peeks`, t, before);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a pane cut off for any reason peeks out at its fullest with Shift held (whole, if it fits in its column), across and down, and the curves follow it: covered from below or above, by its share, by the column's foot, beside a pinned pane, and with its column covered", async ({ page }) => {
|
||||||
await page.setViewportSize({ width: 1920, height: 700 });
|
await page.setViewportSize({ width: 1920, height: 700 });
|
||||||
await library(page);
|
await library(page);
|
||||||
for (const t of ["Octopus minds", "Explicata", "The tides", "Fixed points"]) await clickOpen(page, "Library", t);
|
for (const t of ["Octopus minds", "Explicata", "The tides", "Fixed points"]) await clickOpen(page, "Library", t);
|
||||||
/** Hover each pane of the top-level trees' column that is cut off, and check it comes out whole, and the curves with it. */
|
/** Hover each pane of the top-level trees' column that is cut off, Shift held, and check it comes out whole, and the curves with it. */
|
||||||
const sweep = async (label: string, across: boolean) => {
|
const sweep = async (label: string, across: boolean) => {
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
|
const peeked = await sweepHeld(label, across);
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
|
return peeked;
|
||||||
|
};
|
||||||
|
const sweepHeld = async (label: string, across: boolean) => {
|
||||||
const col = page.locator(".strip > .col").nth(1);
|
const col = page.locator(".strip > .col").nth(1);
|
||||||
const n = await col.locator(":scope > .pane").count();
|
const n = await col.locator(":scope > .pane").count();
|
||||||
let peeked = 0;
|
let peeked = 0;
|
||||||
@@ -307,10 +397,11 @@ test("a pane that already has all its column can give it beside the others' tabs
|
|||||||
return { t: p.querySelector(".pane-head h2, .top h1")?.textContent?.trim(), box: [r.left, r.top, r.width, r.height].map(Math.round), tab: p.hasAttribute("data-tab"), shows: !!hit && p.contains(hit), peek: p.hasAttribute("data-peek") };
|
return { t: p.querySelector(".pane-head h2, .top h1")?.textContent?.trim(), box: [r.left, r.top, r.width, r.height].map(Math.round), tab: p.hasAttribute("data-tab"), shows: !!hit && p.contains(hit), peek: p.hasAttribute("data-peek") };
|
||||||
});
|
});
|
||||||
}, TAB);
|
}, TAB);
|
||||||
/** Rest the mouse on the pane at the column's foot, longer than it takes a pane to peek. */
|
/** Rest the mouse on the pane at the column's foot, Shift held, longer than it takes a pane to peek. */
|
||||||
const rest = async () => {
|
const rest = async () => {
|
||||||
const b = (await pane(page, "The tides").boundingBox())!;
|
const b = (await pane(page, "The tides").boundingBox())!;
|
||||||
await page.mouse.move(b.x + 60, b.y + b.height / 2);
|
await page.mouse.move(b.x + 60, b.y + b.height / 2);
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
await page.waitForTimeout(450);
|
await page.waitForTimeout(450);
|
||||||
};
|
};
|
||||||
/** With this pane active (The tides, or one deeper on its branch): The tides at the column's foot does not peek. */
|
/** With this pane active (The tides, or one deeper on its branch): The tides at the column's foot does not peek. */
|
||||||
@@ -329,6 +420,7 @@ test("a pane that already has all its column can give it beside the others' tabs
|
|||||||
expect(after[3].box, `${label}: its box`).toEqual(before[3].box);
|
expect(after[3].box, `${label}: its box`).toEqual(before[3].box);
|
||||||
for (const p of after.slice(0, 3)) expect(p.shows, `${label}: ${p.t}'s tab`).toBe(true);
|
for (const p of after.slice(0, 3)) expect(p.shows, `${label}: ${p.t}'s tab`).toBe(true);
|
||||||
await noFaults(page, `${label}: resting on it`);
|
await noFaults(page, `${label}: resting on it`);
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
await page.mouse.move(1910, 690);
|
await page.mouse.move(1910, 690);
|
||||||
};
|
};
|
||||||
await check("the column in full view", "The tides");
|
await check("the column in full view", "The tides");
|
||||||
@@ -341,6 +433,7 @@ test("a pane that already has all its column can give it beside the others' tabs
|
|||||||
await check("the column covered", "The brake");
|
await check("the column covered", "The brake");
|
||||||
// A folded pane peeking out of the covered column covers the tabs after it: the curves to and from those tabs are under it, the column's others over the column.
|
// A folded pane peeking out of the covered column covers the tabs after it: the curves to and from those tabs are under it, the column's others over the column.
|
||||||
const fp = (await pane(page, "Fixed points").boundingBox())!;
|
const fp = (await pane(page, "Fixed points").boundingBox())!;
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
await page.mouse.move(fp.x + 60, fp.y + TAB / 2);
|
await page.mouse.move(fp.x + 60, fp.y + TAB / 2);
|
||||||
await page.waitForTimeout(450);
|
await page.waitForTimeout(450);
|
||||||
await expect(col).toHaveAttribute("data-peek", "");
|
await expect(col).toHaveAttribute("data-peek", "");
|
||||||
@@ -358,6 +451,7 @@ test("a pane that already has all its column can give it beside the others' tabs
|
|||||||
expect(peeked.y + peeked.height).toBeLessThanOrEqual(c.y + c.height + 1);
|
expect(peeked.y + peeked.height).toBeLessThanOrEqual(c.y + c.height + 1);
|
||||||
expect((await column())[0].shows, "Explicata's tab").toBe(true);
|
expect((await column())[0].shows, "Explicata's tab").toBe(true);
|
||||||
await page.mouse.move(1910, 690);
|
await page.mouse.move(1910, 690);
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
await noFaults(page, "back");
|
await noFaults(page, "back");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ test("peeking in a busy forest: every other curve leaves the peeking pane's plac
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
expect(cut.length).toBeGreaterThan(1);
|
expect(cut.length).toBeGreaterThan(1);
|
||||||
|
// Shift held, as the mouse comes onto each.
|
||||||
|
await page.keyboard.down("Shift");
|
||||||
for (const c of cut) {
|
for (const c of cut) {
|
||||||
await page.mouse.move(c.x, c.y);
|
await page.mouse.move(c.x, c.y);
|
||||||
await expect(page.locator(`.pane[data-tid="${c.tid}"]`)).toHaveAttribute("data-peek", "");
|
await expect(page.locator(`.pane[data-tid="${c.tid}"]`)).toHaveAttribute("data-peek", "");
|
||||||
@@ -76,6 +78,7 @@ test("peeking in a busy forest: every other curve leaves the peeking pane's plac
|
|||||||
await expect(page.locator(`.pane[data-tid="${c.tid}"]`)).not.toHaveAttribute("data-peek", "");
|
await expect(page.locator(`.pane[data-tid="${c.tid}"]`)).not.toHaveAttribute("data-peek", "");
|
||||||
await noFaults(page, `after ${c.tid}`);
|
await noFaults(page, `after ${c.tid}`);
|
||||||
}
|
}
|
||||||
|
await page.keyboard.up("Shift");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a pane's title and its tab never show together, and the curve lands in whichever shows, as a crowded column scrolls through its panes", async ({ page }) => {
|
test("a pane's title and its tab never show together, and the curve lands in whichever shows, as a crowded column scrolls through its panes", async ({ page }) => {
|
||||||
|
|||||||
+62
-15
@@ -378,8 +378,8 @@ const HOLD_MS = 380;
|
|||||||
/** The touch drag's move handler (Panes' effect sets it); the handles call it from their own, blocking, touchmove listeners. */
|
/** The touch drag's move handler (Panes' effect sets it); the handles call it from their own, blocking, touchmove listeners. */
|
||||||
let handleMove: ((e: TouchEvent) => void) | null = null;
|
let handleMove: ((e: TouchEvent) => void) | null = null;
|
||||||
const onHandleMove = (e: TouchEvent) => handleMove?.(e);
|
const onHandleMove = (e: TouchEvent) => handleMove?.(e);
|
||||||
/** How long the mouse rests on a covered pane before it peeks out. */
|
/** How long Shift or Control is held, with the mouse on a covered pane, before it peeks out (so a capital typed, or Ctrl+C, does not flash it). */
|
||||||
const PEEK_MS = 200;
|
const PEEK_MS = 120;
|
||||||
|
|
||||||
/** 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). */
|
/** 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). */
|
||||||
const LOCK_PX = 8;
|
const LOCK_PX = 8;
|
||||||
@@ -537,6 +537,8 @@ export function Panes() {
|
|||||||
const fingers = useRef(false);
|
const fingers = useRef(false);
|
||||||
/** The layout last drawn: pages or side by side. */
|
/** The layout last drawn: pages or side by side. */
|
||||||
const wasPages = useRef<boolean | null>(null);
|
const wasPages = useRef<boolean | null>(null);
|
||||||
|
/** The columns were laid out while something peeked: lay them out again once it is back (the effect's `settled`). */
|
||||||
|
const peekLaid = useRef(false);
|
||||||
|
|
||||||
const branch = store.branchNodes;
|
const branch = store.branchNodes;
|
||||||
const onBranch = new Set(branch.map((n) => n.id));
|
const onBranch = new Set(branch.map((n) => n.id));
|
||||||
@@ -558,6 +560,8 @@ export function Panes() {
|
|||||||
const colEls = [...el.children].filter((c): c is HTMLElement => c.classList.contains("col"));
|
const colEls = [...el.children].filter((c): c is HTMLElement => c.classList.contains("col"));
|
||||||
if (!colEls.length) return;
|
if (!colEls.length) return;
|
||||||
clearTimeout(later.current);
|
clearTimeout(later.current);
|
||||||
|
// A pane or column peeking skews what is measured here (its height, the offset that keeps that from moving the panes under it, its lift).
|
||||||
|
if (el.querySelector("[data-peek]")) peekLaid.current = true;
|
||||||
const activeCol = activeId === undefined ? null : paneEls(el).get(activeId)?.parentElement;
|
const activeCol = activeId === undefined ? null : paneEls(el).get(activeId)?.parentElement;
|
||||||
const spine = colEls[0].querySelector<HTMLElement>(".spine")?.offsetWidth ?? 0;
|
const spine = colEls[0].querySelector<HTMLElement>(".spine")?.offsetWidth ?? 0;
|
||||||
// With no scrollbar under the panes (none needed, or one drawn over them) their last bottom edge meets the status line's: one line, not two.
|
// With no scrollbar under the panes (none needed, or one drawn over them) their last bottom edge meets the status line's: one line, not two.
|
||||||
@@ -925,10 +929,14 @@ export function Panes() {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Peeking: a pane the stacks have covered, wholly or in part (its column across the strip, or
|
* Peeking: a pane the stacks have covered, wholly or in part (its column across the strip, or
|
||||||
* the pane down a crowded column), slides out over its neighbours while the mouse rests on it
|
* the pane down a crowded column), slides out over its neighbours while the mouse is on it with
|
||||||
* (after PEEK_MS, so passing across does not flicker), raised and, if it runs past the column's
|
* Shift or Control held (after PEEK_MS, so a capital typed or a Ctrl+C does not flash it):
|
||||||
* foot, lifted into view; nothing else moves. A click makes it the active pane, which uncovers
|
* pressed with the mouse resting on it, or held as the mouse comes onto it. It is raised and, if
|
||||||
* it for good. Not for touch, the keyboard, or while dragging.
|
* it runs past the column's foot, lifted into view; nothing else moves. Letting go of both keys,
|
||||||
|
* any other key, the mouse leaving or the window losing the focus puts it back. A plain hover
|
||||||
|
* never peeks, so text being read does not jump and an edge stays where it is to be dragged. A
|
||||||
|
* click makes it the active pane, which uncovers it for good. Not for touch, or while dragging
|
||||||
|
* a grip or an edge.
|
||||||
*/
|
*/
|
||||||
/** What peeks (its column across, the pane down its column, or both) and the pane it is for. */
|
/** What peeks (its column across, the pane down its column, or both) and the pane it is for. */
|
||||||
let peeked: HTMLElement[] = [];
|
let peeked: HTMLElement[] = [];
|
||||||
@@ -942,12 +950,18 @@ export function Panes() {
|
|||||||
it.style.removeProperty("--peek-extra");
|
it.style.removeProperty("--peek-extra");
|
||||||
it.style.transform = "";
|
it.style.transform = "";
|
||||||
};
|
};
|
||||||
|
/** Once something has come back: the curves drawn again; and if the columns were laid out while it was out (a click on it made it the active pane, say), laid out again, since its height, offset and lift skewed what was measured (a column's scroll, the panes' marks). */
|
||||||
|
const settled = () => {
|
||||||
|
if (!peekLaid.current) return schedule();
|
||||||
|
peekLaid.current = false;
|
||||||
|
relayout();
|
||||||
|
};
|
||||||
function hide() {
|
function hide() {
|
||||||
if (!peeked.length) return;
|
if (!peeked.length) return;
|
||||||
for (const it of peeked) lower(it);
|
for (const it of peeked) lower(it);
|
||||||
peeked = [];
|
peeked = [];
|
||||||
peekedFor = null;
|
peekedFor = null;
|
||||||
schedule();
|
settled();
|
||||||
}
|
}
|
||||||
function unpeek() {
|
function unpeek() {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
@@ -1016,11 +1030,12 @@ export function Panes() {
|
|||||||
}
|
}
|
||||||
schedule();
|
schedule();
|
||||||
};
|
};
|
||||||
const onMove = (e: PointerEvent) => {
|
/** Where the mouse last was over the strip (a modifier pressed with it resting there peeks what is under it); null once it has left. */
|
||||||
if (e.pointerType !== "mouse" || e.buttons || drag) return;
|
let mouse: { x: number; y: number } | null = null;
|
||||||
// On an edge between panes (below): it is pressed to resize, not peeked through.
|
/** Shift or Control held: what makes a covered pane peek. */
|
||||||
if (wrap.dataset.edge) return unpeek();
|
const held = (e: { shiftKey: boolean; ctrlKey: boolean }) => e.shiftKey || e.ctrlKey;
|
||||||
const pane = (e.target as HTMLElement).closest<HTMLElement>(".pane");
|
/** Peek this pane, the pointer on it with a modifier held, after PEEK_MS (or put back what peeks, if it is none, or has nothing covered). */
|
||||||
|
const consider = (pane: HTMLElement | null) => {
|
||||||
if (pane && (pane === peekedFor || pane === pending)) return;
|
if (pane && (pane === peekedFor || pane === pending)) return;
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
pending = null;
|
pending = null;
|
||||||
@@ -1032,7 +1047,7 @@ export function Panes() {
|
|||||||
for (const it of gone) lower(it);
|
for (const it of gone) lower(it);
|
||||||
peeked = [col];
|
peeked = [col];
|
||||||
peekedFor = pane;
|
peekedFor = pane;
|
||||||
if (gone.length) schedule();
|
if (gone.length) settled();
|
||||||
} else hide();
|
} else hide();
|
||||||
if (!pane || !its.some((x) => !peeked.includes(x))) return;
|
if (!pane || !its.some((x) => !peeked.includes(x))) return;
|
||||||
pending = pane;
|
pending = pane;
|
||||||
@@ -1043,8 +1058,40 @@ export function Panes() {
|
|||||||
if (now.length) peek(pane, now);
|
if (now.length) peek(pane, now);
|
||||||
}, PEEK_MS);
|
}, PEEK_MS);
|
||||||
};
|
};
|
||||||
el.addEventListener("pointerleave", unpeek, { signal });
|
const onMove = (e: PointerEvent) => {
|
||||||
window.addEventListener("keydown", unpeek, { capture: true, signal });
|
if (e.pointerType !== "mouse") return;
|
||||||
|
mouse = { x: e.clientX, y: e.clientY };
|
||||||
|
if (e.buttons || drag || edging) return;
|
||||||
|
// On an edge between panes (below): it is pressed to resize, not peeked through. Without Shift or Control, nothing peeks.
|
||||||
|
if (wrap.dataset.edge || !held(e)) return unpeek();
|
||||||
|
consider((e.target as HTMLElement).closest<HTMLElement>(".pane"));
|
||||||
|
};
|
||||||
|
/** Typing in a field: Shift is for capitals there. */
|
||||||
|
const typing = () => store.mode === "edit" || !!(document.activeElement as HTMLElement | null)?.closest?.("input, textarea, [contenteditable]");
|
||||||
|
// Shift or Control pressed: the covered pane under the resting mouse peeks. Any other key puts back what peeks (so does Shift or Control pressed off a covered pane).
|
||||||
|
const onPeekKey = (e: KeyboardEvent) => {
|
||||||
|
if (e.key !== "Shift" && e.key !== "Control") return unpeek();
|
||||||
|
if (!mouse || drag || edging || wrap.dataset.edge || typing()) return;
|
||||||
|
const t = document.elementFromPoint(mouse.x, mouse.y);
|
||||||
|
consider(t && el.contains(t) ? t.closest<HTMLElement>(".pane") : null);
|
||||||
|
};
|
||||||
|
// Both let go: it goes back.
|
||||||
|
const onPeekKeyUp = (e: KeyboardEvent) => !held(e) && unpeek();
|
||||||
|
// The wheel with Shift held over what peeks scrolls its text up and down (the browser would scroll sideways, and nothing there moves).
|
||||||
|
const onPeekWheel = (e: WheelEvent) => {
|
||||||
|
if (!e.shiftKey || e.ctrlKey || !peeked.length) return;
|
||||||
|
const t = e.target as HTMLElement;
|
||||||
|
const box = peeked.some((p) => p.contains(t)) ? t.closest<HTMLElement>(".pane-scroll") : null;
|
||||||
|
if (!box) return;
|
||||||
|
const d = e.deltaY || e.deltaX;
|
||||||
|
e.preventDefault();
|
||||||
|
box.scrollTop += e.deltaMode === 1 ? d * 16 : e.deltaMode === 2 ? d * box.clientHeight : d;
|
||||||
|
};
|
||||||
|
el.addEventListener("wheel", onPeekWheel, { passive: false, signal });
|
||||||
|
el.addEventListener("pointerleave", () => ((mouse = null), unpeek()), { signal });
|
||||||
|
window.addEventListener("keydown", onPeekKey, { capture: true, signal });
|
||||||
|
window.addEventListener("keyup", onPeekKeyUp, { capture: true, signal });
|
||||||
|
window.addEventListener("blur", unpeek, { signal });
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dragging a pane up or down its column, by its grip (the band above its title, beside the pin
|
* Dragging a pane up or down its column, by its grip (the band above its title, beside the pin
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ export const HELP: [string, [string, string][]][] = [
|
|||||||
["Alt+h Alt+l", "in panes: the pane this one was opened from (left) / one opened from it (right): the one opened from the focused row or link if it is open, else the one last visited; from a node, a selection or an article alike. Left then right comes back"],
|
["Alt+h Alt+l", "in panes: the pane this one was opened from (left) / one opened from it (right): the one opened from the focused row or link if it is open, else the one last visited; from a node, a selection or an article alike. Left then right comes back"],
|
||||||
["Alt+k Alt+j", "in panes: the pane above / below in the same column, across forks (Alt+↑ ↓ and [ ] too)"],
|
["Alt+k Alt+j", "in panes: the pane above / below in the same column, across forks (Alt+↑ ↓ and [ ] too)"],
|
||||||
["Alt+Shift+k j", "in panes: move the active pane up / down its column, as dragging it by its grip or tab does (Alt+Shift+↑ ↓ too; the pane's ⋯ menu offers the same)"],
|
["Alt+Shift+k j", "in panes: move the active pane up / down its column, as dragging it by its grip or tab does (Alt+Shift+↑ ↓ too; the pane's ⋯ menu offers the same)"],
|
||||||
["[ ]", "in panes: the pane above / below in the same column (back where you were in it, or at its head); at the top or bottom nothing moves. A crowded column stacks its panes as the strip stacks columns, covered to a tab; resting the mouse on a covered pane peeks it out; its grip or tab drags it up or down. The edge between two panes, or two columns, dragged by the mouse resizes them (Esc puts it back, a double click lays them out again); only a pinned pane's size, and the width of its column, stay once another pane is the active one. A faint curve runs from where each pane was opened to its title"],
|
["[ ]", "in panes: the pane above / below in the same column (back where you were in it, or at its head); at the top or bottom nothing moves. A crowded column stacks its panes as the strip stacks columns, covered to a tab; Shift or Control held with the mouse on a covered pane peeks it out (a plain hover never does; letting go puts it back); its grip or tab drags it up or down. The edge between two panes, or two columns, dragged by the mouse resizes them (Esc puts it back, a double click lays them out again); only a pinned pane's size, and the width of its column, stay once another pane is the active one. A faint curve runs from where each pane was opened to its title"],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|||||||
+1
-1
@@ -443,7 +443,7 @@ kbd, .help code { font-family: var(--mono); font-size: 0.86em; border: 1px solid
|
|||||||
/* A pane or column covered down to its tab or spine has nothing else on show: it is not painted, until it peeks. */
|
/* A pane or column covered down to its tab or spine has nothing else on show: it is not painted, until it peeks. */
|
||||||
.col[data-buried]:not([data-peek]) .pane-scroll, .col.crowded > .pane[data-buried]:not([data-peek]) > .pane-scroll { content-visibility: hidden; }
|
.col[data-buried]:not([data-peek]) .pane-scroll, .col.crowded > .pane[data-buried]:not([data-peek]) > .pane-scroll { content-visibility: hidden; }
|
||||||
|
|
||||||
/* Peeking: a covered pane or column, the mouse resting on it, raised over its neighbours whole. */
|
/* Peeking: a covered pane or column, the mouse on it with Shift or Control held, raised over its neighbours whole. */
|
||||||
.col[data-peek], .pane[data-peek] { z-index: 6; box-shadow: 0 3px 18px 0 var(--shade); outline: 1px solid var(--edge-strong); outline-offset: -1px; }
|
.col[data-peek], .pane[data-peek] { z-index: 6; box-shadow: 0 3px 18px 0 var(--shade); outline: 1px solid var(--edge-strong); outline-offset: -1px; }
|
||||||
/* A pane peeking down its column is shown as tall as its text needs; the extra height takes no room, so nothing around it moves. */
|
/* A pane peeking down its column is shown as tall as its text needs; the extra height takes no room, so nothing around it moves. */
|
||||||
.pane[data-peek-h] { height: var(--peek-h) !important; margin-bottom: calc(-1 * var(--peek-extra, 0px)); }
|
.pane[data-peek-h] { height: var(--peek-h) !important; margin-bottom: calc(-1 * var(--peek-extra, 0px)); }
|
||||||
|
|||||||
Reference in new issue
Block a user