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,
)
| 202 | /// **This is meant to be called in the render body.** It `.read()`s |
| 203 | /// `scroll_offset` and `viewport_size` to subscribe the component. |
| 204 | pub 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 | /// |