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 set_settle_policy(&self, policy: Option<ScrollSettlePolicy>)
pub fn set_settle_policy(&self, policy: Option<ScrollSettlePolicy>)
Installs (or clears) the settle policy consulted when interactions end.
Sourcepub fn settle_policy(&self) -> Option<ScrollSettlePolicy>
pub fn settle_policy(&self) -> Option<ScrollSettlePolicy>
The currently installed settle policy, if any.
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.
Sourcepub fn viewport_extent(&self) -> f32
pub fn viewport_extent(&self) -> f32
The main-axis extent of the scroll viewport, as the last measure pass resolved it.
Sourcepub fn content_extent(&self) -> f32
pub fn content_extent(&self) -> f32
The whole scrollable content along the main axis.
Sourcepub fn metrics(&self) -> ScrollMetrics
pub fn metrics(&self) -> ScrollMetrics
Everything an indicator needs about this scroll, read together so it cannot mix a position from one frame with an extent from another.
Read outside composition — during draw, or from a gesture — so following a scroll costs no recomposition.
Trait Implementations§
Source§impl Clone for ScrollState
impl Clone for ScrollState
impl Copy for ScrollState
Auto Trait Implementations§
impl Freeze for ScrollState
impl RefUnwindSafe for ScrollState
impl Send for ScrollState
impl Sync for ScrollState
impl Unpin for ScrollState
impl UnsafeUnpin for ScrollState
impl UnwindSafe for ScrollState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more