Peach: Local-first video metadata scraper and media manager.
fix(web): iOS 状态栏回到实色,筛选条上滚放出改走合成线程不再卡顿
longmeidao364668ee622f
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex c0514f664..d4a16b7d6 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -2916,12 +2916,13 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains("document.querySelectorAll('[data-filter-frame]')")self.assertPageContains("const active=frames.find(frame=>frame.offsetParent!==null);")self.assertPageContains("mobileFilterScroll=filterScrollState(mobileFilterScroll,y,innerWidth<=760,hold);")- # 窄屏这条和主题切换那条材质过渡同权重、又排在后面,`top` 得和材质写在一起,- # 否则它把材质那条整个顶掉,浮层在明暗之间又变回一刀切。- self.assertIn(".board-filter-frame.board-filter-frame{transition:top var(--board-motion),"- "background-color .28s ease,backdrop-filter .28s ease,"- "-webkit-backdrop-filter .28s ease}", board)+ # 收起和放出时 `top` 一步到位,滑动交给合成线程上的 translate;`top` 不进过渡,逐帧重排会卡。self.assertIn(".board-filter-frame.board-filter-frame.mobile-filter-free{top:var(--filter-free-top)}", board)+ self.assertNotIn("transition:top var(--board-motion)", board)+ self.assertPageContains("if(free===frame.classList.contains('mobile-filter-free'))continue;")+ self.assertPageContains("frame.getAnimations().forEach(a=>a.id==='filter-slide'&&a.cancel());")+ self.assertPageContains("frame.animate([{translate:`0 ${shift}px`},{translate:'0 0'}],{id:'filter-slide',duration:parseFloat(duration)*1000,easing});")+ self.assertPageContains("el.getBoundingClientRect().top-(parseFloat(css.translate.split(' ')[1])||0)<=top+1;")self.assertPageContains("document.documentElement.scrollHeight-innerHeight")def test_unlinked_identity_does_not_look_clickable(self):@@ -4586,8 +4587,6 @@ class WebUiSourceTests(unittest.TestCase):切换结束撤掉那个标记时,一整块底色瞬间变成透明玻璃,读出来像主题又切了第二次。所以过渡写在常态上,快照态那条规则自己把过渡关掉——正在拍旧状态的快照时,路上的中间色会被拍进去。- 窄屏那条给筛选浮层改 `top` 的规则同权重且在后,材质过渡要在那里一并写上,- 否则它把这条整个顶掉。"""board = (Path(__file__).resolve().parents[1] / 'web/board.css').read_text(encoding='utf-8')self.assertIn('.board-filter-frame.board-filter-frame,.entitytagbar.entitytagbar,'@@ -4596,8 +4595,6 @@ class WebUiSourceTests(unittest.TestCase):'-webkit-backdrop-filter .28s ease}', board)snapshot_rule = board.split('html[data-theme-snapshot] .review.review-has-pane::before{', 1)[1]self.assertIn('transition:none!important', snapshot_rule.split('}', 1)[0])- self.assertIn('transition:top var(--board-motion),background-color .28s ease,'- 'backdrop-filter .28s ease,-webkit-backdrop-filter .28s ease', board)def test_notes_and_navigation_links_keep_their_own_presentation(self):board = (Path(__file__).resolve().parents[1] / "web/board.css").read_text(encoding="utf-8")@@ -7865,28 +7862,18 @@ class WebUiSourceTests(unittest.TestCase):self.assertPageContains(".scrim.on{display:block;opacity:1;pointer-events:auto}")self.assertPageContains("@starting-style{.scrim.on{opacity:0}}")- def test_ios_status_bar_tint_skips_closed_drawer_and_detail_stage(self):- """iOS 26 的 Safari 取到一块 fixed 元素的颜色后,只要它仍可见就一直沿用。窄屏抽屉收起时必须- visibility:hidden,且可见性跟着位移过渡,滑出动画才播得完。详情浮窗上沿让出状态栏、下沿按 dvh- 停在地址栏之上,两个取样点落在 ::backdrop 上取遮罩的暗色。"""+ def test_mobile_detail_stage_clears_status_bar_and_address_bar(self):+ """手机上详情浮窗上沿让出状态栏、下沿按 dvh 停在地址栏之上,吸顶的画面不钻到两条栏底下。"""board = (Path(__file__).resolve().parents[1] / "web/board.css").read_text(encoding="utf-8")- self.assertIn(" transition:transform var(--board-dialog-motion),visibility var(--board-dialog-motion)}\n"- " .drawer.drawer:not(.open){visibility:hidden}\n", board)self.assertIn(" .stage{inset:calc(env(safe-area-inset-top) + 8px) 8px auto;margin:0 auto;", board)self.assertIn(" max-height:calc(100dvh - env(safe-area-inset-top) - 16px)}", board)- def test_top_bar_shell_is_invisible_to_ios_status_bar_tinting(self):- """通栏吸顶的 `<header>` 永远落在 iOS 26 Safari 给状态栏取色的那一点上,取到过一次颜色就一直沿用。- 顶栏本身 visibility:hidden,直接子元素各自成层保持可见,WebKit 就把这条栏判成不可见的容器跳过;- ::before 铺满接住按钮间隙的点按,也挡住从顶栏底下滑过的吸顶玻璃,筛选框保持全宽。- 窄屏侧栏的遮罩同理:暗色画在 ::before 上,遮罩外壳对取色不可见,一开侧栏状态栏不整块变色。"""+ def test_mobile_scrim_shell_is_skipped_by_ios_status_bar_tinting(self):+ """窄屏侧栏遮罩铺满视口、底色半透明,iOS 26 的 Safari 会把它当压暗层给状态栏取色。暗色画在 ::before 上,+ 遮罩外壳 visibility:hidden,Safari 跳过这层沿用顶栏的颜色,一开侧栏状态栏不整块变暗。"""board = (Path(__file__).resolve().parents[1] / "web/board.css").read_text(encoding="utf-8")- self.assertIn(".top.top{visibility:hidden}\n"- ":where(.top>*){visibility:visible;position:relative}\n"- ".top::before{content:'';position:absolute;inset:0;z-index:-1;visibility:visible}\n", board)self.assertIn(" .scrim.scrim.on{top:0;z-index:101;background:none;visibility:hidden}\n"" .scrim.scrim.on::before{content:'';position:absolute;inset:0;background:#0007;visibility:visible}\n", board)- self.assertNotIn("max-width:calc(88vw - 8px)", board)def test_card_hover_hides_source_and_duration_and_missing_size_is_explicit(self):self.assertPageContains('.card:hover .badge,.card:hover .dur{opacity:0}')diff --git a/web/app.js b/web/app.jsindex 0773e48cf..6b3710cf7 100644--- a/web/app.js+++ b/web/app.js@@ -9471,7 +9471,16 @@ function updateMobileFilterScroll(){for(const frame of frames){const free=frame===active&&mobileFilterScroll.free;if(free)frame.style.setProperty('--filter-free-top',`${-frame.offsetHeight-12}px`);+ if(free===frame.classList.contains('mobile-filter-free'))continue;+ /* `top` 一步到位,再用 translate 从量到的起点滑到落点:逐帧改 `top` 每一帧都要重排,滚动中主线程一忙+ 就一顿一顿,translate 走合成线程。起点量的是连着上一段滑动的实际位置,半路反向也接得上。 */+ const from=frame.getBoundingClientRect().top;+ frame.getAnimations().forEach(a=>a.id==='filter-slide'&&a.cancel());frame.classList.toggle('mobile-filter-free',free);+ const shift=from-frame.getBoundingClientRect().top;+ const [duration,easing]=getComputedStyle(document.documentElement).getPropertyValue('--board-motion').trim().split(' ');+ if(Math.abs(shift)>=1&&parseFloat(duration)>0)+ frame.animate([{translate:`0 ${shift}px`},{translate:'0 0'}],{id:'filter-slide',duration:parseFloat(duration)*1000,easing});}}function updateStickySurfaces(){@@ -9480,7 +9489,7 @@ function updateStickySurfaces(){['.board-filter-frame','#tagbar','#count','.entitytagbar','.entitycollectionhead'].forEach(selector=>{const el=$(selector),css=el&&getComputedStyle(el),top=css?parseFloat(css.top):NaN;const stuck=!!el&&css.position==='sticky'&&el.offsetParent!==null&&window.scrollY>0&&- Number.isFinite(top)&&el.getBoundingClientRect().top<=top+1;+ Number.isFinite(top)&&el.getBoundingClientRect().top-(parseFloat(css.translate.split(' ')[1])||0)<=top+1;if(el)el.classList.toggle('is-stuck',stuck);if(el?.matches('.board-filter-frame'))el.classList.toggle('board-is-stuck',stuck);});diff --git a/web/board.css b/web/board.cssindex 8475d627a..bdd25a6ca 100644--- a/web/board.css+++ b/web/board.css@@ -369,15 +369,6 @@ html.board-high-contrast .board-filter-frame.board-filter-frame.board-filter-fra.gridstack .card:not(.junkcard) .pic{border-radius:12px;overflow:hidden}.gridstack>.grid{row-gap:24px;column-gap:16px}.top{isolation:isolate}-/* 顶栏本身 visibility:hidden,只让里面的控件可见。iOS 26 的 Safari 在状态栏下沿正中命中元素,顺着祖先找第一个- fixed/sticky 容器给状态栏上色:这条通栏吸顶的 `<header>` 永远被选中,头一次取到页面底色就一直沿用,状态栏- 变成一条实色,内容透不上去。WebKit 判容器是否可见只看它自己画的内容,自带图层的后代不算,所以直接子元素都- 带上 position 各自成层;`:where` 不占特异性,已有的定位和隐藏规则照旧生效。空的 ::before 铺满整条接住按钮- 间隙的点按,不让它落到栏下面的卡片上;取样点也先命中它,从顶栏底下滑过的筛选框等吸顶玻璃够不到那一点,- 宽度不必为此收窄。门槛见 WebKit LocalFrameView::fixedContainerEdges 与 RenderLayer::computeHasVisibleContent。 */-.top.top{visibility:hidden}-:where(.top>*){visibility:visible;position:relative}-.top::before{content:'';position:absolute;inset:0;z-index:-1;visibility:visible}body.board-scrolled .top{box-shadow:none;border-bottom:0}/* 吸顶那一刻这块板离开纸面往上抬一档,三层影跟着加重:它盖住内容滚过去,两层之间要有东西说明谁在上面。类名写三遍是为了压过上面那组玻璃规则——两条都从@@ -561,11 +552,7 @@ body::before{display:none}8px 还被 `.combo` 的下边距吃掉,加起来 32px,下面却只有 20px,同一块浮层上下差出 12px。上面这 22px 改不动(两处都是别的页面共用的),所以自己不再加,下面照同一个数写。 */.board-filter-frame{position:sticky;top:calc(var(--topH) + 8px);z-index:60;border:0;border-radius:16px;background:var(--ground);margin:0 0 22px;box-shadow:0 2px 14px #00000014}-@media(max-width:760px){- /* 窄屏这条要把材质那两样带上:同权重、排在后面,整条 `transition` 会把上面那份换掉。 */- .board-filter-frame.board-filter-frame{transition:top var(--board-motion),background-color .28s ease,backdrop-filter .28s ease,-webkit-backdrop-filter .28s ease}- .board-filter-frame.board-filter-frame.mobile-filter-free{top:var(--filter-free-top)}-}+@media(max-width:760px){.board-filter-frame.board-filter-frame.mobile-filter-free{top:var(--filter-free-top)}}/* 首页那块住在 `body` 底下,两侧没有任何东西给它留白,22px 的圆角直接切在屏幕边沿上;资料页那块在 `#index` 里,`main` 的 16px 已经把它让开了。这里补的就是那 16px,取的也是 `main` 自己的那个数,所以两页的浮层和底下的网格对在同一条竖线上。 */@@ -793,9 +780,7 @@ body>.board-filter-frame{margin-inline:16px}/* 手机上浮窗离屏幕边只留 8px,画面格按视频自己的比例排:竖屏和方形视频装进 16:9 的格子里只剩中间一小块画面。比例由播放器读到元数据后写进 `--peach-video-ratio`,读到之前仍是 16:9;高度封顶 56dvh,吸顶以后下面至少还有四成屏给详情。- 上沿让出状态栏、下沿按 dvh 停在地址栏之上:iOS 26 的 Safari 在状态栏下沿和地址栏上沿各取一点给- 两条栏取色,点落在浮窗上就刷成浮窗的底色,落在 ::backdrop 上取的是遮罩那一档暗色,和底下- 被压暗的页面连成一片。 */+ 上沿让出状态栏、下沿按 dvh 停在地址栏之上,浮窗和吸在它顶上的画面不钻到这两条栏底下。 */@media(max-width:760px){.stage{inset:calc(env(safe-area-inset-top) + 8px) 8px auto;margin:0 auto;width:calc(100vw - 16px);max-width:calc(100vw - 16px);max-height:calc(100dvh - env(safe-area-inset-top) - 16px)}@@ -878,15 +863,11 @@ html.board-high-contrast .settingscard.settingscard>.board-local-nav{background:.drawer:not(.open) .board-sidebar-head #filterBtn{height:20px}}@media(max-width:760px){- /* 收起时不可见,不只是移出屏幕:iOS 26 的 Safari 取到过这块玻璃给状态栏上色后,只要它仍可见就一直沿用,- 开合一次状态栏就再也透不出内容。visibility 跟着位移一起过渡,过渡期间两头都算可见,滑出动画照常播完。 */- .drawer.drawer{top:12px;bottom:12px;z-index:102;transform:translateX(calc(-100% - 16px));- transition:transform var(--board-dialog-motion),visibility var(--board-dialog-motion)}- .drawer.drawer:not(.open){visibility:hidden}+ .drawer.drawer{top:12px;bottom:12px;z-index:102;transform:translateX(calc(-100% - 16px));transition:transform var(--board-dialog-motion)}.drawer.drawer.open{transform:translateX(0)}/* 暗色画在 ::before 上,遮罩本身 visibility:hidden:它铺满视口、没有子元素、底色半透明,iOS 26 的 Safari- 会把它当压暗层,拿暗色和页面底色混成实色刷满状态栏,一开侧栏状态栏就整块变色。自带图层的 ::before- 不计入外壳的可见内容,Safari 跳过这层,点在暗色上仍然落到遮罩身上收起侧栏。 */+ 会把它当压暗层给状态栏取色,一开侧栏状态栏就整块变暗。自带图层的 ::before 不计入外壳的可见内容,+ Safari 跳过这层、沿用顶栏的颜色,点在暗色上仍然落到遮罩身上收起侧栏。 */.scrim.scrim.on{top:0;z-index:101;background:none;visibility:hidden}.scrim.scrim.on::before{content:'';position:absolute;inset:0;background:#0007;visibility:visible}.index .ihead .geist-search{flex-basis:160px}