pub struct ScrollViewport { /* private fields */ }Expand description
A handle to the enclosing scroll area’s live viewport, handed to the content builder by
LayoutScrollArea::new_with. Because a scroll area lays its content out as its OWN layout root,
every descendant’s tracked rect is already in the same content-local space the scroll offset
indexes into — so visible is a plain rect overlap, no scroll-transform math.
Implementations§
Source§impl ScrollViewport
impl ScrollViewport
Sourcepub fn offset(&self) -> (ReadSignal<f32>, ReadSignal<f32>)
pub fn offset(&self) -> (ReadSignal<f32>, ReadSignal<f32>)
The live scroll offset (x, y) in content-local px.
Sourcepub fn reveal(&self, item: NodeId, margin: f32)
pub fn reveal(&self, item: NodeId, margin: f32)
Scrolls the minimum distance needed to bring item fully into view, leaving margin px of breathing
room at whichever edge it entered from. A no-op when the item is already visible.
This is what keyboard navigation needs and what a scroll offset alone cannot express: moving a selection
down a list should follow it, without yanking the view when the item was on screen all along. item must
be a node inside this scroll’s content, so its tracked rect shares the content-local space the offset
indexes into.
Sourcepub fn rect(&self) -> ReadSignal<Rect>
pub fn rect(&self) -> ReadSignal<Rect>
The live viewport rect; its width/height are the visible window’s size.
Sourcepub fn scroll_to_top(&self)
pub fn scroll_to_top(&self)
Puts the view back at the top-left.
For content that has been replaced rather than resized — a page swapped for another one — which is the one thing the scroll area cannot tell on its own: a shorter page is clamped back into range automatically, but only the caller knows that what is in the viewport is now a different thing, and that being three screens down someone else’s page is not where the reader left off.
peek for the same reason as reveal, and this is where it bites hardest: “the page
changed” is noticed by an effect, so a reactive read of the offset would make every wheel tick re-run
the effect that puts the offset back — the viewport pinned to the top for good.
Trait Implementations§
Source§impl Clone for ScrollViewport
impl Clone for ScrollViewport
Source§fn clone(&self) -> ScrollViewport
fn clone(&self) -> ScrollViewport
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more