Fusuma

Components / Lists and updates

virtual_rows

A list of count rows, each row_h pixels high, with pool row boxes (the rows that show, plus two: height / row_h + 2), and the view of row i from row(i).

Try it

This is the Long list page of the gallery, running in your browser: virtual_rows is on it, and it is the real widget. Press Run, then use it.

Live: Long list, where virtual_rows is usedOpen full size

Also on this pageshow

A list of count rows, each row_h pixels high, with pool row boxes (the rows that show, plus two: height / row_h + 2), and the view of row i from row(i).

Rows of your own views instead of a line of text. .heights(f) gives rows of different heights.

Signature

pub const fn virtual_rows<M, V, F: Fn(usize) -> V>( count: usize, row_h: u32, pool: usize, row: F, ) -> VirtualRows<M, F>

Methods

  • .heights(height: fn(usize) -> u32) -> Self — Rows of different heights: height(i) is the height of row i in pixels (row_h is then only the guess the pool is sized for, so size the pool for the shortest row).
  • .height(height: Length) -> Self — The list's height, which has to be fixed or filling (see VirtualList::height).

Example

use fusuma::{Length, text, virtual_rows};
let view = virtual_rows(1000, 32, 6, |i| text(if i % 2 == 0 { "even" } else { "odd" })).height(Length::Fixed(96));
let built = fusuma::doc::built::<(), _>(&view);
assert!(built.nodes() < 40, "a thousand rows, a few nodes");

All components · Source