Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
238 commits
Select commit Hold shift + click to select a range
d737f3d
feat: 初始化recycle list
Jan 20, 2025
7de08fb
feat: 初始化recycle list
Jan 21, 2025
78c6340
chore: 增强recycle
Jan 22, 2025
e93b931
chore: 增强recycle
Jan 22, 2025
db5ed91
fix: ali&web环境scrollTop初始化不生效问题
Jan 23, 2025
b67f4a0
chore: 适配rn
Feb 5, 2025
a76b2c3
feat: rn支持抽象节点
Feb 6, 2025
eaed9a0
fix: warning
Feb 6, 2025
f9c7722
chore: 删除web单独适配的recycle-list
Feb 10, 2025
a38b0f1
chore: 添加节流优化
Feb 10, 2025
5978c67
Merge branch 'master' into feat-recycle-list-web
Feb 10, 2025
3033c17
feat: 支持同时传递多个抽象节点
Feb 10, 2025
1243a2e
chore: 删除vuepress
Feb 10, 2025
042cccc
chore: 优化recycle-view组件
Feb 11, 2025
b13b4ac
chore: 优化recycle-view组件
Feb 11, 2025
dd88f94
feat: 编译时支持内置扩展组件
Feb 11, 2025
0731d04
feat: 新增小程序平台recycle-view全局组件注册
Feb 11, 2025
109e5dd
chore: 修改web,rn平台recycle-view全局组件注册
Feb 12, 2025
985aec0
feat: 新增web, 小程序环境支持跨平台组件编译配置
Feb 12, 2025
0df56f3
feat: item支持动态高度
Feb 13, 2025
fd38830
fix: lint error
Feb 13, 2025
09287cb
chore: 简化visibleCount逻辑
Feb 13, 2025
5b8bc99
fix: rn全局组件注册找不到
Feb 13, 2025
4877bc6
chore: 删除注释
Feb 13, 2025
1e7365a
chore: 修改itemSize定义
Feb 13, 2025
422f350
Merge branch 'master' into feat-recycle-list-web
Feb 13, 2025
c41daee
Merge branch 'fix-rn-global-component' into feat-recycle-list-web
Feb 13, 2025
753a575
Merge branch 'fix-rn-global-component' into feat-recycle-list-web
Feb 13, 2025
4ba6ccd
chore: visibleCount计算逻辑支持item宽高不一致情况
Feb 14, 2025
de3e8e8
chore: 修改visibleCount计算,支持宽高不一致情况
Feb 17, 2025
b24fcd4
fix: web误触发onScrollToLower事件
Feb 17, 2025
9578c47
chore: 调整listData数据更新逻辑
Feb 17, 2025
9b84441
Merge branch 'master' into feat-recycle-list-web
Feb 18, 2025
c244764
feat: 新增sticky-section组件
Feb 18, 2025
17b67f8
feat: 初始化sticky-header
Feb 20, 2025
57dfee4
fix: scrollView具备margin样式情况
Feb 20, 2025
d2f0999
feat: 添加跨平台配置
Feb 20, 2025
ff8d7ff
chore: 添加调试文件暂存
Feb 24, 2025
5440135
fix: sticky-header抖动问题
Feb 25, 2025
a906c68
feat: sticky-header方案调整
Feb 27, 2025
82c9710
chore: 补充header功能
Feb 27, 2025
0709497
fix: 非sticky组件scroll 报错
Feb 27, 2025
963747d
feat: web环境支持sticky-header
Feb 28, 2025
9ea1839
chore: 新增dom节点检查
Feb 28, 2025
6d22397
feat: add sticky-section 配置
Mar 3, 2025
156d402
Merge branch 'master' into feat-extend-sticky
Mar 3, 2025
4c7e647
chore: add sticky section config
Mar 4, 2025
5b1e320
fix: rn 吸顶逻辑计算
Mar 4, 2025
fe3dc93
feat: 支持padding属性
Mar 4, 2025
a325f03
fix: 导航条位置获取异常导致吸附位置不正确
Mar 5, 2025
93e0a07
feat: add sticky-section组件
Mar 5, 2025
63e6ea9
Merge branch 'master' into feat-recycle-list-web
Mar 5, 2025
a579c70
Merge branch 'master' into feat-extend-sticky
Mar 5, 2025
0d2484d
chore: 删除无用sticky组件
Mar 5, 2025
d7c7089
Merge branch 'master' into feat-extend-sticky
Mar 7, 2025
666202c
Merge branch 'master' into feat-recycle-list-web
Mar 7, 2025
438aed5
Merge branch 'feat-recycle-list-web' into feat-extend-sticky
Mar 7, 2025
09cc262
fix: add enableSticky 属性
Mar 7, 2025
3e89590
chore: del useless code
Mar 7, 2025
a4a9ba2
Merge branch 'feat-recycle-list-web' into feat-extend-sticky
Mar 7, 2025
a05fda4
fix: sticky-header
Mar 7, 2025
15dd08b
fix: AnimatedScrollView 生成时机
Mar 14, 2025
8f2b0a6
fix: AnimatedScrollView 生成时机
Mar 14, 2025
b3671e7
Merge branch 'master' into feat-extend-sticky
Mar 14, 2025
1f9ad4c
chore: 调整组件入参
Mar 14, 2025
371ccf8
fix: lint
Mar 14, 2025
ec78dde
Merge branch 'master' into feat-extend-sticky
Mar 18, 2025
9680227
fix: 外层做动画 android pageY 可能拿到不准问题
Mar 19, 2025
ae22a6c
Merge branch 'master' into feat-extend-sticky
Mar 21, 2025
c2eef9d
chore: 修改scroll触发逻辑
Mar 21, 2025
2ec66c0
chore: 修改scroll触发逻辑
Mar 21, 2025
4d7a2d2
chore: 修改 aboveCount 和 belowCount 计算逻辑
Mar 21, 2025
f311836
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 21, 2025
26d4413
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 21, 2025
730736d
chore: 调整组件重建时机
Mar 21, 2025
c29beeb
feat: 支持scrollTo方法
Mar 21, 2025
24e9183
chore: 新增支持props
Mar 21, 2025
c35d1a9
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 21, 2025
b178e62
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 21, 2025
15d84ee
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 24, 2025
d12815d
chore: add rn recyle
Mar 24, 2025
b9ce382
feat: 支持generic
Mar 24, 2025
b408c80
chore: 修改generic
Mar 25, 2025
0bd9f71
chore: 修改generic
Mar 25, 2025
d024f47
chore: 修改generic
Mar 25, 2025
7b87ad6
chore: 修改injectProperties注入时机
Mar 25, 2025
bf6d32f
fix: boundingClientRect 获取异常
Mar 25, 2025
a187e38
Merge branch 'feat-extend-sticky' into feat-generic-rn
Mar 25, 2025
acdefe2
chore: del
Mar 25, 2025
31d64fc
Merge branch 'feat-simple-view' into feat-extend-sticky
Mar 25, 2025
35b1fe3
Merge branch 'feat-generic-rn-new' into feat-extend-sticky
Mar 26, 2025
d64e552
Merge branch 'feat-extend-sticky' into feat-recycle-rn
Mar 26, 2025
a3f6a70
fix conflict
Mar 26, 2025
7d02911
Merge branch 'feat-extend-sticky' into feat-recycle-rn
Mar 26, 2025
6ec3a9c
chore: 增强recycle-view.
Mar 26, 2025
596026f
Merge branch 'feat-generic-rn-new' into feat-recycle-rn
Mar 26, 2025
0dc180b
Merge branch 'master' into feat-recycle-rn
Mar 30, 2025
5daf649
Merge branch 'feat-generic-rn-new' into feat-recycle-rn
Mar 30, 2025
5b51763
chore: 修改recycle逻辑
Mar 30, 2025
02fc308
Merge branch 'feat-generic-rn-new' into feat-recycle-rn
Mar 31, 2025
9ba79c9
Merge branch 'master' into feat-recycle-rn
Mar 31, 2025
28ed166
chore: 修改文件路径
Apr 1, 2025
83bb124
Merge branch 'feat-generic-rn-new' into feat-recycle-rn
Apr 1, 2025
ad11b1a
Merge branch 'master' into feat-recycle-rn
Apr 1, 2025
798a1cf
Merge branch 'master' into feat-recycle-rn
Apr 10, 2025
4f409dc
fix: lint;
Apr 11, 2025
f5fcefe
feat: 补充recycle能力
Apr 11, 2025
5148785
feat: 优化小程序 recycle-view
Apr 15, 2025
835368b
chore: 调整recycle目录
Apr 15, 2025
760dccd
Merge branch 'feat-sticky-rn' into feat-recycle-rn
Apr 15, 2025
0ce6847
feat: 支持 rn 环境recycle
Apr 16, 2025
c192ec0
chore: rn环境支持recycle-view
Apr 17, 2025
de646d4
chore: rn环境支持recycle-view
Apr 17, 2025
0ab5792
chore: 调试recycle
Apr 21, 2025
48a2364
chore: 调试recycle
Apr 21, 2025
d207cdd
chore: 调试getSectionItemLayout
Apr 23, 2025
1e764fa
chore: 调试getSectionItemLayout
Apr 24, 2025
c42ac70
chore: 调试getSectionItemLayout
Apr 25, 2025
fb36889
chore: 调试getSectionItemLayout
Apr 25, 2025
af7d0b6
chore: 兼容flatList
Apr 25, 2025
1e2f722
chore: 支持scrollToIndex
Apr 25, 2025
25263d7
chore: 支持反向索引映射
Apr 25, 2025
5f23489
Merge branch 'master' into feat-recycle-rn
Apr 27, 2025
cbd6b1b
feat: 优化小程序recycle
Apr 27, 2025
cd5100a
feat: 优化小程序recycle
Apr 27, 2025
18f8552
feat: 优化小程序recycle
Apr 28, 2025
be207ec
chore: 修改recycle注入逻辑
Apr 28, 2025
b8407da
chore: 修改rn组件注入条件
Apr 29, 2025
a7f38c6
chore: rn环境支持通过ref获取scrollToIndex方法
Apr 29, 2025
011f8e5
fix: wx recycle
Apr 29, 2025
3ee2cc6
chore: 调整wx组件结构
Apr 29, 2025
3a725d2
chore: del 无用md
Apr 30, 2025
bdfd315
Merge branch 'feat-sticky-rn' into feat-recycle-rn
Apr 30, 2025
2b04cc0
chore: 调整ali,web组件注入逻辑
Apr 30, 2025
68b60bf
Merge branch 'master' into feat-recycle-rn
May 7, 2025
b2f151d
feat: 支持 web sticky;
May 7, 2025
e575ba8
feat: 支持scrollToIndex
May 8, 2025
b7993c2
feat: 支持下拉刷新
May 8, 2025
548ac5e
feat: 支持list-header
May 8, 2025
51051ba
chore: 使用enableSticky作为标识
May 8, 2025
811658a
Merge branch 'feat-recycle-rn' into feat-recycle-sticky-web
May 8, 2025
5fcc341
chore: 优化组件注册逻辑
May 8, 2025
5305a48
feat: scrollToIndex支持viewPosition
May 8, 2025
eedc1fc
chore: 优化props类型
May 9, 2025
043752b
chore: 优化props类型
May 9, 2025
c366c40
chore: 优化props类型
May 9, 2025
2c801b1
Merge branch 'feat-recycle-rn' into feat-recycle-sticky-web
May 9, 2025
6eba2d4
chore: 优化props类型
May 9, 2025
8fc3515
chore: 优化组件注册逻辑
May 9, 2025
169e428
chore: 调整mpx-recycle-view目录
May 9, 2025
8f60230
chore: 调整mpx-recycle-view目录
May 9, 2025
3000d00
Merge branch 'feat-recycle-rn' into feat-recycle-sticky-web
May 9, 2025
570667f
Merge branch 'feat-sticky-rn' into feat-recycle-rn
May 12, 2025
a937a57
feat: init sticky ali
May 13, 2025
b7468e9
feat: init sticky ali
May 13, 2025
b0211f0
Merge branch 'feat-sticky-rn' into feat-recycle-rn
May 21, 2025
15895f3
Merge branch 'feat-sticky-rn' into feat-recycle-sticky-web
May 21, 2025
4c8cb27
Merge branch 'feat-sticky-rn' into feat-sticky-ali
May 22, 2025
2505b65
feat: 切换sticky吸附判断条件
May 23, 2025
1386c9e
fix: offsetTop导致吸附位置错误问题
May 23, 2025
deb6e01
feat: ali环境支持sticky-section
May 26, 2025
f7d80fa
Merge branch 'feat-sticky-rn' into feat-recycle-rn
May 26, 2025
e8732eb
Merge branch 'feat-recycle-rn' into feat-sticky-ali
May 26, 2025
c633673
chore: ali 支持recycle-view
May 26, 2025
e59c1cd
chore: 优化recycle-view
May 27, 2025
02dfc1f
chore: 优化sticky
May 27, 2025
47807f1
Merge branch 'master' into feat-sticky-ali
May 27, 2025
ccc8ac5
chore: 优化recyle
May 28, 2025
9bea494
chore: 优化recyle
May 28, 2025
d104685
chore: 修改recycle-view ref 获取返回值
May 28, 2025
9e15b94
Merge branch 'feat-recycle-rn' into feat-sticky-ali
May 28, 2025
e75566a
chore: 补充ali环境EXTEND_COMPONENTS_LIST
May 28, 2025
d77cc56
chore: 补充ali环境EXTEND_COMPONENTS_LIST
May 28, 2025
3d32435
Merge branch 'feat-recycle-rn' into feat-sticky-ali
May 28, 2025
55fcfac
Merge branch 'feat-recycle-rn' into feat-recycle-sticky-web
May 28, 2025
e423ba8
chore: 优化sticky-header
May 29, 2025
c9f2aad
chore: 添加轮询修正逻辑
May 29, 2025
bd54ba0
chore: 添加轮询修正逻辑
May 29, 2025
6e2262d
Merge branch 'master' into feat-recycle-rn
Jun 18, 2025
8053a33
Merge branch 'master' into feat-recycle-sticky-web
Jun 18, 2025
bc953eb
Merge branch 'master' into feat-sticky-ali-v2
Jun 20, 2025
69ea628
chore: 优化refresh逻辑
Jun 20, 2025
a178120
chore: 优化handleStickyStateChange逻辑
Jun 20, 2025
358058f
Merge branch 'master' into feat-recycle-rn
Sep 3, 2025
23312fb
chore: cr修改
Sep 5, 2025
2adde6e
refactor: flatlist替换为sectionlist
Sep 16, 2025
5c8cfd7
feat: 拓展组件注册考虑单组件输出
Sep 16, 2025
f6d519e
chore: 修改默认组件样式
Sep 17, 2025
6f10b44
Merge pull request #2224 from didi/feat-recycle-rn-cr
yandadaFreedom Sep 17, 2025
b197c4a
Merge branch 'master' into feat-recycle-rn
Sep 17, 2025
4e83ff6
feat: 新增end-reached-threshold属性
Sep 18, 2025
9d945d8
Merge branch 'feat-recycle-rn' into feat-recycle-sticky-web
Nov 21, 2025
e659668
Merge branch 'master' into feat-recycle-sticky-web
Nov 21, 2025
9ea4fe4
fix: web recycle-view 格式与其他平台拉齐
Nov 21, 2025
6a7d6ba
Merge branch 'feat-recycle-rn' into feat-sticky-ali-v2
Nov 21, 2025
86f0ed8
Merge branch 'feat-recycle-sticky-web' into feat-sticky-ali-v2
Nov 21, 2025
7e604f0
chore: 修改web注册拓展组件逻辑
Nov 24, 2025
d2e1435
Merge branch 'feat-recycle-sticky-web' into feat-sticky-ali-v2
Nov 24, 2025
84d5b03
chore: 优化ali环境recyle-view渲染逻辑
Nov 24, 2025
996ff5d
docs: 补充recycle-view文档
Nov 24, 2025
8705b49
docs: 补充recycle-view文档
Nov 24, 2025
f7bf9cc
docs: 补充recycle-view文档
Nov 24, 2025
186aba6
docs: 补充文档
Dec 1, 2025
1878280
docs: 补充文档
Dec 1, 2025
e331c77
fix: 外层容器定高,recycle-view无法滚动问题
Dec 1, 2025
e975878
Merge branch 'feat-recycle-sticky-web' into feat-sticky-ali-v2
Dec 1, 2025
b9ba9d1
docs: 补充文档
Dec 1, 2025
4eef437
Merge branch 'master' into feat-sticky-ali-v2
Dec 1, 2025
d2afd25
Merge branch 'master' into feat-recycle-rn
Dec 1, 2025
5d48042
fix: lint error
Dec 1, 2025
30bb85d
chore: 修改useListHeader默认值
Dec 1, 2025
15831f6
chore: 修改useListHeader默认值
Dec 1, 2025
71407a0
chore: 修改useListHeader默认值
Dec 1, 2025
5b6f2ca
docs: 补充文档
Dec 1, 2025
e0c4401
docs: 修改文档
Dec 1, 2025
197708c
fix: 动态修改height相关配置,重新触发getItemLayout计算
Jan 12, 2026
87c50a2
fix: sectionList 重新渲染导致list-item、list-header 等组件 销毁并重新创建;
Jan 15, 2026
5b5d2d2
Merge pull request #2404 from didi/feat-sticky-ali-v2-cr
yandadaFreedom Jan 19, 2026
c097ef3
feat: 修复recycle-view组件渲染导致item等组件销毁重建&支持list-footer节点
Jan 22, 2026
5ca823b
fix: conflict;
Jan 22, 2026
1655db9
feat: wx & web支持list-footer节点&支持itemHeight等高度动态变化
Jan 22, 2026
8be6bc2
feat: ali支持list-footer节点&支持itemHeight等高度动态变化
Jan 22, 2026
2388fd4
feat: scrollToIndex 支持 viewOffset参数
Jan 22, 2026
1de2850
refactor: 重构拓展组件引用机制
Jan 23, 2026
c57abd7
feat: 新增通过key复用dom机制,https://
Jan 23, 2026
1a5507f
refactor: 修改sticky相关组件注册机制
Jan 23, 2026
ca7772c
Merge branch 'master' into feat-sticky-ali-v2
Jan 23, 2026
e798421
feat: add defult generics component
Jan 23, 2026
fbe97cf
chore: rename recycle-list
Jan 28, 2026
e491f1b
fix: lint error
Jan 28, 2026
3d4109d
feat: 添加拓展组件占位文件
Feb 2, 2026
71fe3bc
Merge branch 'master' into feat-sticky-ali-v2
Feb 26, 2026
9bdf8c0
Merge branch 'master' into feat-sticky-ali-v2
Mar 10, 2026
a8d9f3a
Merge branch 'master' into feat-sticky-ali-v2
Apr 13, 2026
1bf20f5
feat: sectionList 支持手势协同
Apr 16, 2026
9bc8729
feat: 删除无用组件配置
Apr 16, 2026
4b5a554
feat: 删除无用组件配置
Apr 16, 2026
e4471e4
Merge branch 'feat-sticky-ali-v2' into feat-section-list-gesuture
Apr 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 59 additions & 59 deletions docs-vitepress/api/compile.md

Large diffs are not rendered by default.

254 changes: 254 additions & 0 deletions docs-vitepress/guide/extend/extend-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
# Mpx 扩展组件

除基础组件外,Mpx 额外提供一些扩展组件。扩展组件需要在页面或组件的 `usingComponents` 中注册后使用。

```html
<script type="application/json">
{
"usingComponents": {
"section-list": "@mpxjs/webpack-plugin/lib/runtime/components/extends/section-list"
}
}
</script>
```

Mpx 会根据当前编译的目标平台(wx/ali/web/ios/android/harmony),自动解析到对应平台的扩展组件实现。


## section-list

跨端虚拟列表组件,可自定义分组头、列表头、列表项,自动分段渲染兼容各端。

支持平台:微信小程序、支付宝小程序、Web、RN

### 属性

| 属性名 | 类型 | 默认值 | 说明 | 支持平台 |
|-----------------------|-------------|----------|------------------------|-----------|
| height | String/Number | 100% | 组件高度 | 微信小程序、支付宝小程序、Web、RN |
| width | String/Number | 100% | 组件宽度 | 微信小程序、支付宝小程序、Web、RN |
| listData | Array | [] | 列表数据,如需使用列表分组头 `section-header`,对应 item 的数据需要包含 `isSectionHeader: true` 标识 | 微信小程序、支付宝小程序、Web、RN |
| enable-sticky | Boolean | false | 启用分组吸顶 | 微信小程序、支付宝小程序、Web、RN<br>⚠️微信小程序环境,需要使用 skyline 渲染模式,webview 模式不支持;web 环境仅支持移动端,不支持 pc 端 |
| scroll-with-animation | Boolean | false | 滚动动画 | 微信小程序、支付宝小程序、Web、RN |
| useListHeader | Boolean | false | 使用自定义列表头 | 微信小程序、支付宝小程序、Web、RN |
| listHeaderData | Object | {} | 列表头数据 | 微信小程序、支付宝小程序、Web、RN |
| useListFooter | Boolean | false | 使用自定义列表页脚 | 微信小程序、支付宝小程序、Web、RN |
| listFooterData | Object | {} | 列表头数据 | 微信小程序、支付宝小程序、Web、RN |
| generic:recycle-item | String | | 列表项,抽象节点组件名,对应组件需要通过 usingComponents 注册 | 微信小程序、支付宝小程序、Web、RN |
| generic:section-header | String | | 列表分组头,抽象节点组件名,对应组件需要通过 usingComponents 注册 | 微信小程序、支付宝小程序、Web、RN |
| generic:list-header | String | | 列表头,抽象节点组件名,对应组件需要通过 usingComponents 注册 | 微信小程序、支付宝小程序、Web、RN |
| generic:list-footer | String | | 列表页脚,抽象节点组件名,对应组件需要通过 usingComponents 注册 | 微信小程序、支付宝小程序、Web、RN |
| itemHeight | Object | {} | 列表项高度配置(支持 getter/value),必须配置 | 微信小程序、支付宝小程序、Web、RN |
| sectionHeaderHeight | Object | {} | 分组头部高度配置(getter/value),若使用了自定义分组头必须配置 | 微信小程序、支付宝小程序、Web、RN |
| listHeaderHeight | Object | {} | 列表头部高度配置(getter/value),若使用了列表头必须配置 | 微信小程序、支付宝小程序、Web、RN |
| bufferScale | Number | 1 | 渲染缓冲区行数(虚拟滚动优化) | 仅支付宝小程序/web支持 |
| minRenderCount | Number | 10 | 最小渲染项目数 | 仅支付宝小程序/web支持 |

#### `itemHeight`/`sectionHeaderHeight`/`listHeaderHeight` 格式说明

高度相关属性支持如下格式:

```js
height: {
value: 400, // 定高
getter: function (item, index) {
const seed = item.id % 2 || 0
const heights = [100, 300]
return heights[seed]
}
}
```

**说明:**
- `value`:默认高度(所有项相同高度时直接用 value 即可)。
- `getter`:函数形式,可接收每一项的数据和索引,按需返回不同高度(动态高度需求时使用)。
- `getter` 优先级 大于 value。

> 建议性能要求较高(如超大数据集)优先使用 `value` 定高。

### 事件

| 事件名 | 说明 | 支持平台 |
|-----------------------|-----------------------------------|--------------|
| bindscroll | 滚动时触发,返回滚动信息 | 微信小程序、支付宝小程序、Web、RN |
| bindscrolltolower | 滚动到底部/触底通知 | 微信小程序、支付宝小程序、Web、RN |
| bindscrollToIndex | 组件方法,滚动到指定索引 | 微信小程序、支付宝小程序、Web、RN |

`scrollToIndex({ index, animated, viewPosition })` 参数说明:
- `index`:目标索引
- `animated`:是否滚动动画
- `viewOffset`:滚动偏移量
- `viewPosition`:滚动定位,0:顶部, 0.5:中间, 1:底部

### 用法示例

```js
<section-list
generic:recycle-item="normal-recycle-item"
generic:section-header="section-header"
generic:list-header="list-header"
width="{{width}}"
height="{{height}}"
listData="{{dataList}}"
itemHeight="{{ itemHeight }}"
sectionHeaderHeight="{{headerHeight}}"
listHeaderHeight="{{listHeaderHeight}}"
bufferScale="{{bufferScale}}"
useListHeader="{{true}}"
enable-sticky="{{true}}"
/>
<script>
import mpx, { createPage, createComponent } from '@mpxjs/core'

const generateData = (itemsPerSection) => {
const data = []

for (let i = 0; i < 10; i++) {
data.push({
isSectionHeader: true, // 标识该行使用 section-header 对应的抽象节点渲染
title: `Section ${i + 1}`
})

// 添加该 section 的 items
for (let j = 0; j < itemsPerSection; j++) {
const itemNumber = i * itemsPerSection + j + 1
data.push({
id: itemNumber,
title: `Item ${itemNumber}`,
description: `This is item number ${itemNumber} in section ${i + 1}`
})
}
}
return data
}

createPage({
data: {
width: 0,
height: 0,
bufferScale: 5,
dataList: generateData(100),
itemHeight: {
getter: function (item, index) {
const seed = item.id % 2 || 0
const heights = [100, 300]
return heights[seed]
}
},
headerHeight: {
value: 50
},
listHeaderHeight: {
value: 100
}
},
onLoad() {
this.height = mpx.getWindowInfo().windowHeight
this.width = mpx.getWindowInfo().windowWidth
}
})
</script>
<script type="application/json">
{
"usingComponents": {
"section-list": "@mpxjs/webpack-plugin/lib/runtime/components/extends/section-list",
"normal-recycle-item": "@/components/recycle-item",
"section-header": "@/components/section-header",
"list-header": "@/components/list"
}
}
</script>
```

### 其它说明

- 当使用了列表项、列表头或者自定义分组头,必须配置对应 item/sectionHeader/listHeader 的 height 相关参数,否则会出现滚动异常情况。
- 可直接调用 ref 实例执行 `scrollToIndex` 方法实现滚动。
- 如果用户滑动的速度超过渲染的速度,则会先看到空白的内容,这是为了长列表优化不得不作出的妥协。
- 当某行滑出渲染区域之外后,其内部状态将不会保留。
- 在 RN 环境,section-list 通过 RN 提供的 SectionList 实现分组吸顶。受 RN 底层实现机制限制,开启 `enable-sticky` 且快速滑动时,自定义分组头有时会出现闪烁现象。此问题需要等待 RN 官方修复,我们会持续关注并跟进。
- 若某行需要使用 `section-header` 对应的抽象节点渲染,则该行数据必须包含 `isSectionHeader: true` 字段;否则默认使用 `recycle-item` 对应的抽象节点渲染


## sticky-section

吸顶布局容器,仅支持作为 `<scroll-view>` 的直接子节点

支持平台:微信小程序(仅 skyline 支持)、支付宝小程序、Web、RN

### 用法示例

```html
<template>
<scroll-view>
<sticky-section>
<sticky-header>这是会吸顶的内容</sticky-header>
</sticky-section>
</scroll-view>
</template>

<script type="application/json">
{
"usingComponents": {
"sticky-section": "@mpxjs/webpack-plugin/lib/runtime/components/extends/sticky-section"
}
}
</script>
```


## sticky-header

吸顶头部组件,支持在滚动容器中实现元素吸顶效果。仅支持作为 `<scroll-view>` 的直接子节点或 `sticky-section` 组件直接子节点

支持平台:微信小程序(仅 skyline 支持)、支付宝小程序、Web、RN

### 属性

| 属性名 | 类型 | 默认值 | 说明 | 支持平台 |
|-------|------|--------|------|---------|
| offsetTop | Number | 0 | 吸顶距离顶部的偏移量 | 微信小程序、支付宝小程序、Web、RN |
| padding | Array | - | 内边距配置 [top, right, bottom, left] | 微信小程序、支付宝小程序、Web、RN |
| scrollViewId | String | '' | 滚动容器的 id, 支付宝环境必传, 值与选择器 id 值一致 | 支付宝小程序 |
| stickyId | String | '' | 吸顶元素的唯一标识,支付宝环境必传,值与选择器 id 值一致 | 支付宝小程序 |
| enablePolling | Boolean | false | 启用轮询刷新 | 支付宝小程序 |
| pollingDuration | Number | 300 | 轮询间隔时间(毫秒) | 支付宝小程序 |

### 事件

| 事件名 | 说明 | 支持平台 |
|-------|------|---------|
| stickontopchange | 吸顶状态改变时触发,返回 { isStickOnTop, id } | 微信小程序、支付宝小程序、Web、RN |

**注意**:
- 支付宝小程序中该功能基于 IntersectionObserver 实现,但在支付宝平台上,IntersectionObserver 的回调可能存在触发不及时或不触发的情况,进而导致 stickontopchange 事件无法及时触发,或 sticky-header 吸附位置异常。

为此我们提供了 enablePolling 属性。开启后将通过定时轮询的方式校验 sticky-header 当前吸附状态是否正确,若发现异常会自动进行修正。建议在支付宝平台根据实际情况按需开启该配置。

- RN 环境的 sticky-header 更适用于内容稳定,状态不常变更的场景使用,目前如果 sticky-header 还在动画过程中就触发组件更新(如在bindstickontopchange 回调中立刻更新 state)、scroll-view 内容高度由多变少、通过修改 scroll-into-view、scroll-top 让 scroll-view 滚动,以上场景在安卓上都可能会导致闪烁或抖动


### 用法示例

```html
<template>
<scroll-view id="scrollViewContainer" scroll-y>
<sticky-header
scroll-view-id="scrollViewContainer"
sticky-id="header1"
offset-top="0"
bind:stickontopchange="handleStickyChange">
<view>这是会吸顶的内容</view>
</sticky-header>
</scroll-view>
</template>

<script type="application/json">
{
"usingComponents": {
"sticky-header": "@mpxjs/webpack-plugin/lib/runtime/components/extends/sticky-header"
}
}
</script>
```

30 changes: 1 addition & 29 deletions docs-vitepress/guide/rn/component.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### 目录概览 {#directory-overview}

- #### 基础组件
**容器组件**:[view](#view) · [scroll-view](#scroll-view) · [swiper](#swiper) · [swiper-item](#swiper-item) · [movable-area](#movable-area) · [movable-view](#movable-view) · [root-portal](#root-portal) · [sticky-section](#sticky-section) · [sticky-header](#sticky-header) · [cover-view](#cover-view)
**容器组件**:[view](#view) · [scroll-view](#scroll-view) · [swiper](#swiper) · [swiper-item](#swiper-item) · [movable-area](#movable-area) · [movable-view](#movable-view) · [root-portal](#root-portal) · [cover-view](#cover-view)

**媒体组件**:[image](#image) · [video](#video) · [canvas](#canvas)

Expand Down Expand Up @@ -731,34 +731,6 @@ API
> [!tip] 注意
>
> - style 样式不支持中使用百分比计算、css variable

### sticky-section
吸顶布局容器,仅支持作为 `<scroll-view>` 的直接子节点

> [!tip] 注意
>
> - sticky-section 目前仅支持 RN 、web 以及微信小程序环境,其他环境暂不支持。微信小程序中使用需开启 skyline 渲染模式

### sticky-header
吸顶布局容器,仅支持作为 `<scroll-view>` 的直接子节点或 `sticky-section` 组件直接子节点

属性

| 属性名 | 类型 | 默认值 | 说明 |
| ----------------------- | ------- | ------------- | ---------------------------------------------------------- |
| offset-top | number | `0` | 吸顶时与顶部的距离 |
| padding | array | `[0, 0, 0, 0] ` | 长度为 4 的数组,按 top、right、bottom、left 顺序指定内边距 |

事件

| 事件名 | 说明 |
| ----------------| --------------------------------------------------- |
| bindstickontopchange | 吸顶状态变化事件, `event.detail = { isStickOnTop }`,当 sticky-header 吸顶时为 true,否则为 false |

> [!tip] 注意
>
> - sticky-header 目前仅支持 RN 、web 以及微信小程序环境,其他环境暂不支持。微信小程序中使用需开启 skyline 渲染模式
> - RN 环境的 sticky-header 更适用于内容稳定,状态不常变更的场景使用,目前如果 sticky 还在动画过程中就触发组件更新(如在bindstickontopchange 回调中立刻更新 state)、scroll-view 内容高度由多变少、通过修改 scroll-into-view、scroll-top 让 scroll-view 滚动,以上场景在安卓上都可能会导致闪烁或抖动

### cover-view
视图容器。
Expand Down
3 changes: 3 additions & 0 deletions packages/webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const AddEnvPlugin = require('./resolver/AddEnvPlugin')
const PackageEntryPlugin = require('./resolver/PackageEntryPlugin')
const DynamicRuntimePlugin = require('./resolver/DynamicRuntimePlugin')
const FixDescriptionInfoPlugin = require('./resolver/FixDescriptionInfoPlugin')
const ExtendComponentsPlugin = require('./resolver/ExtendComponentsPlugin')
// const CommonJsRequireDependency = require('webpack/lib/dependencies/CommonJsRequireDependency')
// const HarmonyImportSideEffectDependency = require('webpack/lib/dependencies/HarmonyImportSideEffectDependency')
// const RequireHeaderDependency = require('webpack/lib/dependencies/RequireHeaderDependency')
Expand Down Expand Up @@ -403,6 +404,7 @@ class MpxWebpackPlugin {
const addEnvPlugin = new AddEnvPlugin('before-file', this.options.env, this.options.fileConditionRules, 'file')
const packageEntryPlugin = new PackageEntryPlugin('before-file', this.options.miniNpmPackages, this.options.normalNpmPackages, 'file')
const dynamicPlugin = new DynamicPlugin('result', this.options.dynamicComponentRules)
const extendComponentsPlugin = new ExtendComponentsPlugin('described-resolve', this.options.mode, 'resolve')

if (Array.isArray(compiler.options.resolve.plugins)) {
compiler.options.resolve.plugins.push(addModePlugin)
Expand All @@ -417,6 +419,7 @@ class MpxWebpackPlugin {
}
compiler.options.resolve.plugins.push(packageEntryPlugin)
compiler.options.resolve.plugins.push(new FixDescriptionInfoPlugin())
compiler.options.resolve.plugins.push(extendComponentsPlugin)
compiler.options.resolve.plugins.push(dynamicPlugin)

const optimization = compiler.options.optimization
Expand Down
1 change: 0 additions & 1 deletion packages/webpack-plugin/lib/json-compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ module.exports = function (content) {
const { getRequestString } = createHelpers(this)

let currentName

if (isApp) {
currentName = appInfo.name
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ const label = require('./label')
const wxs = require('./wxs')
const fixComponentName = require('./fix-component-name')
const rootPortal = require('./root-portal')
const stickyHeader = require('./sticky-header')
const stickySection = require('./sticky-section')

module.exports = function getComponentConfigs ({ warn, error }) {
/**
Expand Down Expand Up @@ -125,8 +123,6 @@ module.exports = function getComponentConfigs ({ warn, error }) {
livePusher({ print }),
hyphenTagName({ print }),
label({ print }),
rootPortal({ print }),
stickyHeader({ print }),
stickySection({ print })
rootPortal({ print })
]
}

This file was deleted.

This file was deleted.

Loading
Loading