Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 保留卡片悬停边框与筛选玻璃的溢出动画

longmeidaoeb63645f3639
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 6e1435266..690737df4 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -3978,6 +3978,18 @@ class WebUiSourceTests(unittest.TestCase):
rule = self.css[start:self.css.index("}", start)]
self.assertIn("background:rgba(0,0,0,.6)", rule, f"{selector} 和同屏的悬浮件不是一档黑")
+ def test_card_hover_and_view_glide_can_extend_outside_content(self):
+ board = (Path(__file__).resolve().parents[1] / "web/board.css").read_text(encoding="utf-8")
+ self.assertIn(".card{overflow:visible;border-radius:var(--surface-radius)}", board)
+ self.assertIn(".gridstack .card:not(.junkcard) .pic{border-radius:12px;overflow:hidden}", board)
+ self.assertIn(".card:hover .pic::after,.card.selected .pic::after{box-sizing:border-box;border-radius:inherit}", board)
+ self.assertIn(".board-filter-frame.board-filter-frame{border-radius:22px;isolation:isolate;color:var(--glass-text);overflow:visible}", board)
+ self.assertPageContains("const host=pill.closest('.board-filter-frame');if(!host)return null;")
+ self.assertPageContains("x-=n.scrollLeft;y-=n.scrollTop;")
+ self.assertPageContains("if(rect.right<=viewport.left||rect.left>=viewport.right)return null;")
+ self.assertPageContains("if(scroller)scroller.onscroll=()=>syncViewGlide(false,null,kind);")
+ self.assertPageContains("if(!box||!box.w){if(glide)glide.pane.hidden=true;return}")
+
def test_player_tooltips_keep_theme_independent_youtube_style(self):
board_css = (Path(__file__).resolve().parents[1] / "web" / "board.css").read_text(encoding="utf-8")
self.assertNotIn(".vjs-peach-tooltip", board_css)
@@ -8067,14 +8079,12 @@ class WebUiSourceTests(unittest.TestCase):
self.assertNotIn("transparent 62%),color-mix(in srgb,var(--ink) 12%,transparent);", board)
# 描边走满一圈,不只压上缘那一道;外影取主题给的那一档。
self.assertIn("box-shadow:inset 0 0 0 1px var(--glass-rim),var(--glass-pick-shadow)}", board)
- # 玻璃落在那一排最近的那层会裁内容的祖先里,几何就相对它算:那一层横滚时玻璃
- # 跟着内容走,越界的部分跟按钮一起被裁,不会在滚动区外面露出半块白。那一层得
- # 自己是定位元素,否则它不在 `offsetParent` 链上;静态的退回外框。
- self.assertIn("if(getComputedStyle(n).overflowX!=='visible'){host=n;break}", app)
- self.assertIn("return getComputedStyle(host).position==='static'?frame:host;", app)
+ # 玻璃由外框承载,几何扣除横滚量,回弹和阴影允许溢出内容边沿。
+ self.assertIn("const host=pill.closest('.board-filter-frame');if(!host)return null;", app)
+ self.assertIn("x-=n.scrollLeft;y-=n.scrollTop;", app)
self.assertIn("for(let n=pill;n&&n!==host;n=n.offsetParent){x+=n.offsetLeft;y+=n.offsetTop}", app)
self.assertIn("if(glide.pane.parentElement!==box.host)box.host.prepend(glide.pane);", app)
- # 过了断点那一层会换,玻璃得重新落一次位,否则留在旧的那一层上按旧坐标停着。
+ # 视口变化时按按钮的新位置重新落位。
self.assertIn("syncViewGlide(false);syncViewGlide(false,null,'media')},{passive:true});", app)
# 冲过落点再弹回:那条曲线是一次弹簧模拟的采样,峰值 1.103、313ms 收住。
self.assertIn("--spring-pane:linear(0,0.1515,", board)
diff --git a/web/app.js b/web/app.js
index 648e35edb..295f49422 100644
--- a/web/app.js
+++ b/web/app.js
@@ -3190,26 +3190,20 @@ const viewPillsHtml=filterState=>VIEW_PILLS.map(v=>
新建:换了元素,动画就从头开始,看到的只是瞬移。节点由 `viewGlides` 按排持有。
点下去要立刻动。切换视图会重新取数,`buildBars` 约一秒后才把 `aria-pressed` 写成
新值,等它就等于点完先僵一下再跳。 */
-/* 这块玻璃落在那一排最近的一层「会裁掉越界内容」的祖先里,找不到就落在外框上。
- 两件事一起解决:它跟着那一层的内容走,所以那一层横滚时不用自己去减滚动量;越界的
- 部分跟按钮一起被裁,不会在滚动区外面露出半块白。
- 窄屏时那一层就是横滚的 `.filterscroll`;宽屏时那一排根本不滚,这一层是整条筛选条或
- 外框,跳到头一枚的那下回弹尽管冲出那一排的边沿,也没有人切它——这正是玻璃不住在
- `#viewPills` 里的原因,它和它的邻居都开着 `overflow`。
- 那一层得自己是定位元素,否则它不在 `offsetParent` 链上,位置就无从算起;静态的退回
- 外框,宁可不跟着滚,也不要一个算错的坐标。 */
-function glideHost(pill){
- const frame=pill.closest('.board-filter-frame');if(!frame)return null;
- let host=frame;
- for(let n=pill.parentElement;n&&n!==frame;n=n.parentElement){
- if(getComputedStyle(n).overflowX!=='visible'){host=n;break}
- }
- return getComputedStyle(host).position==='static'?frame:host;
-}
+/* 动画层由外框承载,允许回弹与阴影越过内容边沿。横滚只裁剪按钮内容;
+ 玻璃坐标扣除祖先滚动量,目标完全滚出可视区域时收起。 */
function viewGlideGeometry(pill){
- const host=glideHost(pill);if(!host)return null;
+ const host=pill.closest('.board-filter-frame');if(!host)return null;
let x=0,y=0;
for(let n=pill;n&&n!==host;n=n.offsetParent){x+=n.offsetLeft;y+=n.offsetTop}
+ const rect=pill.getBoundingClientRect();
+ for(let n=pill.parentElement;n&&n!==host;n=n.parentElement){
+ x-=n.scrollLeft;y-=n.scrollTop;
+ if(n.scrollWidth>n.clientWidth&&getComputedStyle(n).overflowX!=='visible'){
+ const viewport=n.getBoundingClientRect();
+ if(rect.right<=viewport.left||rect.left>=viewport.right)return null;
+ }
+ }
return {host,x,w:pill.offsetWidth,y,h:pill.offsetHeight};
}
/* 首页和资料页各有一排四选一,玻璃是同一块:在人眼里这两排就是同一个控件,「跟着指针
@@ -3246,6 +3240,8 @@ function viewPillsRow(kind){
function wireViewGlideRow(row,pills,kind='views'){
pills.forEach(b=>b.onpointerenter=e=>{if(e.pointerType!=='touch')syncViewGlide(true,b,kind)});
row.onpointerleave=e=>{if(e.pointerType!=='touch')syncViewGlide(true,null,kind)};
+ const scroller=row.closest('.filterscroll');
+ if(scroller)scroller.onscroll=()=>syncViewGlide(false,null,kind);
syncViewGlide(false,null,kind);
}
/* 每排各存自己那块玻璃和它上一次的落点。键取那一排的用途,不取那一排的元素:资料页
@@ -3258,7 +3254,7 @@ function syncViewGlide(animate,target,kind='views'){
let glide=viewGlides.get(kind);
if(!active){if(glide)glide.pane.hidden=true;return}
const box=viewGlideGeometry(active);
- if(!box||!box.w)return;
+ if(!box||!box.w){if(glide)glide.pane.hidden=true;return}
if(!glide){
const pane=document.createElement('span');
pane.className=`viewglide${GLIDE_ROWS[kind].className?` ${GLIDE_ROWS[kind].className}`:''}`;
diff --git a/web/board.css b/web/board.css
index 547a8ad02..837f18872 100644
--- a/web/board.css
+++ b/web/board.css
@@ -122,7 +122,7 @@
backdrop-filter:var(--glass-optic,blur(22px)) saturate(160%) var(--glass-lume);-webkit-backdrop-filter:var(--glass-optic,blur(22px)) saturate(160%) var(--glass-lume);
border:0;box-shadow:inset 0 1px 0 var(--glass-rim),inset 1px 0 0 var(--glass-low),inset -1px 0 0 var(--glass-low),inset 0 -1px 0 var(--glass-low),var(--glass-shadow);
}
-.board-filter-frame.board-filter-frame{border-radius:22px;isolation:isolate;color:var(--glass-text)}
+.board-filter-frame.board-filter-frame{border-radius:22px;isolation:isolate;color:var(--glass-text);overflow:visible}
.entitytagbar.entitytagbar.entitytagbar,
.entitycollectionhead.entitycollectionhead.entitycollectionhead{border-radius:22px;color:var(--glass-text)}
/* 浮层材质与吸顶归外框,槽位只负责排列内容。 */
@@ -636,7 +636,7 @@ body>.board-filter-frame{margin-inline:16px}
.iconswitch{padding:3px;background:var(--surface);border:1px solid var(--line-soft);border-radius:10px}
.iconswitch label{border-radius:8px}
.iconswitch label:has(input:checked){background:var(--ground);box-shadow:0 1px 3px #0002}
-.card{overflow:clip;border-radius:var(--surface-radius)}
+.card{overflow:visible;border-radius:var(--surface-radius)}
.card .pic{border-radius:var(--surface-radius)}
.card .info{background:transparent}
@media(max-width:760px){.sidecontent{padding:16px}.stage{border-radius:12px}.stage .side{border-left:0;border-top:1px solid var(--line-soft)}}