pub struct LayoutScrollArea { /* private fields */ }Implementations§
Source§impl LayoutScrollArea
impl LayoutScrollArea
pub fn new( layout_style: LayoutStyle, content: Box<dyn LayoutItem>, ) -> Result<Self, LayoutError>
Sourcepub fn new_with<F>(
layout_style: LayoutStyle,
build: F,
) -> Result<Self, LayoutError>
pub fn new_with<F>( layout_style: LayoutStyle, build: F, ) -> Result<Self, LayoutError>
Like new, but the content is built with access to this scroll’s live
ScrollViewport, so descendants can gate work (e.g. lazy asset loading) on whether they are
currently on screen. The offset/viewport signals are created BEFORE build runs, so the content
it returns can capture them — resolving the ordering bind where the scroll is built from its own
content yet the content needs the scroll’s signals.
Sourcepub fn new_kept<F>(
key: &'static str,
layout_style: LayoutStyle,
build: F,
) -> Result<Self, LayoutError>
pub fn new_kept<F>( key: &'static str, layout_style: LayoutStyle, build: F, ) -> Result<Self, LayoutError>
A scroll area whose position the surface keeps under key, so it survives a rebuild of the tree.
The usual spelling of new_keeping: a remounted view — a shell following a
config edit, a page rebuilt under the same window — reopens where the reader left it instead of
snapping to the top. key names this viewport among everything else the surface keeps, so two scroll
areas on one surface need two keys (see kept).
Sourcepub fn new_keeping<F>(
layout_style: LayoutStyle,
offset: (RwSignal<f32>, RwSignal<f32>),
build: F,
) -> Result<Self, LayoutError>
pub fn new_keeping<F>( layout_style: LayoutStyle, offset: (RwSignal<f32>, RwSignal<f32>), build: F, ) -> Result<Self, LayoutError>
Like new_with, but against offset signals the caller owns — so the scroll
position can outlive this widget.
For a tree that is rebuilt while its surface stays (a shell following a config edit, a view remounted
under the same window): a scroll area built with fresh signals starts at the top every time, which
reads as the list jumping back under the reader’s hands. Hand it the same pair on every build and the
view is where they left it. new_kept is this with the surface holding the pair.
Sourcepub fn scroll_offset(&self) -> (ReadSignal<f32>, ReadSignal<f32>)
pub fn scroll_offset(&self) -> (ReadSignal<f32>, ReadSignal<f32>)
The live scroll offset (x, y) signals, for a caller that constructed the scroll via
new and wants to read the offset after the fact.
pub fn scrollbar_style(self, style: ScrollbarStyle) -> Self
pub fn clamp_scroll(&mut self)
Sourcepub fn scroll_to_top(&mut self)
pub fn scroll_to_top(&mut self)
Resets the scroll offset to the top-left, e.g. when swapping the content shown in the viewport.