dynamic_measurement/
dynamic_measurement.rs1use virtualizer::{Align, Virtualizer, VirtualizerOptions};
3
4fn main() {
5 let mut v = Virtualizer::new(VirtualizerOptions::new(100, |_| 10));
7 v.set_viewport_and_scroll_clamped(30, 200);
8
9 println!(
10 "before: off={} total={} range={:?}",
11 v.scroll_offset(),
12 v.total_size(),
13 v.virtual_range()
14 );
15
16 let applied = v.resize_item(0, 30);
19 println!(
20 "resize_item(0): applied_delta={applied} off={} total={}",
21 v.scroll_offset(),
22 v.total_size()
23 );
24
25 v.measure(1, 50);
27 println!(
28 "measure(1): off={} total={}",
29 v.scroll_offset(),
30 v.total_size()
31 );
32
33 v.measure_unadjusted(2, 30);
35
36 let to = v.scroll_to_index_offset(10, Align::Start);
38 v.set_scroll_offset_clamped(to);
39 println!(
40 "set_scroll_offset_clamped(scroll_to_index_offset(10)): off={} range={:?}",
41 v.scroll_offset(),
42 v.virtual_range()
43 );
44}