Peach: Local-first video metadata scraper and media manager.
feat(web): 原地换态的六档动效落到字形、读数、骨架、开关与成败反馈
longmeidao41805827c6ba
diff --git a/docs/HANDOFF.md b/docs/HANDOFF.mdindex e5f34cfcb..0e7e72b68 100644--- a/docs/HANDOFF.md+++ b/docs/HANDOFF.md@@ -75,20 +75,21 @@版本与差异见 `docs/reference-sources.json`、`docs/reference-snapshots/`,流程见`.claude/skills/peach-reference-evidence/SKILL.md`。本节只索引快照,不复制测量值;给不出可重抓-字节的实测不进登记表,理由写进快照正文——`tests/test_reference_updates.py` 会拒绝既没登记也没说明的快照。+字节的实测不登记,理由写进快照正文——`tests/test_reference_updates.py` 会拒绝既没登记也没说明的快照。- 渐变参数模型、`in oklab` 插值与噪点叠层:`feralui-gradients-measured`;工作台与配色圆钮:`feralui-studio-boardui-accent-measured`。- 相关推荐算法:`openaver-related-ranking`,固定 revision,只参考 Tag IDF 与结构化共同点,MMR 和稳定破同分是 Peach 自加,不复制上游界面或源码。- 网格、控件半径、语义 token 与中间省略:`vercel-geist-grid`、`vercel-geist-controls-measured`、`vercel-geist-middle-truncate`;中间省略只用于路径、URL、ID、SHA 这类首尾都有信息的值,须显式 `data-middle-truncate`,标题、说明、人名和标签留末尾省略。-- 统计与口味层级,Note/Progress/Gauge/Context Card 等控件:`vercel-geist-semantics-measured`、`vercel-geist-note-progress-switch-analytics`、`vercel-geist-fieldset-scroller-empty-state`;配置页截图补证:`vercel-geist-controls-measured`。+- 统计与口味层级,Note/Progress/Gauge/Context Card 等控件:`vercel-geist-semantics-measured`、`vercel-geist-note-progress-switch-analytics`、`vercel-geist-fieldset-scroller-empty-state`。- 分类切换条属于 Tabs 的 secondary 变体而不是分段器:`vercel-geist-tabs-secondary-measured`。- 表格、排行与面包屑:`vercel-geist-table-ranking`、`vercel-geist-breadcrumbs`;同形可比较数据才用语义 `table` 并用 tabular numerals,内容标签是固定 Top 排行和直接筛选,不伪装成可排序数据表。- 设置 Dialog 动效、搜索期 Spinner、后台 Loading Dots 与 busy 按钮:`vercel-geist-command-search-loading`;中性说明 Note:`vercel-notifications-note`;具名动作 Toast:`vercel-geist-toast`;确认弹层(2026-09-06):`vercel-geist-modal-measured`。- 资料页阅读顺序与照片入口:`beeg-profile-layout`;JAV 标题显示语义:`jav-title-user-screenshot`;卡片悬停的快退/快进控件:`hover-seek-controls-user-screenshot`(beeg 现网无此控件,只依据用户截图)。-- 播放器控制栏、设置浮层、影院与全屏几何:`youtube-player-controls-user-screenshot`;沉浸页版式:`youtube-shorts-immersive-user-screenshot`;播放统计历史:`youtube-stats-buffer-measured`;小窗与右键菜单:`youtube-miniplayer-measured`;手机顶栏:`youtube-mobile-topbar-measured`。Peach 不复制字幕、睡眠定时或自动播放按钮。+- 播放器控制栏、设置浮层与全屏几何:`youtube-player-controls-user-screenshot`;沉浸页版式:`youtube-shorts-immersive-user-screenshot`;统计历史:`youtube-stats-buffer-measured`;小窗与右键菜单:`youtube-miniplayer-measured`;手机顶栏:`youtube-mobile-topbar-measured`。不复制字幕、睡眠定时与自动播放按钮。- 追更与文件站的凭据与解析边界:`f95-masked-gofile-media`、`follow-fanbox-gofile-paheal`、`fanbox-browser-transport`、`rule34-follow-tags-and-collections`;厂牌 Logo 候选发现:`fiu758-studio-logo-discovery`,只作发现来源不作真相源。- 通用评审清单与报告型页面版式:`vercel-web-interface-guidelines`、`vercel-report-design`。-- 默认 Note、只读提示和 info 入口统一复用本地 Lucide 圆圈 `i`,2px 描边与圆端点保证圆点可见,不复制未开放许可的 Geist 私有 SVG。+- 默认 Note、只读提示和 info 入口复用本地 Lucide 圆圈 `i`(2px 描边、圆端点),不复制未开放许可的 Geist 私有 SVG。+- 原地换态动效的形态与参数(字形、读数、骨架、开关、成功、失败):`transitions-dev-measured`。- 沉浸与详情播放每次加载都带独立 `session`,切片、关闭、失败和页面离开时取消旧会话:只清浏览器的 `src` 不足以停止 CloudDrive 预读或 FFmpeg。Mix 只按已解析且可播放的视频计数,不按回复数或网盘页数计数。- FANBOX 正文统一先经过 `peach.fanbox.normalize_fanbox_post`,数据模型固定参考 PixivUtil2 `v20251112` / `e537e96`:只有图片和视频进入可切换媒体,压缩包等文件只留资源链接,重复 URL 按正文首次出现顺序去重。- FANBOX Cookie 与 Gofile token 都是本机可选凭据,只进各自站点的请求头,不进 URL、证据、ledger 公开投影或浏览器 JSON;只允许公开 JSON,不解机器人质询、不执行网页脚本、不读付费内容。diff --git a/docs/reference-snapshots/transitions-dev-measured.md b/docs/reference-snapshots/transitions-dev-measured.mdnew file mode 100644index 000000000..f2cbffd1d--- /dev/null+++ b/docs/reference-snapshots/transitions-dev-measured.md@@ -0,0 +1,45 @@+# transitions.dev 动效配方实测记录++- 取证日期:2026-09-16+- URL:<https://transitions.dev/>,逐条配方在 `https://transitions.dev/transitions/<slug>`+- 取证方式:打开每条配方页的 CSS 标签页,读它给出的 `:root` 变量与 `@keyframes` 数值。+ 页面上每条都有 CSS 与 React 两个标签页,React 那份只是把同一段 CSS 包一层组件,+ 数值一致,所以只记 CSS 那份。+- **不在 `docs/reference-sources.json` 里登记**:那张表的契约是「每个来源都有可哈希的+ 上游快照」。这里取的是一页上多条配方的参数,页面由站点自己的组件渲染、随时可改,+ 给不出可锁定的单文件哈希。要复核就按上面的方式重开配方页读一遍 CSS 标签页。+- 许可:上游仓库没有 LICENSE 文件,页面只写「copy and paste them」,没有给出明确授权+ 条款。因此 Peach 只借形态与参数,类名与变量名一律自拟:不使用它的 `t-*` 类名,+ 也不使用它的 `:root` 变量名。落地代码在 `web/css/25-motion.css` 与 `web/board.css`。+- **未取得**:上游各条配方所依据的设计原始稿、参数取值理由和许可条款均未取得;+ 上游没有公布 spring 参数,它的「弹」一律由带超调控制点的 `cubic-bezier` 近似。++## 逐条对照++时长与缓动一律并进 Peach 已有的动效 token:`--board-motion`(.3s cubic-bezier(.4,0,.2,1))、+`--spring-press`(208ms 采样弹簧,峰值 1.088)、本次新增的 `--motion-swap`(.25s)、+`--motion-reveal`(.4s)、`--motion-stagger`(70ms),全部由 `board.css` 那一条+`prefers-reduced-motion` 规则统一归零。++| 配方 | slug | 上游取值 | Peach 落成值 | 落点 |+| --- | --- | --- | --- | --- |+| 字形换字形 | `icon-swap` | 250ms;`ease-in-out`;blur 2px;scale .25 | `--motion-swap`(.25s cubic-bezier(.4,0,.2,1));blur 2px;scale .25 | `.iconswap`;`iconSwapHtml`/`setIconSwap` |+| 一行字换一行字 | `text-states` | 150ms;`ease-in-out`;blur 2px;位移 4px | `--motion-swap`;blur 2px;位移 4px | `.textswap`;`swapText` |+| 读数按位跳出 | `number-pop-in` | 500ms;`cubic-bezier(0.34,1.45,0.64,1)`;blur 2px;位移 8px;按位延迟 70ms | `--motion-swap` + 同一条超调缓动;blur 2px;位移 8px;`--motion-stagger` 70ms | `.digits`;`popCount` |+| 占位换真内容 | `skeleton-loader` | 400ms;`ease-in-out`;blur 2px | `--motion-reveal`(.4s cubic-bezier(.4,0,.2,1));blur 2px | `.skelreveal`/`.skelfade`;`revealSkeleton` |+| 开关双弹 | `toggle-double-bounce` | 350ms;`cubic-bezier(0.34,1.35,0.64,1)`;行程 14.66px;超出端点 1px | `--spring-press`(208ms,峰值 1.088,行程 18px,超出约 1.6px) | `.ptoggle::after`/`::before` |+| 成功打勾 | `success-check` | 四段各 500ms;rotate 80deg;blur 10px;上荡 40px;`stroke-dasharray` 20;画笔延迟 80ms | `--board-motion` 走转正与清晰、`--spring-press` 走上荡 14px;rotate 80deg;blur 10px;`stroke-dasharray` 24;画笔延迟 `--motion-stagger` | `.checkdraw`;toast 图标 |+| 失败抖动 | `error-shake` | 280ms;`cubic-bezier(0.22,1,0.36,1)`;关键帧 0/28.57%/57.14%/78.57%/100%,位移 0/6px/-6px/4px/0 | `--board-motion`;同样的五个关键帧与位移 | `@keyframes field-shake`;`[aria-invalid="true"]` |++## 与上游取值不同的几处判断++- 开关双弹不写关键帧。上游用一条超调缓动模拟弹簧,Peach 已经有采样自真实弹簧的+ `--spring-press`,峰值 1.088 折到 18px 行程上就是约 1.6px 的超出,手感与上游那条+ 1px 超出同档,所以直接让 thumb 的 `transform` 走这条弹簧。+- 成功打勾的上荡距离取 14px 而不是 40px:这枚勾长在 toast 的图标位上,只有 16px 见方,+ 40px 会把它荡出 toast 的边界。`stroke-dasharray` 取 24 是 Peach 这枚 Lucide 勾的+ 实际折线长度,不是上游那枚字形的 20。+- 读数与文字的换态只在值真的变了时才走,首次落笔不动。上游示例每次渲染都播一遍,+ 在 Peach 这是首页每次筛选都要重画的读数,首屏会变成一片抖动。+- 骨架换内容时旧的那一层抬成绝对定位再淡出,容器高度全程由新内容决定;上游示例里+ 两块内容尺寸相同,不需要处理这一步。diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 89506dd9a..eb86601b7 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -83,7 +83,7 @@ class StylesheetPartitionTests(unittest.TestCase):"13-stage.css", "14-player.css", "15-detail.css", "16-settings.css","17-overlay.css", "18-drawer.css", "19-immersive.css", "20-offdisk.css","21-online.css", "22-followmanage.css", "23-configuration.css",- "24-miniplayer.css",+ "24-miniplayer.css", "25-motion.css",)@classmethod@@ -1822,8 +1822,8 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains("if(!refine)showIndexLoading('正在读取'+(INDEX_TITLES[kind]||'标签'),kind,q)")self.assertCode("""if($('#indexFilters')){$('#indexFilters').innerHTML=filters;- if(people)$('#indexCount').textContent=countText;- $('#indexBody').innerHTML=body;+ if(people)popCount($('#indexCount'),countText);+ revealSkeleton($('#indexBody'),()=>{$('#indexBody').innerHTML=body});$('#indexMore').hidden=!d.has_more;}else""")# 分类筛选自己有容器,才能不动表头单独换掉。@@ -3007,7 +3007,9 @@ class WebUiSourceTests(unittest.TestCase):"count.innerHTML=state&&state.state==='trash'?''\n"" :`<span class=\"mono\"><span class=\"countskeleton\"></span></span>`+countSortsHtml();\n"" wireCountRow();")- self.assertPageContains(" +(trash?'':countSortsHtml());\n wireCountRow();")+ self.assertPageContains(" +(trash?'':countSortsHtml());")+ # 读数那一格换值时按位错峰长出来,接事件仍在同一次重画的末尾。+ self.assertPageContains(" popCount(readout,lastCountReadout);\n }\n wireCountRow();")self.assertPageLacks("count.textContent=''","加载态不能清空整行,筛选条要留在原位")# 数据到位后摘掉忙碌标记,屏幕阅读器不再把这一行当成还在读取。@@ -9220,7 +9222,7 @@ class WebUiSourceTests(unittest.TestCase):self.assertIn(".board-filter-frame .tagcategories .pill{border:1px solid var(--glass-low);background:transparent}", board)# 标签页的读数只住在浮层里,页头不再重复一遍。self.assertPageContains("${people?`<span class=\"mono\" id=\"indexCount\">${countText}</span>`:''}")- self.assertCode(" if(people)$('#indexCount').textContent=countText;")+ self.assertCode(" if(people)popCount($('#indexCount'),countText);")def test_the_alphabet_is_one_card_per_letter_with_a_jump_row(self):"""每个首字一张卡:字头是卡的标题,右边挂计数徽标;一行一枚标签、36px 高、8px@@ -9324,8 +9326,9 @@ class WebUiSourceTests(unittest.TestCase):# 检查死链找的是断掉的那条链。'id="linkCheck">${icon(\'unlink\')}<span>检查死链</span>',# 资源同步比的是盘上和账本的差异;跑过一轮之后那一枚才是「再跑一遍」。- 'id="resourceScan">${icon(\'git-compare\')}<span>检查文件</span>',- "scan.innerHTML=`${icon(done?'rotate-cw':'git-compare')}",+ 'id="resourceScan">${iconSwapHtml(\'git-compare\',\'rotate-cw\')}'+ '<span data-scan-label>检查文件</span>',+ "setIconSwap(scan,done?'b':'a');",# 同步删除把这个目录在盘上和账本里对齐。'aria-label="同步删除">${icon(\'folder-sync\')}',# 沉浸模式是一叠竖着翻的卡,保存为播放列表存的是一份列表。@@ -9681,8 +9684,10 @@ class WebUiSourceTests(unittest.TestCase):self.assertIn("cursor:grab;transition:scale calc(var(--spring-press-ms) * 1ms) ""var(--spring-press),box-shadow .15s}", board)self.assertIn(":active::-webkit-slider-thumb{scale:1.18;transition:scale .06s ease-out}", board)- # 关掉动效时两档弹簧一起归零,剩下的是瞬时到位。- self.assertIn("--board-motion:0s;--board-dialog-motion:0s;--spring-pane-ms:0;--spring-press-ms:0}", board)+ # 关掉动效时两档弹簧一起归零,剩下的是瞬时到位;原地换态那三档也在同一条里。+ self.assertIn("--board-motion:0s;--board-dialog-motion:0s;--spring-pane-ms:0;"+ "--spring-press-ms:0;--motion-swap:0s;--motion-reveal:0s;"+ "--motion-stagger:0ms}", board)def test_the_theme_sweep_masks_with_a_gradient_instead_of_a_filtered_svg(self):"""明暗切换那圈扩散用一段 CSS 渐变当遮罩,柔边靠色标位置给。@@ -10016,7 +10021,7 @@ class WebUiSourceTests(unittest.TestCase):self.assertIn(".toast{position:relative;align-items:center;", board)self.assertIn(".board-notification-icon svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2}", board)self.assertIn(".toast p{margin:0}", board)- self.assertPageContains("""<span class="board-notification-icon" aria-hidden="true">${icon(alert?'circle-alert':'check')}</span>""")+ self.assertPageContains("""<span class="board-notification-icon${alert?'':' checkdraw'}" aria-hidden="true">${icon(alert?'circle-alert':'check')}</span>""")def test_the_shorts_band_is_told_apart_by_its_fill_not_a_line(self):"""竖屏带靠底色和网格区分,不描一圈线。@@ -11046,7 +11051,8 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains('class="settingrow settingrelated"')self.assertPageContains('.settingrow.settingrelated{border-top:0}')self.assertPageContains("['rating','评分']")- self.assertPageContains("icon(ascending?'arrow-up':'arrow-down','gselectmark')")+ self.assertPageContains("iconSwapHtml('arrow-up','arrow-down','a',")+ self.assertPageContains("setIconSwap(mark,ascending?'a':'b')")self.assertPageContains('class="settingsortcontrols"')self.assertPageContains("field.disabled=appSettings.defaultSort==='seed'")self.assertPageContains("['hoverDelaySetting','悬停放大',[['0','关闭']")@@ -12152,5 +12158,125 @@ class BoardStyleIsolationTests(unittest.TestCase):for selector in centering))+class MotionRecipeTests(unittest.TestCase):+ """原地换态的那一组动效:时长与缓动只读 token,形态只动合成属性。++ 判据全部落在源码上,因为这几条要守的就是「没有写死的毫秒数」和「没有碰布局属性」+ 这两件事——浏览器里看得到的是动了没有,看不到的是它凭什么这样动。++ 不继承 `WebUiSourceTests`:继承会把它那几百条用例连同这一组再跑一遍,失败也会+ 挂到这个类名下。自己读要看的那几份源码即可。+ """++ #: 这一组新增的动效类,每一条都必须只从 token 取时长。+ MOTION_TOKENS = ("--motion-swap", "--motion-reveal", "--motion-stagger")++ @classmethod+ def setUpClass(cls):+ cls.root = Path(__file__).resolve().parents[1]+ web = cls.root / "web"+ cls.css = stylesheet_source()+ cls.page = chr(10).join(path.read_text(encoding="utf-8") for path in (+ [web / "index.html", *sorted((web / "css").glob("*.css")), web / "app.js",+ *sorted((web / "js").glob("*.js"))]))++ def assertPageContains(self, needle: str, message: str = ""):+ if needle not in self.page:+ self.fail(f"Web 表面缺少:{needle!r}" + (f"({message})" if message else ""))++ def test_reduced_motion_zeroes_every_motion_token(self):+ """新加的三档时长跟原有的一样,由那一条全局规则一次关掉,不逐处补。++ `--motion-stagger` 尤其不能漏:时长归零而错峰延迟还在的话,`both` 会把后面+ 几位数字按住不显示,读数看上去缺了几位。+ """+ # 三档 token 和原有的那几档住在同一处(board.css 的 `:root`),关掉它们的也是+ # 同一条规则;`stylesheet_source()` 只拼 `web/css/`,board.css 要单独读。+ board = (Path(__file__).resolve().parents[1]+ / "web/board.css").read_text(encoding="utf-8")+ # board.css 里不止一条 reduced motion 规则,token 那一条认 `--board-motion:0s`。+ start = board.index("--board-motion:0s")+ reduced = board[start:board.index("}", start)]+ for token in self.MOTION_TOKENS:+ with self.subTest(token=token):+ self.assertIn(f"{token}:0", reduced, f"{token} 要在 reduced motion 下归零")++ def test_motion_recipes_only_animate_compositor_properties(self):+ """这几条都长在读数、按钮和整页占位上,一次重排就是一整棵子树。"""+ motion = (Path(__file__).resolve().parents[1]+ / "web/css/25-motion.css").read_text(encoding="utf-8")+ allowed = {"opacity", "filter", "transform", "translate", "stroke-dashoffset"}+ frames = re.findall(r"@keyframes\s+[\w-]+\{(.*?)\}\s*\}", motion, re.S)+ self.assertTrue(frames, "这份分区里应当有关键帧")+ for body in frames:+ for prop in re.findall(r"([a-z-]+)\s*:", body):+ with self.subTest(prop=prop):+ self.assertIn(prop, allowed, f"关键帧里不许动 {prop}")+ for declaration in re.findall(r"transition:([^;}]+)", motion):+ for prop in re.findall(r"\b([a-z-]+)\s+var\(", declaration):+ with self.subTest(prop=prop):+ self.assertIn(prop, allowed, f"过渡里不许动 {prop}")++ def test_icon_swap_stacks_both_glyphs_in_one_cell(self):+ """换字形不重写 innerHTML:重写会把旧字形连同它的动画一起丢掉,读出来是硬切。"""+ self.assertPageContains('.iconswap{display:inline-grid')+ self.assertPageContains('.iconswap>[data-icon]{grid-area:1/1')+ # 退场那一枚还占着同一个格子,不收指针的话按钮上有两个可点区域。+ self.assertPageContains("transform:scale(.25);\n pointer-events:none")+ self.assertPageContains("export function iconSwapHtml(a,b,state='a'")+ self.assertPageContains("export function setIconSwap(root,state)")++ def test_number_and_text_swaps_only_fire_when_the_value_really_changed(self):+ """首屏那一次不放动画,值没变也不放:同一次重绘里把同样的字再写一遍是常态。"""+ self.assertPageContains("if(previous===undefined||previous===next)return;")+ self.assertPageContains("if(previous===undefined||previous===next){write();return}")+ # 整行重画时读数那一格跟着重建,靠上一次的值判断自己是刚出现还是换了数。+ self.assertPageContains("if(lastCountReadout)readout.dataset.popCount=lastCountReadout;")+ self.assertPageContains("animation-delay:calc(var(--motion-stagger) * var(--digit-at,0))")++ def test_skeleton_hands_over_to_content_with_a_cross_fade(self):+ """骨架淡出糊掉、内容同时清晰起来;内容换内容不走这条。"""+ self.assertPageContains("const hasSkeleton=container.querySelector("+ "'.skeleton,[data-skeleton],.skeletoncard,.countskeleton');")+ self.assertPageContains("if(!hasSkeleton||!container.firstChild){write();return}")+ # 终点帧是内容本来的样子;留着它只多留下一个 filter,那会另起一个 backdrop root。+ self.assertPageContains(+ ".skelreveal>:not(.skelfade){animation:skel-reveal-in var(--motion-reveal) backwards}")++ def test_toggle_thumb_rides_the_shared_press_spring(self):+ """手柄那一下的两跳来自 `--spring-press` 本身,不另写一组带 55%/80% 停的关键帧。++ 写成 transition 而不是 animation:animation 一挂上去,进设置页时已经是开态的+ 那十几枚开关会当场各弹一次。+ """+ board = (Path(__file__).resolve().parents[1]+ / "web/board.css").read_text(encoding="utf-8")+ for pseudo in (".ptoggle::after{", ".ptoggle::before{"):+ start = board.index(pseudo)+ rule = board[start:board.index("}", start)]+ with self.subTest(rule=pseudo):+ self.assertIn("transition:transform calc(var(--spring-press-ms)*1ms) "+ "var(--spring-press)", rule)+ self.assertNotIn("transition:transform .2s", rule)++ def test_success_check_draws_itself_and_failure_does_not(self):+ """成功那一枚勾自己画出来;失败那一枚不画——错误要的是立刻看清。"""+ self.assertPageContains(+ 'class="board-notification-icon${alert?\'\':\' checkdraw\'}"')+ self.assertPageContains("@keyframes check-draw{from{stroke-dashoffset:24}"+ "to{stroke-dashoffset:0}}")+ # 荡那一下走按压弹簧,其余三条走站内那条通用缓动,都不是手写的毫秒数。+ self.assertPageContains("check-bob calc(var(--spring-press-ms)*1ms) var(--spring-press)")++ def test_error_shake_rides_on_the_existing_red_border(self):+ """抖动叠在已经有的红边上:不新增红字,也不改边框色。"""+ self.assertPageContains(':is(input,textarea,select)[aria-invalid="true"],\n'+ '.board-number-control:has([aria-invalid="true"])'+ '{animation:field-shake var(--board-motion)}')+ shake = self.css.split("@keyframes field-shake{", 1)[1].split("}}", 1)[0]+ self.assertNotIn("color", shake, "抖动只走 transform,颜色归原有的错误样式")+ self.assertNotIn("border", shake, "抖动只走 transform,边框归原有的错误样式")++if __name__ == "__main__":unittest.main()diff --git a/web/app.js b/web/app.jsindex 7d951064e..67de217c9 100644--- a/web/app.js+++ b/web/app.js@@ -18,7 +18,8 @@ import { catalogSuggestions, catalogEmptyHtml, emptyCatalogLayout, syncSidebarSuimport { javImageKind, normalizeJavImage, normalizeJavLayout, normalizeJavPreferences, panelFrame, syncJavImages, nativeImageFit, matchesFaceSource, entitySkeletonHtml } from './dist/peach-ui.js';import {attachOverlayScrollbar, breadcrumbHtml, checkboxHtml, collectionSummaryHtml, closeAnchoredMenu, confirmModal, dialSliderHtml, dismissMenu, emptyStateHtml, fieldsetTitle, selectOptionIconHtml,- fillSkeletonTier, fitSkeleton, formModal, iconSwitchHtml, indexSkeletonHtml, loadingDotsHtml,+ fillSkeletonTier, fitSkeleton, formModal, iconSwapHtml, iconSwitchHtml, indexSkeletonHtml, loadingDotsHtml,+ popCount, revealSkeleton, setIconSwap, swapText,mediaViewButtonsHtml, boardTabsHtml, mountFilterFrame, filterChipHtml, moveGlidePane, glideEase, sortControlsHtml, collectionHeaderHtml, wireHorizontalScroller, noteHtml, presentMenu, gaugeHtml, scrollerHtml, searchInputHtml, selectFieldHtml,setActionBusy, skeletonHtml, spinnerHtml, growCollapse, wireAnchoredMenu, wireBusyActions, wireCollapse, wireDialSlider, wireDragReorder,wireIconSwitch, wireOverlayScrollbars, wireScrollers, wireSelectField, wireContextCard, configurationSkeletonHtml, wireLoadMore,@@ -257,7 +258,9 @@ const lastGridSection=()=>{const grid=$('#grid'),last=grid.lastElementChild;if(last&&last.classList.contains('grid'))return last;const section=document.createElement('div');section.className='grid';grid.append(section);return section};-const setGridCards=html=>{$('#grid').innerHTML=`<div class="grid">${html}</div>`};+/* 占位换成真内容时走交叉淡入:骨架淡出糊掉、内容同时清晰起来。骨架换骨架、内容换+ 内容(翻页、换筛选)不走这条——`revealSkeleton` 自己看出去的那一屏里有没有占位。 */+const setGridCards=html=>revealSkeleton($('#grid'),()=>{$('#grid').innerHTML=`<div class="grid">${html}</div>`});const appendGridCards=html=>lastGridSection().insertAdjacentHTML('beforeend',html);const gridCards=()=>document.querySelectorAll('#grid > .grid > .card[data-id]');function renderCatalogLoading(label='正在读取作品'){@@ -312,6 +315,8 @@ const MANAGEMENT_PLACEHOLDERS={const managementPlaceholder=path=>boardPageSkeleton(path,{followLayout:followListLayout()})||(MANAGEMENT_PLACEHOLDERS[path]||(()=>pageSkeletonHtml('正在读取页面')))();+/* 详情浮窗的正文:骨架换成真内容时交叉淡入,内容换内容(在队列里跳下一条)直接换。 */+const paintStage=html=>revealSkeleton($('#stage'),()=>{$('#stage').innerHTML=html});function showDetailLoading(){const stage=$('#stage');if(!stage.querySelector('[data-skeleton="detail"]'))stage.innerHTML=detailSkeletonHtml();@@ -770,7 +775,14 @@ function syncSortDirectionSetting(){if(field){field.disabled=appSettings.defaultSort==='seed';const ascending=appSettings.defaultSortDirection==='asc';- field.querySelector('[data-select-label]').innerHTML=`${icon(ascending?'arrow-up':'arrow-down','gselectmark')}${ascending?'升序':'降序'}`;+ /* 两枚箭头叠在同一格里,换的只是方向这一件事。`innerHTML` 重写会把旧字形连同它的+ 动画一起丢掉,读出来是一次硬切,所以只在这一格还没建起来时写一次。 */+ const mark=field.querySelector('[data-select-label]');+ if(!mark.querySelector('[data-icon-swap]'))+ mark.innerHTML=iconSwapHtml('arrow-up','arrow-down','a',+ {className:'gselectmark',iconClass:'gselectmark'})+'<span data-sort-direction-label></span>';+ setIconSwap(mark,ascending?'a':'b');+ mark.querySelector('[data-sort-direction-label]').textContent=ascending?'升序':'降序';}const help=$('#sortDirectionHelp');if(help)help.textContent=appSettings.defaultSort==='seed'?'随机排序不使用方向。':'打开首页时使用的排序与方向。';@@ -991,7 +1003,10 @@ const toast=(message,{timeout=6000,warn=false,action=null,sound=null}={})=>{item.classList.toggle('warn',!!alert);item.setAttribute('role',alert?'alert':'status');playUiSound(sound||(alert?'error':'success'));- item.innerHTML=`<span class="board-notification-icon" aria-hidden="true">${icon(alert?'circle-alert':'check')}</span><p>${body}</p>${+ /* 成功那一枚勾自己画出来:从下方荡上来、转正、从模糊里清晰,笔画随后走完。+ 保存配置、复核判定这些写操作的回执全走这一条,确认反馈只此一处。+ 失败那一枚不画——错误要的是立刻看清,不是等一段动画。 */+ item.innerHTML=`<span class="board-notification-icon${alert?'':' checkdraw'}" aria-hidden="true">${icon(alert?'circle-alert':'check')}</span><p>${body}</p>${action&&!alert&&body===initial?`<button class="tact">${esc(action.label)}</button>`:''}<button class="tclose" title="关闭" aria-label="关闭提示">${icon('x')}</button>`;item.querySelector('.tclose').onclick=close;@@ -1395,7 +1410,11 @@ function syncMiniplayerPlayState(){if(!player||player.isDisposed()||!button)return;const paused=player.paused();button.setAttribute('aria-label',paused?'播放':'暂停');- button.querySelector('use')?.setAttribute('href',paused?'#i-player-play':'#i-player-pause');+ /* 主播放器那一枚走的是 path 形变(`morphIcon`),迷你条上这一枚只有 20px,形变看不+ 出来,走两枚字形叠着换。换的只是容器状态,不改 `use` 的 href——改 href 是硬切。 */+ if(!button.querySelector('[data-icon-swap]'))+ button.innerHTML=iconSwapHtml('player-pause','player-play',paused?'b':'a');+ setIconSwap(button,paused?'b':'a');}function syncMiniplayerTime(){const player=miniplayerState.player,out=$('#miniplayerTime');@@ -4172,6 +4191,8 @@ async function buildBars(){if(expanded)group.querySelector('.board-section-toggle').click();bind();hold();requestAnimationFrame(hold);});}+/* 上一次画出来的读数。整行重画时读数那一格跟着重建,靠它判断这次是换了值还是刚出现。 */+let lastCountReadout='';/* 排序和换批都属于当前列表,放在计数行,不占用全局导航。 */function renderCount(){const n=gridCards().length; // 竖屏带里的 .scard 不计入「显示 N」@@ -4183,9 +4204,18 @@ function renderCount(){$('#count').classList.toggle('count-actions-only',trash);$('#count').removeAttribute('aria-busy');$('#count').removeAttribute('aria-label');$('#count').innerHTML=- (trash?'':`<span class="mono">${total.toLocaleString()} 个符合 · 显示 ${n}</span>`)+ (trash?'':`<span class="mono" data-count-readout></span>`)// 回收站是待清理队列,不是浏览列表:换一批和排序在这里没有意义。+(trash?'':countSortsHtml());+ /* 这一行每次筛选都整块重画,读数那一格因此是新建出来的,自己不知道上一次是多少。+ 把上一次的值写回去它才分得清「刚建出来」和「换了个数」——只有后者按位错峰长出来,+ 首屏那一次不放动画。 */+ const readout=$('#count [data-count-readout]');+ if(readout&&!trash){+ if(lastCountReadout)readout.dataset.popCount=lastCountReadout;+ lastCountReadout=`${total.toLocaleString()} 个符合 · 显示 ${n}`;+ popCount(readout,lastCountReadout);+ }wireCountRow();const emptyTrash=$('#emptyTrash');if(emptyTrash)emptyTrash.onclick=async(e)=>{@@ -4449,7 +4479,7 @@ function resourceSyncMarkup(){<div class="resourcesyncbody geist-fieldset-content">${fieldsetTitle('resourceBoxTitle','文件与记录核对')}<p>按馆藏记录逐条查找本地磁盘与网盘上的文件,列出文件已不存在的记录,以及不再被引用的缓存。</p></div><div class="resourcesyncfooter geist-fieldset-footer" data-geist-fieldset-footer>- <button class="resourceaction primary" type="button" id="resourceScan">${icon('git-compare')}<span>检查文件</span></button></div></div>+ <button class="resourceaction primary" type="button" id="resourceScan">${iconSwapHtml('git-compare','rotate-cw')}<span data-scan-label>检查文件</span></button></div></div><div id="resourceSyncResult" aria-live="polite"></div></section>`;}async function wireResourceSync(){@@ -4458,7 +4488,10 @@ async function wireResourceSync(){const active=()=>location.pathname==='/data-cleanup'&&!$('#stats').hidden&&document.body.contains(result);const setBusy=(busy,done=false)=>{setActionBusy(scan,busy);- scan.innerHTML=`${icon(done?'rotate-cw':'git-compare')}<span>${busy?'扫描中':done?'重新扫描':'检查文件'}</span>`;+ /* 这枚键上的字形要从「比对」换成「再来一次」,只改状态不重写 innerHTML:+ `git-compare` 自己带一套逐笔描画,重写一次就把它连同正在走的笔画一起丢掉。 */+ setIconSwap(scan,done?'b':'a');+ swapText(scan.querySelector('[data-scan-label]'),busy?'扫描中':done?'重新扫描':'检查文件');};const render=payload=>{const cache=payload.cache||{files:0,bytes:0};@@ -5397,7 +5430,7 @@ async function openFollowDetail(id,push=true,mediaIndex=null,preserveReturn=fals<div class="followhiddenthumbs">${item.hidden_media.map(media=>`<button data-follow-media-restore="${media.index}" title="恢复显示 ${esc(media.name||'')}" aria-label="恢复显示 ${esc(media.name||'')}">${media.thumb_url?`<img src="${esc(media.thumb_url)}" alt="" loading="lazy" referrerpolicy="no-referrer" data-drop="self">`:icon('image-off')}<i>${icon('rotate-ccw')}</i></button>`).join('')}</div></div>`:'';placeItemDetail(detailOriginAnchor,detailOriginAbove);$('#stage').hidden=false;document.body.classList.add('detail-open');- $('#stage').innerHTML=`<div class="stagescroll"><div class="sgrid followdetailgrid${collection||embeddedQueue?' mixgrid':''}">+ paintStage(`<div class="stagescroll"><div class="sgrid followdetailgrid${collection||embeddedQueue?' mixgrid':''}"><div class="vwrap followdetailmedia${selectedKind==='image'?' image':''}${frameRatio?' framed':''}"${frameRatio?` style="--follow-frame-ratio:${frameRatio.toFixed(4)}"`:''}>${selectedKind==='video'?'<canvas class="ambientcanvas" width="32" height="18"></canvas>':''}<button class="closestage" id="closeStage" title="关闭" aria-label="关闭">${icon('x')}</button>${selectedKind==='video'?playerStatsOverlayHtml():''}${media}${imageControls}</div>${embeddedQueue?followEmbeddedQueueHtml(item,selectedMedia.index):(collection?followQueueHtml(collection,item.id):'')}<div class="side followdetailside"><div class="sidecontent">@@ -5421,7 +5454,7 @@ async function openFollowDetail(id,push=true,mediaIndex=null,preserveReturn=fals${hiddenStrip}<span class="fstate" aria-live="polite"></span>${tags?`<div class="stags followdetailtags">${tags}</div>`:''}- </div></div></div></div>`;+ </div></div></div></div>`);$('#stage').classList.toggle('ambient-on',selectedKind==='video'&&appSettings.ambientMode);$('#stage').classList.toggle('theater-mode',selectedKind==='video'&&appSettings.theaterMode);/* 关掉详情只是回到列表,不该重新取一遍。重取要等一个网络往返(慢),而且只会@@ -6645,8 +6678,8 @@ async function openIndex(kind,q,push=true,refine=false){住在浮层里,跟着浮层一起重画。 */if($('#indexFilters')){$('#indexFilters').innerHTML=filters;- if(people)$('#indexCount').textContent=countText;- $('#indexBody').innerHTML=body;+ if(people)popCount($('#indexCount'),countText);+ revealSkeleton($('#indexBody'),()=>{$('#indexBody').innerHTML=body});$('#indexMore').hidden=!d.has_more;}else $('#index').innerHTML=indexHeaderHtml(kind,q,countText)+`<div id="indexFilters">${filters}</div><div id="indexBody">${body}</div><button class="indexmore" id="indexMore" type="button" ${d.has_more?'':'hidden'}>载入更多</button>`;// 外壳记号跟着内容走:下一次换档时靠它判断页头和浮层还在不在,值不对就整块重画。@@ -7892,8 +7925,15 @@ function paintManageLede(text='',actionsHtml=''){const el=$('#manageLede');if(!el)return;el.hidden=!text&&!actionsHtml;el.classList.toggle('pagelede-actions',!!actionsHtml);- el.innerHTML='';- if(text)el.appendChild(Object.assign(document.createElement('span'),{textContent:text}));+ /* 说明行的文字那一格留在原地:它每次重画说的都是同一件事的新读数,整格重建就没有+ 起点可走,换态只好硬切。右端的动作仍整块重写——它换的是有没有这个按钮。 */+ const keep=el.querySelector('[data-lede-text]');+ el.querySelectorAll(':scope>:not([data-lede-text])').forEach(node=>node.remove());+ if(text){+ const slot=keep||el.appendChild(Object.assign(document.createElement('span'),{}));+ slot.setAttribute('data-lede-text','');+ swapText(slot,text);+ }else if(keep)keep.remove();if(actionsHtml)el.insertAdjacentHTML('beforeend',actionsHtml);}function paintListTitle(){@@ -8652,7 +8692,7 @@ async function openItem(id,push=true,queueContext=null,anchor=null){/* 浮窗里的内容统一装在 `.stagescroll` 里:窄屏下滚的是它,全站那条覆盖式滚动条才有地方挂(轨道得是滚动容器的兄弟,而 `<dialog>` 在顶层,轨道挂到它父级上会落进遮罩底下)。「接着看」是 `.sgrid` 的兄弟,也得一起装进来,否则它会被裁在浮窗外面。 */- $('#stage').innerHTML=`<div class="stagescroll"><div class="sgrid ${queueContext?'mixgrid':''}">+ paintStage(`<div class="stagescroll"><div class="sgrid ${queueContext?'mixgrid':''}"><div class="vwrap"><canvas class="ambientcanvas" id="ambientCanvas" width="32" height="18"></canvas><button class="closestage" id="closeStage" title="关闭" aria-label="关闭">${icon('x')}</button>${playerStatsOverlayHtml()}${offline?`<div class="gate offline" id="offlineGate" role="status">@@ -8709,7 +8749,7 @@ async function openItem(id,push=true,queueContext=null,anchor=null){<button class="obtn" data-kind="o">${icon('sperm')}<span>记一次高潮</span><b class="mono" id="oCount">${it.o_count||0}</b></button></div></div></div>${queueContext||!(appSettings.relatedLimit>0)?'':`<div class="next"><h3>接着看</h3><div class="nrow" id="nrow">${- pageSkeletonHtml('正在读取推荐',{cards:true,className:'related-skeleton'})}</div></div>`}</div>`;+ pageSkeletonHtml('正在读取推荐',{cards:true,className:'related-skeleton'})}</div></div>`}</div>`);$('#stage').classList.toggle('ambient-on',appSettings.ambientMode);$('#stage').classList.toggle('theater-mode',appSettings.theaterMode);diff --git a/web/board.css b/web/board.cssindex 792677c40..eec3c2c00 100644--- a/web/board.css+++ b/web/board.css@@ -747,9 +747,14 @@ body>.board-filter-frame{margin-inline:16px}.settingscard .board-number-error:not(:empty){position:absolute;z-index:10;right:0;top:calc(100% + 6px);width:max-content;max-width:240px;padding:6px 10px;background:var(--ground);border:1px solid color-mix(in srgb,var(--error,#e5484d) 35%,var(--line));border-radius:8px;box-shadow:0 4px 14px #0002;color:var(--error,#e5484d);font-size:12px;line-height:18px;margin:0}.settingscard .board-number-error[hidden]{display:none}.settingscard .board-optional-number{position:relative}+/* 手柄那一下走 `--spring-press`:那条曲线本来就是冲过落点再荡回来一次,18px 的行程上+ 读出来正是「过头一点点、退回来、停住」两跳,不必另写一组带 55%/80% 停的关键帧。+ 轨道换色仍走自己的钟,它是一次颜色交叉淡入,跟着手柄一起弹会把整枚开关读成在呼吸。+ 写成 transition 而不是 animation,是因为 animation 一挂上去,页面载入时已经是开态的+ 那几枚会当场各弹一次——这一屏设置里有十几个开关,进页面就是一片抖。 */.ptoggle{width:42px;height:24px;background:var(--color-background-tertiary-default);border:0;border-radius:999px;transition:background .2s}-.ptoggle::after{width:18px;height:18px;top:3px;left:3px;background:linear-gradient(#fff 44%,#f3f3f3);box-shadow:0 3px 3px #00000008;transition:transform .2s;transform:none}-.ptoggle::before{content:'';position:absolute;z-index:1;left:8.25px;top:8.25px;width:7.5px;height:7.5px;border-radius:50%;background:var(--surface);box-shadow:inset 0 0 0 .375px var(--line);transition:transform .2s}+.ptoggle::after{width:18px;height:18px;top:3px;left:3px;background:linear-gradient(#fff 44%,#f3f3f3);box-shadow:0 3px 3px #00000008;transition:transform calc(var(--spring-press-ms)*1ms) var(--spring-press);transform:none}+.ptoggle::before{content:'';position:absolute;z-index:1;left:8.25px;top:8.25px;width:7.5px;height:7.5px;border-radius:50%;background:var(--surface);box-shadow:inset 0 0 0 .375px var(--line);transition:transform calc(var(--spring-press-ms)*1ms) var(--spring-press)}.ptoggle:checked{background:var(--board-blue);box-shadow:inset 0 1.5px 0 #ffffff40,inset 0 0 0 .75px var(--color-accent-400)}.ptoggle:checked::after{left:3px;transform:translateX(18px)}.ptoggle:checked::before{transform:translateX(18px);background:linear-gradient(var(--color-accent-700),var(--color-accent-500))}@@ -812,6 +817,12 @@ body>.board-filter-frame{margin-inline:16px}/* BoardUI surface tokens; Peach retains its layouts and specialized media UI. */:root{--board-motion:.3s cubic-bezier(.4,0,.2,1);--board-dialog-motion:.3s cubic-bezier(.32,.72,0,1);--fs-lg:16px;--fs-xl:20px;--fs-2xl:24px;--control-h:36px}+/* 原地换一样东西的那三档:一枚字形换成另一枚、一行字换成另一行、占位换成真内容。+ 三者都是同一件事的不同尺度,所以共用 `--board-motion` 那条缓动,只有时长按跨度分档:+ 字形和文字原地不动只换外观走 250ms,骨架换内容要跨整块区域走 400ms。+ `--motion-stagger` 是多位数字按位错峰的步长,它跟时长一样要在 reduced motion 下归零——+ 动画时长归零而延迟还在的话,`both` 会把前几位按住不显示,读数看上去缺了几位。 */+:root{--motion-swap:.25s cubic-bezier(.4,0,.2,1);--motion-reveal:.4s cubic-bezier(.4,0,.2,1);--motion-stagger:70ms}body{font-size:14px;line-height:20px}button,input,select,textarea{font-family:inherit}.index .ihead{padding:4px;gap:12px;min-width:0;flex-wrap:wrap}@@ -892,7 +903,7 @@ html.board-high-contrast .settingscard.settingscard>.board-local-nav{background:.settingscard .settingsscroll .gselect,.settingscard .settingsscroll .gselectfield{height:40px;font-size:14px}.settingscard .settingsscroll .board-number-control>span{font-size:14px}}-@media(prefers-reduced-motion:reduce){:root{--board-motion:0s;--board-dialog-motion:0s;--spring-pane-ms:0;--spring-press-ms:0}.settingscard .settingshead::after{transition:none}}+@media(prefers-reduced-motion:reduce){:root{--board-motion:0s;--board-dialog-motion:0s;--spring-pane-ms:0;--spring-press-ms:0;--motion-swap:0s;--motion-reveal:0s;--motion-stagger:0ms}.settingscard .settingshead::after{transition:none}}/* Stat Cards 的内层读数与底栏;统计卡仍是可键盘切换的视图入口。 *//* 侧栏分组使用标题行与带计数的叶项。 */.drawer.drawer{display:flex;flex-direction:column;overflow:hidden}diff --git a/web/css/25-motion.css b/web/css/25-motion.cssnew file mode 100644index 000000000..0c71c549a--- /dev/null+++ b/web/css/25-motion.css@@ -0,0 +1,88 @@+/* 原地换态的一组动效:字形换字形、读数换读数、占位换内容、成功与失败的那一下。++ 共同的形态取自 transitions.dev 的免费配方(逐条的来源 URL、它那边的时长/模糊/+ 缩放取值和 Peach 落成的值记在 docs/reference-snapshots/transitions-dev-measured.md)。+ 借的是形态和参数,类名与 token 都是 Peach 自己的:时长与缓动一律读 board.css 的+ `--motion-swap`/`--motion-reveal`/`--board-motion`/`--spring-*`,所以+ `prefers-reduced-motion` 由那一份全局规则一次关掉,这里不再逐处补。++ 只动 opacity/transform/filter/stroke-dashoffset,不动 width、height、left 这类+ 会触发重排的属性——这几条都长在读数、按钮和整页占位上,一次重排就是一整棵子树。 */++/* ── 字形换字形 ──+ 两枚字形叠在同一个 grid 格里,换的只是容器上的 `data-icon-state`:innerHTML 重写会+ 把旧字形连同它的动画一起丢掉,看上去就是硬切。退场那一枚缩到 .25 并糊掉,+ 进场那一枚从同样的位置长回原大小。 */+.iconswap{display:inline-grid;place-items:center;line-height:1;flex:none}+.iconswap>[data-icon]{grid-area:1/1;display:grid;place-items:center;+ transition:opacity var(--motion-swap),filter var(--motion-swap),transform var(--motion-swap)}+.iconswap[data-icon-state="a"]>[data-icon="a"],+.iconswap[data-icon-state="b"]>[data-icon="b"]{opacity:1;filter:blur(0);transform:scale(1)}+/* 退场那一枚要收掉指针和读屏:它还占着同一个格子,不收的话按钮上有两个可点区域,+ 读屏也会把两枚字形的名称连着念出来。 */+.iconswap[data-icon-state="a"]>[data-icon="b"],+.iconswap[data-icon-state="b"]>[data-icon="a"]{opacity:0;filter:blur(2px);transform:scale(.25);+ pointer-events:none}++/* ── 一行字换成另一行字 ──+ 退场往上走 4px 并糊掉,新字从下方 4px 处回到原位。`.entering` 那一帧不带过渡,+ 它只是把新字瞬间摆到起点,下一帧摘掉类名才开始走。 */+.textswap{display:inline-block;transition:opacity var(--motion-swap),+ filter var(--motion-swap),transform var(--motion-swap)}+.textswap.leaving{opacity:0;filter:blur(2px);transform:translateY(-4px)}+.textswap.entering{opacity:0;filter:blur(2px);transform:translateY(4px);transition:none}++/* ── 读数按位错峰 ──+ 每一位从下方 8px 处带模糊长上来,相邻两位差一个 `--motion-stagger`。缓动那条超出+ 1 的控制点是数字自己要的:读数落位时轻轻过一点再收住,才读成「跳到了新值」而不是+ 「被推到了新值」。分隔符(千分位逗号、间隔点)跟着相邻那一位走,不单独占一档。 */+@keyframes digit-pop-in{+ from{opacity:0;filter:blur(2px);transform:translateY(8px)}+ to{opacity:1;filter:blur(0);transform:none}}+.digits{display:inline-flex;align-items:baseline}+.digits>span{display:inline-block;white-space:pre}+.digits.popping>span{animation:digit-pop-in var(--motion-swap) cubic-bezier(.34,1.45,.64,1) both;+ animation-delay:calc(var(--motion-stagger) * var(--digit-at,0))}++/* ── 占位换成真内容 ──+ 骨架和内容在同一段时间里交叉:骨架淡出并糊掉,内容从模糊里清晰起来。两层必须叠在+ 同一处坐标,所以换的那一刻把旧的整块抬成绝对定位的一层盖在容器上,动画走完再摘掉;+ 容器本身的高度全程由新内容决定,不留一段空白,也不让下面的东西跳两次。 */+/* `<dialog>` 自己已经是 fixed,它就是淡出层的包含块;再给它一条 relative 会把浮窗从+ 视口定位打回文档流里,整块详情会掉到页面底下。 */+.skelreveal:not(dialog){position:relative}+.skelreveal>.skelfade{position:absolute;inset:0;z-index:2;overflow:hidden;pointer-events:none;+ opacity:1;filter:blur(0);transition:opacity var(--motion-reveal),filter var(--motion-reveal)}+.skelreveal.revealing>.skelfade{opacity:0;filter:blur(2px)}+/* 用 `backwards` 不用 `both`:终点帧是内容本来的样子,留着它只多留下一个+ `filter:blur(0)`,而非 none 的 filter 会另起一个 backdrop root,内容里任何+ backdrop-filter 从此只采样得到它自己。 */+.skelreveal>:not(.skelfade){animation:skel-reveal-in var(--motion-reveal) backwards}+@keyframes skel-reveal-in{from{opacity:0;filter:blur(2px)}to{opacity:1;filter:blur(0)}}++/* ── 成功的那一下 ──+ 勾从下方荡上来的同时转正、从模糊里清晰起来,笔画随后画出。荡那一下走+ `--spring-press`:它冲过落点再收回来,正是一个「落定」的手感;其余三条走站内那条+ 通用缓动。笔画长度 24 是这枚字形的整条折线,dasharray 与 dashoffset 都是继承属性,+ 写在外层 svg 上就能穿过 `<use>` 落到里面那条 path。 */+@keyframes check-settle{from{opacity:0;transform:rotate(80deg);filter:blur(10px)}+ to{opacity:1;transform:rotate(0);filter:blur(0)}}+@keyframes check-bob{from{translate:0 14px}to{translate:0 0}}+@keyframes check-draw{from{stroke-dashoffset:24}to{stroke-dashoffset:0}}+.checkdraw>svg{stroke-dasharray:24;+ animation:check-settle var(--board-motion) backwards,+ check-bob calc(var(--spring-press-ms)*1ms) var(--spring-press) backwards,+ check-draw var(--board-motion) var(--motion-stagger) backwards}++/* ── 失败的那一下 ──+ 已经有红边表达「这一格不对」,抖动只是把视线拉过去,所以不另加红字、不改边框色,+ 只在原位左右各走一趟再回中。走的是站内那条通用时长与缓动,reduced motion 下归零。+ `[aria-invalid]` 一挂上就开始走,是纯 CSS 的触发;同一次提交里同一格再报同一个错,+ 属性没变过,这一下就不重放——判据是「这一格刚变成不对」,不是「又提交了一次」。 */+@keyframes field-shake{0%{transform:translateX(0)}+ 28.57%{transform:translateX(6px)}+ 57.14%{transform:translateX(-6px)}+ 78.57%{transform:translateX(4px)}+ 100%{transform:translateX(0)}}+:is(input,textarea,select)[aria-invalid="true"],+.board-number-control:has([aria-invalid="true"]){animation:field-shake var(--board-motion)}diff --git a/web/js/ui-components.js b/web/js/ui-components.jsindex a62cd7955..2944d0a23 100644--- a/web/js/ui-components.js+++ b/web/js/ui-components.js@@ -22,6 +22,105 @@ export function collectionHeaderHtml({readout='',controls='',before='',classNamereturn `<div class="entitycollectionhead${className?' '+esc(className):''}"${filterRow?` data-filter-row="${esc(filterRow)}"`:''}>${before}<h3${loading?' class="skeleton"':''}>${readout}</h3>${controls}</div>`;}+/* ── 原地换态的一组辅助 ──+ 形状和 CSS 在 `web/css/25-motion.css`,那里也写着每一条的来源与取值。这一层只负责+ 「什么时候换」:动画本身一律交给 CSS,JS 不读也不写具体的毫秒数。 */++/**+ * 两枚字形叠在一格里,换态只改容器上的 `data-icon-state`。+ *+ * 直接 `innerHTML=icon(...)` 的地方都可以换成它:重写 innerHTML 会把旧字形连同它正在+ * 走的动画一起丢掉,新字形也没有起点可走,读出来是一次硬切。+ */+export function iconSwapHtml(a,b,state='a',{className='',iconClass='',label=''}={}){+ return `<span class="iconswap${className?' '+esc(className):''}" data-icon-swap data-icon-state="${state==='b'?'b':'a'}"${+ label?` aria-label="${esc(label)}"`:''}><span data-icon="a">${icon(a,iconClass)}</span><span data-icon="b">${icon(b,iconClass)}</span></span>`;+}+/** 把 `iconSwapHtml` 画出来的那一枚切到 a 或 b;`root` 可以是它本身或它的祖先。 */+export function setIconSwap(root,state){+ const el=root&&(root.matches?.('[data-icon-swap]')?root:root.querySelector?.('[data-icon-swap]'));+ if(el)el.dataset.iconState=state==='b'||state===true?'b':'a';+ return el;+}++/**+ * 一行字换成另一行字:旧字往上糊掉,新字从下方回到原位。+ *+ * 值没变就什么也不做——同一次重绘里把同样的字再写一遍是常态,跟着抖一下会让页面看起来+ * 一直在变。首次写入(这一格还空着)也不放动画:那是内容第一次出现,归骨架那一段。+ */+export function swapText(el,text,{html=false}={}){+ if(!el)return;+ const next=String(text??''),write=()=>{if(html)el.innerHTML=next;else el.textContent=next};+ const previous=el.dataset.swapText;+ if(previous===next&&(el.textContent||'').length)return;+ el.dataset.swapText=next;+ el.classList.add('textswap');+ if(previous===undefined||previous===next){write();return}+ el.classList.remove('entering');+ el.classList.add('leaving');+ const enter=()=>{+ el.classList.remove('leaving');+ write();+ el.classList.add('entering');+ el.getBoundingClientRect();+ el.classList.remove('entering');+ };+ const done=event=>{if(event.target!==el)return;el.removeEventListener('transitionend',done);enter()};+ el.addEventListener('transitionend',done);+ /* 兜底:`--motion-swap` 归零或元素此刻不可见时 `transitionend` 不会来,+ 不兜的话这一行就永远停在透明。 */+ setTimeout(()=>{if(el.classList.contains('leaving')){el.removeEventListener('transitionend',done);enter()}},400);+}++/**+ * 读数按位错峰长出来。把 `text` 拆成一个个字符,数字各占一档延迟,分隔符跟着前一档。+ *+ * 和 `swapText` 一样只在值真变时触发,首次写入不放动画。+ */+export function popCount(el,text){+ if(!el)return;+ const next=String(text??''),previous=el.dataset.popCount;+ if(previous===next&&el.firstElementChild)return;+ el.dataset.popCount=next;+ let at=-1;+ el.innerHTML=`<span class="digits">${[...next].map(ch=>{+ if(/\d/.test(ch))at+=1;+ return `<span style="--digit-at:${Math.max(at,0)}">${esc(ch)}</span>`;+ }).join('')}</span>`;+ /* 上一个值没登记过(这一格第一次出现)或压根没变,就只把字写上去。调用点整块重绘时+ 把上一次的读数写回 `dataset.popCount` 再调,这一格才知道自己是换了值还是刚建出来。 */+ if(previous===undefined||previous===next)return;+ const group=el.firstElementChild;+ group.getBoundingClientRect();+ group.classList.add('popping');+}++/**+ * 占位换成真内容:旧的那一屏抬成盖在容器上的一层淡出,新内容同时从模糊里清晰起来。+ *+ * `write()` 负责把新内容写进 `container`。容器里没有骨架时直接写,不套这一层——+ * 翻页、筛选这类「内容换内容」不属于这条动效,套上去每换一次筛选整页都糊一下。+ */+export function revealSkeleton(container,write){+ if(!container)return;+ const hasSkeleton=container.querySelector('.skeleton,[data-skeleton],.skeletoncard,.countskeleton');+ if(!hasSkeleton||!container.firstChild){write();return}+ const fade=document.createElement('div');+ fade.className='skelfade';+ fade.setAttribute('aria-hidden','true');+ while(container.firstChild)fade.append(container.firstChild);+ write();+ container.classList.add('skelreveal');+ container.prepend(fade);+ container.getBoundingClientRect();+ container.classList.add('revealing');+ const drop=()=>{fade.remove();container.classList.remove('skelreveal','revealing')};+ const done=event=>{if(event.target!==fade)return;fade.removeEventListener('transitionend',done);drop()};+ fade.addEventListener('transitionend',done);+ setTimeout(()=>{if(fade.isConnected){fade.removeEventListener('transitionend',done);drop()}},1000);+}+const horizontalControls=new Map();let horizontalCleanup;/** 同一容器只绑定一次,滚到边缘后将滚轮交还页面。 */