iter(g58): 新增 affix 固钉组件

This commit is contained in:
HIsheR
2026-10-26 12:23:25 +08:00
parent 89cddada21
commit 7684ae2b10
12 changed files with 166 additions and 10 deletions
+32 -2
View File
@@ -1,6 +1,6 @@
{
"$schema": "ui-arch-registry-index/0.1",
"generatedAt": "2026-10-26T04:21:58.071Z",
"generatedAt": "2026-10-26T04:23:09.567Z",
"repoRoot": ".",
"packages": [
{
@@ -197,7 +197,8 @@
"colorPicker(props):颜色选择,预设色板(缺省语义令牌色)+ 原生取色器 + 手输 CSS 颜色串,value 为颜色串信号",
"tour(props):引导漫游,返回 { el, start, close } 句柄;聚光框按 target 选择器定位,卡片自动选方位,Esc / 跳过走 onClose",
"watermark(props, ...children):内容容器 + 平铺水印覆盖层,canvas 生成单元、颜色取自令牌,覆盖层不挡交互",
"checkboxGroup(props):多选组,value 为数组信号,min/max 用禁用边界项实现(不抛错),checkAll 支持半选且只统计未禁用项"
"checkboxGroup(props):多选组,value 为数组信号,min/max 用禁用边界项实现(不抛错),checkAll 支持半选且只统计未禁用项",
"affix(props, ...children):固钉,滚过 offset 后内容转 fixed 贴顶、外层保留占位高度,固定后宽度随容器自适应"
],
"keyTypes": [
"ButtonProps",
@@ -2519,6 +2520,35 @@
"checkAll 行的选中/半选只统计未禁用项,禁用项不计入基数",
"direction 传 vertical 改为纵向排列;disabled 支持信号,整组响应式禁用"
]
},
{
"id": "affix",
"title": "固钉 Affix",
"demo": "sec-affix",
"props": [
{
"n": "offset",
"t": "number",
"d": "距视口顶部多少像素后转为固定;缺省 0"
},
{
"n": "target",
"t": "HTMLElement | Window",
"d": "监听的滚动容器;缺省 window(整页)"
},
{
"n": "children",
"t": "...unknown[]",
"d": "被固定的内容,作为第二个及之后的实参传入"
}
],
"example": "affix({ offset: 8 }, card({ title: '滚动时我会贴顶' }, h('p', null, '正文')))",
"steps": [
"把要贴住的内容作为实参传入;组件内部包两层:外层占位、内层负责 fixed",
"滚动到 offset 以内(默认贴视口顶)时内层转 fixed,外层同步撑出等高占位,页面不会塌跳",
"固定期间宽度与横向位置跟随占位容器,窗口缩放或父容器变宽都自动贴合",
"内滚容器场景把该元素传给 target,判定改为基于它的滚动位置"
]
}
]
},