From 0690db23ebd3b6d86fd1613f3be2490cd166f825 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 12:09:59 +0000 Subject: [PATCH 1/4] docs(fixlip): the page scrolls plainly from the demo to the write-up - The first page is no longer held while the write-up slides over it. The demo fills the first screen, and the link and the divider lead to the Summary. - figures.js only measures where the demo starts and keeps the title on one line. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_019qiuyCA3ZwoP9HdB6UGfZc --- docs/source/demos/fixlip/assets/figures.css | 91 --------------------- docs/source/demos/fixlip/assets/figures.js | 37 ++------- 2 files changed, 7 insertions(+), 121 deletions(-) diff --git a/docs/source/demos/fixlip/assets/figures.css b/docs/source/demos/fixlip/assets/figures.css index d9d243482..d13b76356 100644 --- a/docs/source/demos/fixlip/assets/figures.css +++ b/docs/source/demos/fixlip/assets/figures.css @@ -1761,97 +1761,6 @@ article[role="main"] hr.docutils { margin: 2.25rem 0; } -/* -- the first page and the second page -------------------------------------------------------------- */ - -/* The title and the demo are the first page, and the write-up is the second. While the page is - scrolled, the first page stays where it is, and the second slides up over it like a sheet. The - first page recedes under it: it shrinks a little and dims. figures.js marks the section of the - page with fixlip-staged and measures the places: where the title and the block of the demo lie - on the page (--fixlip-title-top, --fixlip-opening-top), by how much the first page is higher than - the screen (--fixlip-over, the page scrolls by this much before the first page stays), and where - the sheet starts in the section (--fixlip-sheet-top). While it measures, the section has the - class fixlip-placing, and nothing is held. The first page lies under the section's own content - (the negative layers stay inside the section, which keeps its layers to itself), so the write-up - needs no layer of its own. Without the script, the page scrolls as one, and so it does on a - narrow screen, where the docs scroll the text column sideways and nothing can be held in it. */ -@media screen and (min-width: 48.1em) { - article[role="main"] section.fixlip-staged { - position: relative; - isolation: isolate; - } - - article[role="main"] section.fixlip-staged:not(.fixlip-placing) > h1, - article[role="main"] section.fixlip-staged:not(.fixlip-placing) > .fixlip-opening { - position: sticky; - z-index: -2; - } - - article[role="main"] section.fixlip-staged:not(.fixlip-placing) > h1 { - top: calc(var(--fixlip-title-top, 0px) - var(--fixlip-over, 0px)); - /* both parts shrink towards the same point, a little above the middle of the screen */ - transform-origin: 50% calc(45vh - var(--fixlip-title-top, 0px) + var(--fixlip-over, 0px)); - } - - article[role="main"] section.fixlip-staged:not(.fixlip-placing) > .fixlip-opening { - top: calc(var(--fixlip-opening-top, 0px) - var(--fixlip-over, 0px)); - transform-origin: 50% calc(45vh - var(--fixlip-opening-top, 0px) + var(--fixlip-over, 0px)); - } - - /* the sheet: the ground of the write-up, from a little under the end of the first page (so that - its shadow does not show there) to the end of the section, a little wider than the text */ - article[role="main"] section.fixlip-staged::before { - content: ""; - position: absolute; - z-index: -1; - top: calc(var(--fixlip-sheet-top, 100vh) + 2rem); - right: calc(-1 * var(--fixlip-sheet-bleed)); - bottom: 0; - left: calc(-1 * var(--fixlip-sheet-bleed)); - border-top: 1px solid var(--color-background-border, #eeebee); - border-radius: 1.25rem 1.25rem 0 0; - background: var(--color-background-primary, #ffffff); - box-shadow: 0 -1.5rem 2.5rem -1.75rem rgba(15, 18, 30, 0.35); - --fixlip-sheet-bleed: 1rem; - } - - /* the edge of the sheet is the divider */ - article[role="main"] section.fixlip-staged > .fixlip-opening + hr.docutils { - display: none; - } - - article[role="main"] section.fixlip-staged > .fixlip-opening + hr.docutils + section.fixlip-summary { - margin-top: 4.5rem; - } -} - -@media screen and (min-width: 67.1em) { - article[role="main"] section.fixlip-staged::before { - --fixlip-sheet-bleed: 2rem; - } -} - -/* The first page recedes with the scroll position of the page, from where it starts to stay until - the sheet has covered most of the screen. The browser runs this with the scrolling itself. A - browser that cannot leaves the first page as it is under the sheet, and so does a reader who - asked for less motion. */ -@supports (animation-timeline: scroll()) { - @media screen and (min-width: 48.1em) and (prefers-reduced-motion: no-preference) { - article[role="main"] section.fixlip-staged:not(.fixlip-placing) > h1, - article[role="main"] section.fixlip-staged:not(.fixlip-placing) > .fixlip-opening { - animation: fixlip-recede linear both; - animation-timeline: scroll(root block); - animation-range: var(--fixlip-over, 0px) calc(var(--fixlip-over, 0px) + 85vh); - } - } -} - -@keyframes fixlip-recede { - to { - opacity: 0.2; - scale: 0.93; - } -} - /* -- the colors that the text names -------------------------------------------------------------------- */ /* Where the text or a caption names the red and the blue of the figures, the word is set in that diff --git a/docs/source/demos/fixlip/assets/figures.js b/docs/source/demos/fixlip/assets/figures.js index ec2273d06..94158b1f8 100644 --- a/docs/source/demos/fixlip/assets/figures.js +++ b/docs/source/demos/fixlip/assets/figures.js @@ -1545,18 +1545,12 @@ }); } - // The first page of the page is its title and the block of the demo (.fixlip-opening), which - // reaches to the end of the screen. The write-up is the second page. figures.css keeps the first - // page in place while the second slides over it, and needs the places for that: where the title - // and the block lie on the page, by how much the first page is higher than the screen, and where - // the second page starts in the section. They are measured with nothing held in place. + // The first screen of the page: the title and the block of the demo (.fixlip-opening), which + // reaches to the end of the screen (figures.css), for which it needs to know where it starts. const opening = document.querySelector(".fixlip-opening"); - const stage = opening?.parentElement; - const title = stage?.querySelector(":scope > h1"); + const title = opening?.parentElement.querySelector(":scope > h1"); if (opening && title) { - stage.classList.add("fixlip-staged"); const place = () => { - stage.classList.add("fixlip-placing"); // the title stays on one line (figures.css), also in a font that runs wider than expected title.style.fontSize = ""; const look = getComputedStyle(title); @@ -1567,23 +1561,12 @@ const room = title.clientWidth; if (width > room) title.style.fontSize = `${Math.floor((parseFloat(look.fontSize) * room * 10) / width) / 10}px`; } - const down = window.scrollY; - const top = Math.round(opening.getBoundingClientRect().top + down); - stage.style.setProperty("--fixlip-title-top", `${Math.round(title.getBoundingClientRect().top + down)}px`); - stage.style.setProperty("--fixlip-opening-top", `${top}px`); - // the block now has its height for this place - const height = opening.offsetHeight; - const over = Math.max(0, top + height - document.documentElement.clientHeight); - stage.style.setProperty("--fixlip-over", `${over}px`); - const start = top + height - (stage.getBoundingClientRect().top + down); - stage.style.setProperty("--fixlip-sheet-top", `${Math.round(start)}px`); - stage.classList.remove("fixlip-placing"); + const top = Math.round(opening.getBoundingClientRect().top + window.scrollY); + opening.style.setProperty("--fixlip-opening-top", `${top}px`); }; place(); - // the title wraps anew at another width, the demo grows with its note, the screen changes - const watch = new ResizeObserver(place); - watch.observe(stage); - watch.observe(opening); + // the title wraps anew at another width, the screen changes + new ResizeObserver(place).observe(opening.parentElement); window.addEventListener("resize", place); // the link under the demo leads to the write-up, which starts with the box of the summary (the @@ -1597,12 +1580,6 @@ summary.scrollIntoView({ behavior: calm ? "auto" : "smooth", block: "start" }); history.replaceState(null, "", link.hash); }); - // a part of the first page that takes the focus while the write-up covers it comes into view - opening.addEventListener("focusin", () => { - if (window.scrollY > parseFloat(stage.style.getPropertyValue("--fixlip-over")) + 8) { - window.scrollTo({ top: 0 }); - } - }); } const load = (name, file) => From 9b08bf39e582857103d49dc0b9990197bf0a6bfd Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 12:18:45 +0000 Subject: [PATCH 2/4] docs(fixlip): the link to the write-up scrolls slower The page glides to the Summary with a soft start and end, in 1 to 1.7 s by the way it has to go. A wheel, a touch or a key stops it. With reduced motion it jumps. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_019qiuyCA3ZwoP9HdB6UGfZc --- docs/source/demos/fixlip/assets/figures.js | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/docs/source/demos/fixlip/assets/figures.js b/docs/source/demos/fixlip/assets/figures.js index 94158b1f8..2b2eb625f 100644 --- a/docs/source/demos/fixlip/assets/figures.js +++ b/docs/source/demos/fixlip/assets/figures.js @@ -1573,12 +1573,37 @@ // label of the section lies inside the box) const link = opening.querySelector(".fixlip-more a"); const summary = link && document.getElementById(link.hash.slice(1))?.closest("section"); + // The page glides there, slower than the browser scrolls by itself: it starts and ends softly + // and takes longer for a longer way. The reader takes over with the wheel, a touch or a key. + let glide = 0; + const halt = () => cancelAnimationFrame(glide); + for (const kind of ["wheel", "touchstart", "keydown", "pointerdown"]) { + window.addEventListener(kind, halt, { passive: true }); + } link?.addEventListener("click", (event) => { if (!summary) return; event.preventDefault(); - const calm = window.matchMedia("(prefers-reduced-motion: reduce)").matches; - summary.scrollIntoView({ behavior: calm ? "auto" : "smooth", block: "start" }); + halt(); history.replaceState(null, "", link.hash); + const from = window.scrollY; + const room = document.documentElement.scrollHeight - window.innerHeight; + const margin = parseFloat(getComputedStyle(summary).scrollMarginTop) || 0; + const to = Math.min(room, Math.round(summary.getBoundingClientRect().top + from - margin)); + if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) { + window.scrollTo({ top: to, behavior: "instant" }); + return; + } + const time = Math.min(1700, Math.max(1000, 750 + Math.abs(to - from) * 0.6)); + let start = 0; + const step = (now) => { + start ||= now; + const share = Math.min(1, (now - start) / time); + const eased = share < 0.5 ? 4 * share ** 3 : 1 - (-2 * share + 2) ** 3 / 2; + // the docs scroll smoothly by themselves, which would lag behind every step + window.scrollTo({ top: from + (to - from) * eased, behavior: "instant" }); + if (share < 1) glide = requestAnimationFrame(step); + }; + glide = requestAnimationFrame(step); }); } From b82c69b48fd06b7e6211db651ff53c51df94d003 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 14:59:44 +0000 Subject: [PATCH 3/4] docs(fixlip demo): the demo does not move while its page loads - demo.js lays the demo out before its first paint. It did so a frame later, so the demo first showed without the room that its caption keeps, about 280 px taller, and then moved by a line. - figures.css guesses where the block of the demo starts until figures.js has measured it, so the block keeps its height then. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_019qiuyCA3ZwoP9HdB6UGfZc --- docs/source/demos/fixlip/assets/demo.js | 19 +++++++++++++------ docs/source/demos/fixlip/assets/figures.css | 13 +++++++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/docs/source/demos/fixlip/assets/demo.js b/docs/source/demos/fixlip/assets/demo.js index 784d1e46c..fbbc6c2ba 100644 --- a/docs/source/demos/fixlip/assets/demo.js +++ b/docs/source/demos/fixlip/assets/demo.js @@ -1098,23 +1098,30 @@ show(null); } }); + // the demo's layout for its width: the room that its texts keep and the place of the excerpt + const layOut = () => { + setShift(); + reserveRoom(); + placeExcerpt(); + if (state.focus === null) show(null); + }; // a new width lays the demo out again (in the next frame, outside the observer's callback) let width = -1; new ResizeObserver(([entry]) => { const now = Math.round(entry.contentRect.width); if (now === width) return; + const first = width < 0; width = now; - requestAnimationFrame(() => { - setShift(); - reserveRoom(); - placeExcerpt(); - if (state.focus === null) show(null); - }); + // the first report is the width that the demo was built for and laid out with below + if (!first) requestAnimationFrame(layOut); }).observe(root); root.classList.add("fixlip-demo-ready"); reset(); setView(state.view); + // laid out before the browser paints the demo for the first time: a frame later, the demo + // would first show without the room it keeps, taller, and then move + layOut(); started = true; } })(); diff --git a/docs/source/demos/fixlip/assets/figures.css b/docs/source/demos/fixlip/assets/figures.css index d13b76356..b4eaed022 100644 --- a/docs/source/demos/fixlip/assets/figures.css +++ b/docs/source/demos/fixlip/assets/figures.css @@ -1647,8 +1647,17 @@ article[role="main"] section:has(> .fixlip-opening) > h1 > a.headerlink { .fixlip-opening { display: flex; flex-direction: column; - min-height: calc(100vh - var(--fixlip-opening-top, 8rem)); - min-height: calc(100svh - var(--fixlip-opening-top, 8rem)); + min-height: calc(100vh - var(--fixlip-opening-top, var(--fixlip-opening-guess))); + min-height: calc(100svh - var(--fixlip-opening-top, var(--fixlip-opening-guess))); + /* where the block starts until figures.js has measured it: under the title, and on a narrower + page under the bar of the docs too, so that the block does not change its height then */ + --fixlip-opening-guess: 8.25rem; +} + +@media (max-width: 67em) { + .fixlip-opening { + --fixlip-opening-guess: 11.3rem; + } } .fixlip-opening > .fixlip-demo { From 8b91e86cb077cdbd805357c2d24cfc45c3ea74bb Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 15:05:00 +0000 Subject: [PATCH 4/4] docs(fixlip): Definition 1 in the notation of the paper An explanation is a vector over the explanation basis B, the union of three index sets, as in Definition 1 of the paper. The page wrote it as a tuple of three families. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_019qiuyCA3ZwoP9HdB6UGfZc --- docs/source/demos/fixlip/index.rst | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/source/demos/fixlip/index.rst b/docs/source/demos/fixlip/index.rst index 9c4a3b09b..07e94dd26 100644 --- a/docs/source/demos/fixlip/index.rst +++ b/docs/source/demos/fixlip/index.rst @@ -211,24 +211,23 @@ explanation is defined as follows. .. shapiq-definition:: Explanation :name: fixlip-def-explanation - An explanation :math:`\mathbf{e}` consists of a constant :math:`\mathbf{e}_0 \in \mathbb{R}`, a - *main effect* :math:`\mathbf{e}_i \in \mathbb{R}` for each token, and an *interaction* - :math:`\mathbf{e}_{\{i,j\}} \in \mathbb{R}` for each pair of tokens, i.e. + An explanation :math:`\mathbf{e} \in \mathbb{R}^{\vert \mathcal{B} \vert}` assigns a constant + :math:`\mathbf{e}_0 \in \mathbb{R}`, a *main effect* :math:`\mathbf{e}_i \in \mathbb{R}` to each + token, and an *interaction* :math:`\mathbf{e}_{\{i,j\}} \in \mathbb{R}` to each pair of tokens, + for an *explanation basis* .. math:: - \mathbf{e} := \Big( + \mathcal{B} := \class{fixlip-brace}{\underbrace{\class{fixlip-braced}{ - \mathbf{e}_0 \vphantom{(\mathbf{e}_{\{i,j\}})_{\{i,j\} \subseteq N_\mathcal{T}: i \neq j}} - }}_{\class{fixlip-braced}{\text{constant}\mathstrut}}}, \; + \{0\} + }}_{\class{fixlip-braced}{\text{constant}\mathstrut}}} \;\cup\; \class{fixlip-brace}{\underbrace{\class{fixlip-braced}{ - (\mathbf{e}_i)_{i \in N_\mathcal{I} \cup N_\mathcal{T}} - \vphantom{(\mathbf{e}_{\{i,j\}})_{\{i,j\} \subseteq N_\mathcal{T}: i \neq j}} - }}_{\class{fixlip-braced}{\text{main effects}\mathstrut}}}, \; + \{i: i \in N_\mathcal{I} \cup N_\mathcal{T}\} + }}_{\class{fixlip-braced}{\text{individual tokens}\mathstrut}}} \;\cup\; \class{fixlip-brace}{\underbrace{\class{fixlip-braced}{ - (\mathbf{e}_{\{i,j\}})_{\{i,j\} \subseteq N_\mathcal{I} \cup N_\mathcal{T}: i \neq j} - }}_{\class{fixlip-braced}{\text{interactions}\mathstrut}}} - \Big) + \{\{i,j\}: i,j \in N_\mathcal{I} \cup N_\mathcal{T}, i \neq j\} + }}_{\class{fixlip-braced}{\text{two-token interaction sets}\mathstrut}}} :shapiq-statement:`fixlip-def-explanation` fixes the form of an explanation, but not its values. The values should describe how the prediction changes when tokens are removed from the input. FIxLIP