37 Dynamic Virtual Measurement. 37 of 95.

37/SCROLL BEHAVIOR/37 of 95

Dynamic Virtual Measurement

Row height may not be known until rendered.

The problem

Variable-height rows clipped or gapped because the virtualizer assumed a fixed size for every item.

The solution

Dynamic measurement updates row size estimates as content is rendered.

Experiment

Play with the values

48px
2

How it works

  • Rows that have not been rendered yet get an estimated height so the scrollbar can exist.
  • Only the visible window, plus a little overscan, is actually rendered.
  • Once a row is on screen, its real height is measured.
  • The size cache replaces the estimate for that row.
  • The offset table is rebuilt so later rows start at the correct scroll position.

Seen in

Chat threads

Messages of uneven length need measured heights so scroll position stays accurate.

Feeds

Cards with images and wrapped text update estimates once each card mounts.

Email lists

Preview snippets of different lengths pack correctly after first paint.

Comment trees

Nested replies of varying depth measure after expand so the scrollbar stays honest.

References