Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

feat(virtual-scroll): Add dynamic fixed size virtual scroll strategy

未关闭
#33,045 2 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
angular, typescript
领域
frontend

调研方向

首先查看当前的固定大小虚拟滚动策略和实验性的 cdk autoSize 策略,然后运行链接的 StackBlitz 示例。当某个策略接受一个将索引映射到像素大小的函数,并支持固定、可变、间距、内边距以及可展开或可折叠的项目大小时,工作即完成。

由索引模型根据 Issue 内容生成。

描述

area: cdk/scrolling feature gemini-triaged P3
Feature Description

Currently the provided virtual scroll strategy is only for fixed size. This is very restrictive.
In cdk experimental there is an autoSize strategy that determines the size of an item automatically but it is experimental and decides the size by itself.
I propose a new strategy for fixed, known but dynamic size.
For example if I have a list of items with some items being with 50px height and some with 80px height I can't use any default strategy for it but I also don't need autoSize. I know item 3 is 80px but item 6 is 50px which makes it easier to implement.
Using the new strategy I can express the dynamic (but known) size.
An example API for it is passing a function: (index: number) => number that returns a pixel size based on given item index.
One of the benefits is that fixed size is a specific case of the new strategy with the function returning the same size always (with a bit of worse performance) - so no need to create two default strategies as fixed (the current one) can be derived from the new strategy.
I created a stackblitz with such strategy and some use cases:
https://stackblitz.com/edit/stackblitz-starters-eey1ve9m

Use Case
  1. Can be used for fixed size like now
  2. Can be used to add gap between items
  3. Can be used to add padding (top/bottom) - although there are other ways to do it currently
  4. Can be used to express varying sizes (80px and 50px mixed for example)
  5. Can be used to allow expand/collapse items for details - initial size for index X is 50px. On click increase size to 80px and refresh strategy. Same for collapse but the other way around.
  6. Can be a mix of all the above

To summarize it gives a lot of control for many use cases including the fixed size that exists today.

主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 1 小时
30 天内合并 PR
84

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

angular/components 的其他 Issue

查看 angular/components 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。