pub struct ScrollState { /* private fields */ }Expand description
Re-export the UI crate so applications can depend on a single crate. 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) -> ScrollState
pub fn new(initial: f32) -> ScrollState
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 moreAuto 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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.