Skip to main content

Module scroll_area

Module scroll_area 

Source
Expand description

ScrollArea — a clipping viewport that scrolls its content on wheel, on a finger’s pan, and on assistive-technology actions.

Wrap any widget in ScrollArea to make it scrollable. The scroll position is stored in reactive Signal<f32> signals (one per axis), shared with the built-in ScrollBar children. Two display modes cover most use cases: Overlay (the default, macOS-style thin-at-rest indicator that expands on hover) and Permanent (a layout-consuming gutter always on screen). Use ScrollBarPolicy to control when each axis shows.

§Pan to scroll

ScrollArea is the reference adopter of ScrollableBehavior: it declares a both-axis pan claim, so a direct pointer dragging its content is synthesised by the router into a positioned Scroll and delivered along the claimant chain. A release hands its velocity to the tree’s fling driver, whose coast arrives back here as ordinary scroll deltas and stops — and chains outward — at the boundary, exactly as a wheel notch does. A mouse never pans: the wheel is its scroll device, and its behaviour here is unchanged in every particular.

Following the finger past the end is off by default (ScrollArea::rubber_band); a nested area that banded at its own end could never hand the gesture to the container around it.

§Wheel and hover

Shift held over a vertical wheel scrolls the area horizontally when it has horizontal range (ScrollArea::shift_wheel_scrolls_horizontally, on by default). Overlay bars can be shown for as long as the pointer is over the area (ScrollArea::reveal_bars_on_hover, off by default).

§Accessibility

Reports Role::ScrollView with per-axis scroll_y / scroll_x position and limit fields. Advertises ScrollUp / ScrollDown / ScrollLeft / ScrollRight actions only for the axes that actually overflow, so AT clients (NVDA, JAWS, VoiceOver) know which directions are reachable.

let _w = ScrollArea::new()
    .child(MinSize::new(0.0, 2000.0))
    .scroll_bar_style(ScrollBarMode::Permanent)
    .smooth_scrolling(true);

Structs§

ScrollArea
A clipping viewport that makes any child widget scrollable.

Enums§

ScrollBarMode
How the scroll bar is presented relative to the viewport content.
ScrollBarPolicy
Controls when the scroll bar appears for a given axis.