pub struct CarouselState { /* private fields */ }Expand description
Retained scroll position for one carousel. Observe the entity to read changes from input, programmatic navigation, or item replacement.
Implementations§
Source§impl CarouselState
impl CarouselState
Sourcepub fn new(initial_index: usize) -> CarouselState
pub fn new(initial_index: usize) -> CarouselState
Starts at the given index when the first items are available.
Sourcepub fn current_item(&self) -> Option<usize>
pub fn current_item(&self) -> Option<usize>
Returns the item nearest the keyline, or no index when empty.
Sourcepub fn current_item_id(&self) -> Option<&SharedString>
pub fn current_item_id(&self) -> Option<&SharedString>
Returns the stable ID of the item nearest the keyline.
Sourcepub fn current_item_offset_fraction(&self) -> f32
pub fn current_item_offset_fraction(&self) -> f32
Signed displacement from the nearest keyline in item units.
Sourcepub fn scroll_to_item(
&mut self,
index: usize,
cx: &mut Context<'_, CarouselState>,
)
pub fn scroll_to_item( &mut self, index: usize, cx: &mut Context<'_, CarouselState>, )
Immediately positions the carousel at the clamped index.
Sourcepub fn animate_scroll_to_item(
&mut self,
index: usize,
cx: &mut Context<'_, CarouselState>,
)
pub fn animate_scroll_to_item( &mut self, index: usize, cx: &mut Context<'_, CarouselState>, )
Moves to the clamped index using the window’s motion policy.
Auto Trait Implementations§
impl !RefUnwindSafe for CarouselState
impl !Send for CarouselState
impl !Sync for CarouselState
impl !UnwindSafe for CarouselState
impl Forget for CarouselState
impl Freeze for CarouselState
impl Move for CarouselState
impl Unpin for CarouselState
impl UnsafeUnpin for CarouselState
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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