pub struct ScrollState { /* private fields */ }Expand description
State object for scroll position tracking.
Holds the current scroll offset and provides methods to programmatically
control scrolling. Can be created with rememberScrollState().
This is a pure scroll model - it does NOT store ephemeral gesture/pointer state. Gesture state is managed locally in the scroll modifier.
Implementations§
Source§impl ScrollState
impl ScrollState
Sourcepub fn new(initial: f32) -> Self
pub fn new(initial: f32) -> Self
Creates a new ScrollState with the given initial scroll position.
Sourcepub fn value(&self) -> f32
pub fn value(&self) -> f32
Gets the current scroll position in pixels (reactive - triggers recomposition).
Use this in Composable functions when you want UI to update on scroll.
Example: Text("Scroll position: ${scrollState.value()}")
Sourcepub fn value_non_reactive(&self) -> f32
pub fn value_non_reactive(&self) -> f32
Gets the current scroll position in pixels (non-reactive).
Use this in layout/measure phase to avoid triggering recomposition. This is called internally by ScrollNode::measure().
Sourcepub fn dispatch_raw_delta(&self, delta: f32) -> f32
pub fn dispatch_raw_delta(&self, delta: f32) -> f32
Scrolls by the given delta, clamping to valid range [0, max_value]. Returns the actual amount scrolled.
Trait Implementations§
Source§impl Clone for ScrollState
impl Clone for ScrollState
Source§fn clone(&self) -> ScrollState
fn clone(&self) -> ScrollState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more