MCPcopy Create free account
hub / github.com/DioxusLabs/dioxus-components / get_virtual_items

Function get_virtual_items

primitives/src/virtual/virtualizer.rs:204–221  ·  view source on GitHub ↗

Return the virtual items to render. This is meant to be called in the render body.** It `.read()`s `scroll_offset` and `viewport_size` to subscribe the component.

(
    state: &Store<VirtualizerState>,
    measurements: &[VirtualItem],
    overscan: usize,
)

Source from the content-addressed store, hash-verified

202/// **This is meant to be called in the render body.** It `.read()`s
203/// `scroll_offset` and `viewport_size` to subscribe the component.
204pub fn get_virtual_items(
205 state: &Store<VirtualizerState>,
206 measurements: &[VirtualItem],
207 overscan: usize,
208) -> Vec<VirtualItem> {
209 let range = match calculate_range(state, measurements) {
210 Some(r) => r,
211 None => return Vec::new(),
212 };
213
214 let count = measurements.len();
215 let indexes = default_range_extractor(range, overscan, count);
216
217 indexes
218 .into_iter()
219 .filter_map(|i| measurements.get(i).cloned())
220 .collect()
221}
222
223/// Return the total scrollable size.
224///

Calls 2

calculate_rangeFunction · 0.85
default_range_extractorFunction · 0.85