pub struct ScrollState { /* private fields */ }Implementations§
Source§impl ScrollState
impl ScrollState
pub fn new() -> Self
pub fn viewport_size(&self) -> Size
pub fn content_size(&self) -> Size
pub fn current_offset(&self) -> Vector
pub fn max_offset(&self) -> Vector
Sourcepub fn set_offset(&self, offset: Vector) -> bool
pub fn set_offset(&self, offset: Vector) -> bool
Updates the shared scroll offset, clamped to the current viewport and content metrics. Returns whether the effective offset changed.
Widgets bound to this state observe the new offset on their next layout pass; event handlers should request the corresponding invalidation.
Sourcepub fn scroll_to_item(&self, index: usize) -> bool
pub fn scroll_to_item(&self, index: usize) -> bool
Queues a virtual-scroll item to align with the viewport start on the next layout pass. Returns whether the pending request changed.
Resolving the request during layout keeps the target aligned with the item’s latest measured position, including requests made before the first render.
Sourcepub fn scroll_to_item_with_ctx(&self, index: usize, ctx: &mut EventCtx) -> bool
pub fn scroll_to_item_with_ctx(&self, index: usize, ctx: &mut EventCtx) -> bool
Queues a virtual-scroll item and invalidates the bound viewport so the jump is laid out and repainted in the frame requested by an event.
Sourcepub fn virtual_item_at(&self, y: f32) -> Option<usize>
pub fn virtual_item_at(&self, y: f32) -> Option<usize>
Index of the virtual-scroll item whose extent contains the content
offset y, measured from the top of the scrolled content. Offsets past
the last item resolve to the last item; returns None before the bound
VirtualScrollView has been laid out or when it has no items.
Scroll-spy navigation compares this against the current offset, for
example virtual_item_at(current_offset().y + threshold).
Sourcepub fn first_visible_item(&self) -> Option<usize>
pub fn first_visible_item(&self) -> Option<usize>
Index of the virtual-scroll item at the top edge of the viewport.
Sourcepub fn virtual_item_offset(&self, index: usize) -> Option<f32>
pub fn virtual_item_offset(&self, index: usize) -> Option<f32>
Content-space top of a virtual-scroll item from the latest layout.