Skip to content

feat(rolling): 实现滚动组件的无缝循环播放功能#1561

Draft
laoshuikaixue wants to merge 14 commits intoClassIsland:masterfrom
laoshuikaixue:feat/rolling-infinite-scroll
Draft

feat(rolling): 实现滚动组件的无缝循环播放功能#1561
laoshuikaixue wants to merge 14 commits intoClassIsland:masterfrom
laoshuikaixue:feat/rolling-infinite-scroll

Conversation

@laoshuikaixue
Copy link
Copy Markdown
Contributor

  • 将 Grid 布局替换为 StackPanel,添加水平间距设置
  • 增加 ItemsControlContainerCopy 副本容器,实现无缝滚动效果
  • 修改滚动动画逻辑,计算总宽度时包含间距
  • 优化动画关键帧,支持停顿偏移和循环播放
  • 添加尺寸变化检测优化,避免重复计算
  • 更新组件样式和布局结构

检查清单

  • 我已经在本地测试过这个 PR,确保欲实现的功能或修复的问题能正常工作。

- 将 Grid 布局替换为 StackPanel,添加水平间距设置
- 增加 ItemsControlContainerCopy 副本容器,实现无缝滚动效果
- 修改滚动动画逻辑,计算总宽度时包含间距
- 优化动画关键帧,支持停顿偏移和循环播放
- 添加尺寸变化检测优化,避免重复计算
- 更新组件样式和布局结构
@laoshuikaixue laoshuikaixue requested review from a team and HelloWRC as code owners December 27, 2025 13:38
@laoshuikaixue
Copy link
Copy Markdown
Contributor Author

解决了滚动末尾留白过大的问题,并实现了首尾相接的无缝滚动效果 与1.x版本逻辑一致

MyVideo_1.mp4

Copy link
Copy Markdown
Member

@HelloWRC HelloWRC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不应考虑使用这种模式实现无缝滚动。因为如果添加了可能随机显示内容的组件(如随机模式的轮播组件或 ExtraIsland 的一言组件),这个动画就会因为两个组件显示的内容不同而露馅。并且同时初始化两份组件也会带来一定的性能负担。

laoshuikaixue and others added 2 commits December 28, 2025 10:45
- 移除旧的 ItemsControlContainerCopy 边框和 ItemsControl
- 添加 Rectangle 作为 ItemsControlContainerMirror 实现镜像效果
- 使用 VisualBrush 创建容器的视觉镜像
@laoshuikaixue laoshuikaixue marked this pull request as draft December 28, 2025 04:06
laoshuikaixue and others added 3 commits January 1, 2026 12:30
- 将 StackPanel 替换为 Grid 布局以支持更灵活的排列
- 添加 ColumnDefinitions 属性定义自动和固定列宽
- 为 GridScrollContainer 添加高度绑定以匹配容器高度
- 将 ItemsControlContainerMirror 移至 Grid 的第二列
- 为 ItemsControlContainerMirror 添加高度绑定以匹配容器高度
- 完善布局结构提升组件渲染性能
- 将ClipToBounds属性从False更改为True
- 添加RenderOptions.BitmapInterpolationMode设置为LowQuality
- 添加RenderOptions.EdgeMode设置为Aliased
@laoshuikaixue laoshuikaixue marked this pull request as ready for review January 1, 2026 04:58
@laoshuikaixue
Copy link
Copy Markdown
Contributor Author

不应考虑使用这种模式实现无缝滚动。因为如果添加了可能随机显示内容的组件(如随机模式的轮播组件或 ExtraIsland 的一言组件),这个动画就会因为两个组件显示的内容不同而露馅。并且同时初始化两份组件也会带来一定的性能负担。

已修改,使用了 VisualBrush 来实现镜像

Copy link
Copy Markdown
Member

@HelloWRC HelloWRC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

根据测试,在滚动尽头的镜像矩形没有按预期显示。请修复此问题,使其能按预期工作。

20260101-0530-28.6796298.mp4

Comment on lines +22 to +23
RenderOptions.BitmapInterpolationMode="LowQuality"
RenderOptions.EdgeMode="Aliased"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在这里指定渲染质量是基于什么目的?这样可能会降低渲染质量,如非必要,最好不要在这里添加这类设置。

@HelloWRC
Copy link
Copy Markdown
Member

HelloWRC commented Jan 1, 2026

注意到在重新加载此组件后,镜像矩形的内容更新了。可能是 VisualBrush 未及时更新导致的这个问题。

laoshuikaixue and others added 2 commits January 1, 2026 13:52
- 移除RenderOptions的低质量设置以改善渲染效果
- 修复ItemsControl的Height绑定以确保正确显示
- 简化VisualBrush的配置参数
@laoshuikaixue
Copy link
Copy Markdown
Contributor Author

根据测试,在滚动尽头的镜像矩形没有按预期显示。请修复此问题,使其能按预期工作。

20260101-0530-28.6796298.mp4

export-1767246983419.mp4

@laoshuikaixue laoshuikaixue requested a review from HelloWRC January 1, 2026 05:57
Copy link
Copy Markdown
Member

@HelloWRC HelloWRC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20260101-1349-39.5026392.mp4

事实上 VisualBrush 没更新这个问题还是没有被根治……

这个主要是 Avalonia 的 VisualBrush 不是实时更新的,如果要实现像 wpf 那样的实时更新效果,可能要下一番功夫再合适的时机使用一些方法触发笔刷更新才行,这也是为什么我一开始移植的时候放弃了这个实现思路。

@laoshuikaixue laoshuikaixue marked this pull request as draft January 2, 2026 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants