pub fn virtual_stack<T, IF, I, KF, K, VF, V>(
each_fn: IF,
key_fn: KF,
view_fn: VF,
) -> VirtualStack<T>Expand description
A View that is like a dyn_stack but also lazily loads the items as they appear in a scroll view
This virtualization/lazy loading is done for performance and allows for lists of millions of items to be used with very high performance.
By default, this view tries to calculate and assume the size of the items in the list by calculating the size of the first item that is loaded.
If all of your items are not of a consistent size in the relevant axis (ie a consistent width when flex_row or a consistent height when in flex_col) you will need to specify the size of the items using item_size_fixed or item_size_fn.
ยงExample
use floem::prelude::*;
VirtualStack::new(move || 1..=1000000)
.style(|s| {
s.flex_col().class(LabelClass, |s| {
// give each of the numbers some vertical padding and make them take up the full width of the stack
s.padding_vert(2.5).width_full().justify_center()
})
})
.scroll()
.style(|s| s.size(200., 500.).border(1.0))
.container()
.style(|s| {
s.size_full()
.items_center()
.justify_center()
});