fix: draw the bar's neck in the bar container; the changelog button folds the list back
Page glass near the bar is passed to the bar container as fusion partners, so the bridge stays attached to the still bar while the page scrolls. The earlier-versions button turns into a collapse button and keeps its place on screen when the list folds.
This commit is contained in:
1 parent
09fd1a8cd5
commit
4e7eb7dc06
2 files changed
+43
-23
No files matched your search
+40
-20
@@ -271,7 +271,11 @@ function renderTimeline() {
|
||||
if (!state.expanded && index >= PAGE) item.classList.add("hidden");
|
||||
return item;
|
||||
}));
|
||||
$("#more").hidden = state.expanded || visible.length <= PAGE;
|
||||
// One button both ways: it expands the list, then folds it back.
|
||||
const more = $("#more");
|
||||
more.hidden = visible.length <= PAGE;
|
||||
more.textContent = t(state.expanded ? "collapse" : "log.more");
|
||||
more.setAttribute("aria-expanded", String(state.expanded));
|
||||
observeReveal();
|
||||
}
|
||||
|
||||
@@ -467,14 +471,13 @@ uniform sampler2D u_blur;
|
||||
uniform vec2 u_res; // canvas, px
|
||||
uniform vec2 u_origin; // canvas top-left in the viewport, px
|
||||
uniform vec4 u_fbo; // viewport rect the scene textures cover, px
|
||||
uniform int u_cutBar; // page container: the bar container draws the bar itself
|
||||
uniform vec2 u_mouse;
|
||||
uniform vec2 u_light; // the blade's light, px
|
||||
uniform float u_px;
|
||||
uniform float u_time;
|
||||
uniform int u_count;
|
||||
uniform vec4 u_glass[MAX];
|
||||
uniform vec4 u_meta[MAX]; // radius, kind, hover (+1 while pressed), layer
|
||||
uniform vec4 u_meta[MAX]; // radius, kind (6 = partner: fuses, not drawn), hover (+1 while pressed), layer
|
||||
out vec4 color;
|
||||
|
||||
float hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }
|
||||
@@ -504,7 +507,7 @@ void main() {
|
||||
|
||||
// Per-layer distances. Layer 0 holds panels and free pills; the bar is
|
||||
// kept apart so it can fuse with them.
|
||||
float d0 = 1e5, d1 = 1e5, d2 = 1e5, dBar = 1e5;
|
||||
float d0 = 1e5, d1 = 1e5, d2 = 1e5, dBar = 1e5, dPart = 1e5;
|
||||
float k0 = 0.0, hov0 = 0.0, hov1 = 0.0, hov2 = 0.0, acc2 = 0.0, bar0 = 0.0;
|
||||
float kSelf = 6.0 * u_px;
|
||||
for (int i = 0; i < MAX; i++) {
|
||||
@@ -512,23 +515,28 @@ void main() {
|
||||
vec4 r = u_glass[i], m = u_meta[i];
|
||||
float d = shape(px, r, min(m.x, min(r.z, r.w) * .5));
|
||||
float near = 1.0 - smoothstep(0.0, 24.0 * u_px, d);
|
||||
if (m.y == 6.0) { dPart = smin(dPart, d, kSelf); continue; }
|
||||
if (m.y == 4.0) { dBar = min(dBar, d); bar0 = max(bar0, near); }
|
||||
else if (m.w == 0.0) { d0 = smin(d0, d, kSelf); hov0 = max(hov0, m.z * near); k0 = max(k0, (m.y == 0.0 ? 1.0 : 0.0) * near); }
|
||||
else if (m.w == 1.0) { d1 = smin(d1, d, kSelf); hov1 = max(hov1, m.z * near); }
|
||||
else { d2 = smin(d2, d, kSelf); hov2 = max(hov2, m.z * near); acc2 = max(acc2, (m.y == 2.0 ? 1.0 : 0.0) * near); }
|
||||
}
|
||||
float own = d0;
|
||||
// Contact: within kBar the bar and the glass near it pull into one shape;
|
||||
// neck marks the bridge between them.
|
||||
// Contact: within kBar glass pulls into one shape with the bar; neck marks
|
||||
// the bridge. Partners are page glass near the bar: the bar container draws
|
||||
// the neck toward them (the bar is still while they scroll, so its side of
|
||||
// the bridge must not trail) and leaves their own body to the page.
|
||||
float kBar = 30.0 * u_px;
|
||||
float neck = clamp(1.0 - abs(d0 - dBar) / kBar, 0.0, 1.0) * (1.0 - smoothstep(0.0, kBar, max(d0, dBar)));
|
||||
d0 = smin(d0, dBar, kBar);
|
||||
float base = d0;
|
||||
neck = max(neck, clamp(1.0 - abs(d0 - dPart) / kBar, 0.0, 1.0) * (1.0 - smoothstep(0.0, kBar, max(d0, dPart))));
|
||||
d0 = smin(d0, dPart, kBar);
|
||||
|
||||
// Gradients for all layers before any branching.
|
||||
vec2 g0 = vec2(dFdx(d0), -dFdy(d0)), g1 = vec2(dFdx(d1), -dFdy(d1)), g2 = vec2(dFdx(d2), -dFdy(d2));
|
||||
|
||||
// Soft shadow under the base layer.
|
||||
float shadow = .3 * (1.0 - smoothstep(0.0, 26.0 * u_px, d0)) * step(0.0, d0);
|
||||
float shadow = .3 * (1.0 - smoothstep(0.0, 26.0 * u_px, base)) * step(0.0, d0);
|
||||
col *= 1.0 - shadow;
|
||||
float cover = 0.0;
|
||||
|
||||
@@ -601,9 +609,7 @@ void main() {
|
||||
// Premultiplied, so that compositing onto the scene gives col back.
|
||||
float a = 1.0 - (1.0 - cover) * (1.0 - shadow);
|
||||
vec4 outc = vec4(max(col - bg * (1.0 - a), 0.0), a);
|
||||
// The page container leaves the bar's body to the bar container but keeps
|
||||
// its own glass under it and the neck outside it.
|
||||
if (u_cutBar == 1) outc *= max(1.0 - smoothstep(-1.0 * u_px, 1.0 * u_px, own), smoothstep(-1.0 * u_px, 1.0 * u_px, dBar));
|
||||
outc *= max(smoothstep(-1.0 * u_px, 1.0 * u_px, dPart), 1.0 - smoothstep(-1.0 * u_px, 1.0 * u_px, base));
|
||||
color = outc;
|
||||
}`;
|
||||
|
||||
@@ -655,7 +661,7 @@ function glassContext(canvas, art, sceneOnly) {
|
||||
let targets = null, size = "";
|
||||
|
||||
// f: ratio, view [w, h], canvas {x, y, w, h} and fbo {x, y, w, h} in
|
||||
// viewport CSS px, time, art rect, dim, mouse, light, list, cutBar.
|
||||
// viewport CSS px, time, art rect, dim, mouse, light and list.
|
||||
return function render(f) {
|
||||
const k = f.ratio, r = f.rect, c = f.canvas, b = f.fbo || f.canvas;
|
||||
const cw = Math.max(1, Math.round(c.w * k)), ch = Math.max(1, Math.round(c.h * k));
|
||||
@@ -712,7 +718,6 @@ function glassContext(canvas, art, sceneOnly) {
|
||||
gl.uniform2f(u("u_res"), cw, ch);
|
||||
gl.uniform2f(u("u_origin"), c.x * k, c.y * k);
|
||||
gl.uniform4f(u("u_fbo"), b.x * k, b.y * k, bw, bh);
|
||||
gl.uniform1i(u("u_cutBar"), f.cutBar ? 1 : 0);
|
||||
gl.uniform2f(u("u_mouse"), f.mouse[0] * k, f.mouse[1] * k);
|
||||
gl.uniform2f(u("u_light"), f.light[0] * k, f.light[1] * k);
|
||||
gl.uniform1f(u("u_px"), k);
|
||||
@@ -830,10 +835,13 @@ function shaderScene(scene, art, state) {
|
||||
const radius = Math.min(radii.get(node), w / 2, h / 2) * ratio;
|
||||
const meta = [radius, kind, m.hover.x + m.press.x, layer];
|
||||
if (kind === 4) barBox = r;
|
||||
if (!inBar.get(node)) { push(pageList, x * ratio, y * ratio, w * ratio, h * ratio, meta); continue; }
|
||||
if (!inBar.get(node)) {
|
||||
push(pageList, x * ratio, y * ratio, w * ratio, h * ratio, meta);
|
||||
// Base glass near the bar also goes to the bar container as a partner.
|
||||
if (layer === 0 && barBox && r.top < barBox.bottom + 40 && r.bottom > barBox.top - 40) push(barList, x * ratio, y * ratio, w * ratio, h * ratio, [radius, 6, 0, 0]);
|
||||
continue;
|
||||
}
|
||||
push(barList, x * ratio, y * ratio, w * ratio, h * ratio, meta);
|
||||
// The page container fuses with the bar, which its own container draws.
|
||||
if (kind === 4) push(pageList, x * ratio, y * ratio, w * ratio, h * ratio, [radius, 4, 0, 0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -898,7 +906,7 @@ function shaderScene(scene, art, state) {
|
||||
mouse: [state.pointer.tx, state.pointer.ty], light: [r.x + .46 * r.w, r.y + .565 * r.h],
|
||||
};
|
||||
sceneRender({ ...frame, canvas: view });
|
||||
pageRender({ ...frame, canvas: { x: 0, y: -margin, w: vw, h: vh + 2 * margin }, fbo: view, list: pageList, cutBar: true });
|
||||
pageRender({ ...frame, canvas: { x: 0, y: -margin, w: vw, h: vh + 2 * margin }, fbo: view, list: pageList });
|
||||
const style = pageCanvas.style;
|
||||
style.width = `${vw}px`;
|
||||
style.height = `${vh + 2 * margin}px`;
|
||||
@@ -907,10 +915,10 @@ function shaderScene(scene, art, state) {
|
||||
|
||||
// The bar container covers the bar, its menu and their shadow only.
|
||||
if (region && barList.count) {
|
||||
const pad = 28, reach = 64;
|
||||
const pad = 40, reach = 64;
|
||||
const box = { x: Math.floor(region.x - pad), y: Math.floor(Math.max(0, region.y - pad)), w: 0, h: 0 };
|
||||
box.w = Math.ceil(region.w + 2 * pad); box.h = Math.ceil(region.y + region.h + pad - box.y);
|
||||
barRender({ ...frame, canvas: box, fbo: { x: box.x - reach, y: box.y - reach, w: box.w + 2 * reach, h: box.h + 2 * reach }, list: barList, cutBar: false });
|
||||
barRender({ ...frame, canvas: box, fbo: { x: box.x - reach, y: box.y - reach, w: box.w + 2 * reach, h: box.h + 2 * reach }, list: barList });
|
||||
const s = barCanvas.style;
|
||||
s.display = "";
|
||||
s.width = `${box.w}px`; s.height = `${box.h}px`;
|
||||
@@ -1082,7 +1090,19 @@ function bind() {
|
||||
sceneLight.refresh?.();
|
||||
}));
|
||||
$("#more").addEventListener("click", () => {
|
||||
morph($(".log"), () => { state.expanded = true; renderTimeline(); }, () => $$("#timeline > .entry").slice(PAGE));
|
||||
const more = $("#more");
|
||||
if (!state.expanded) {
|
||||
morph($(".log"), () => { state.expanded = true; renderTimeline(); }, () => $$("#timeline > .entry").slice(PAGE));
|
||||
} else {
|
||||
// Fold back: keep the button where the eye is by scrolling with the
|
||||
// shrinking list, so it does not jump far down the page.
|
||||
const before = more.getBoundingClientRect().top;
|
||||
morph($(".log"), () => { state.expanded = false; renderTimeline(); });
|
||||
const shift = more.getBoundingClientRect().top - before;
|
||||
if (shift < 0 && !PREFS.calm) scrollBy({ top: shift, behavior: "smooth" });
|
||||
else if (shift < 0) scrollBy(0, shift);
|
||||
}
|
||||
more.animate?.([{ opacity: 0, transform: "scale(.92)" }, { opacity: 1, transform: "none" }], { duration: 380, easing: SMOOTH });
|
||||
sceneLight.refresh?.();
|
||||
});
|
||||
$$(".hero, .card, .log, .verify").forEach(n => n.classList.add("reveal"));
|
||||
|
||||
+3
-3
@@ -9,8 +9,8 @@
|
||||
<meta name="theme-color" content="#140a24">
|
||||
<link rel="icon" href="/assets/icon.svg" type="image/svg+xml">
|
||||
<link rel="preload" href="/assets/bg.webp" as="image" type="image/webp">
|
||||
<link rel="stylesheet" href="/assets/app.css?v=11">
|
||||
<script src="/assets/app.js?v=11" defer></script>
|
||||
<link rel="stylesheet" href="/assets/app.css?v=12">
|
||||
<script src="/assets/app.js?v=12" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="scene" aria-hidden="true">
|
||||
@@ -106,7 +106,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<ol class="timeline" id="timeline"><li class="muted" data-i18n="loading">载入中…</li></ol>
|
||||
<button type="button" class="more pill" id="more" hidden data-i18n="log.more">显示更早的版本</button>
|
||||
<button type="button" class="more pill" id="more" hidden>显示更早的版本</button>
|
||||
<p class="source"><span data-i18n="log.source">内容来自签名发布的</span> <a href="/releases/CHANGELOG.md">CHANGELOG.md</a></p>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in new issue
Block a user