feat(cdk/scrolling): Integrate Pretext Library for Precise Text Measurement in Auto-Size Virtual Scroll
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 静か
- 技術スタック
- angular, typescript
- 領域
- frontend, performance
調査の方向性
AutoSizeVirtualScrollStrategy とその ItemSizeAverager から始め、次に提案されている Pretext の prepare() API と layout() API、およびテキスト量の多い項目と複雑なレイアウトの違いを確認します。正確なサイズ計測をリグレッションなしで示すために、統合範囲、フォールバック動作、必要な検証を定義します。
索引モデルが issue の本文から書いたものです。
説明
Feature Description
Description:
Problem Statement
The current AutoSizeVirtualScrollStrategy implementation relies on ItemSizeAverager to estimate the size of unseen items based on historical measurements. While this approach works for many scenarios, it has several limitations:
- Reflow overhead: Must render elements first before measuring, triggering expensive layout reflows
- Inaccurate predictions: Averaging-based estimation can be imprecise for heterogeneous content, especially variable-height text items
- Performance bottlenecks: Frequent DOM measurements during scrolling impact performance
- Layout shifts: Predictive scrolling may cause visual jumps when estimated sizes differ significantly from actual sizes
Proposed Solution
I'd like to propose integrating the Pretext library (https://github.com/chenglou/pretext) into the auto-size virtual scroll strategy. Pretext is a pure JavaScript/TypeScript library that provides:
- Accurate text measurement without DOM: Calculates text dimensions using pure arithmetic, avoiding
getBoundingClientRectandoffsetHeight - Excellent performance: Benchmarks show
layout()operations at ~0.09ms for 500 texts (hot path) - Comprehensive language support: Handles all languages, emojis, and mixed-bidi text correctly
- Predictive sizing: Enables pre-rendering size calculations for virtual lists
Implementation Ideas
The integration could work as follows:
-
For text-heavy virtual lists:
- When items contain primarily text content with known font/line-height configurations
- Use Pretext's
prepare()+layout()API to calculate heights before rendering - This allows the scroll strategy to know exact item sizes upfront
-
Hybrid approach:
- Use Pretext for text content measurement
- Fall back to current DOM measurement for non-text or complex layouts
- Combine both for maximum accuracy
-
Performance optimization:
- Cache
PreparedTextobjects for reuse during resize events - Only re-run
layout()(the cheap 0.09ms operation) when container width changes
- Cache
Benefits
- Eliminates layout reflow for text measurement in virtual lists
- More accurate scrolling behavior with predictable item sizes
- Better performance especially for long lists with variable-height text items
- Reduced visual jumps during scrolling since sizes are pre-calculated
- Support for all languages and scripts including complex layouts
Example Use Case
- Chat applications with varying message lengths.
- Feeds/Dashboards with dynamic text content.
Use Case
No response
- 主要言語
- TypeScript
- スター
- 25k
- フォーク
- 6.8k
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 84
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
angular/components のほかの issue
-
area: material/tree docs gemini-triaged needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
angular/components#33832 ·
-
area: material/datepicker gemini-triaged P4
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
angular/components#33763 · コメント 2 件 · リアクション 3 件 ·
-
area: material/table gemini-triaged P4
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
angular/components#33709 · コメント 1 件 ·
-
area: material/table docs gemini-triaged P4
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
angular/components#33455 ·
-
area: material/core gemini-triaged P3
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
angular/components#33059 · コメント 2 件 ·
angular/components の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
security
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
IBM/node-sdk-core#373 ·
-
e2e-failure ready-to-code
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
chore
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100