pub struct VirtualScrollState { /* private fields */ }Expand description
State for virtual scrolling of a list.
Implementations§
Source§impl VirtualScrollState
impl VirtualScrollState
Sourcepub fn new(total_items: usize, item_height: ItemHeight) -> Self
pub fn new(total_items: usize, item_height: ItemHeight) -> Self
Creates a new virtual scroll state.
Sourcepub fn with_config(
total_items: usize,
item_height: ItemHeight,
config: VirtualScrollConfig,
) -> Self
pub fn with_config( total_items: usize, item_height: ItemHeight, config: VirtualScrollConfig, ) -> Self
Creates a new virtual scroll state with configuration.
Sourcepub fn set_container(&mut self, node: NodeId)
pub fn set_container(&mut self, node: NodeId)
Sets the container node for the scroll content.
Sourcepub fn set_total_items(&mut self, count: usize)
pub fn set_total_items(&mut self, count: usize)
Updates the total number of items.
Sourcepub fn total_items(&self) -> usize
pub fn total_items(&self) -> usize
Gets the total number of items.
Sourcepub fn set_viewport_height(&mut self, height: f32)
pub fn set_viewport_height(&mut self, height: f32)
Updates the viewport height.
Sourcepub fn viewport_height(&self) -> f32
pub fn viewport_height(&self) -> f32
Gets the viewport height.
Sourcepub fn total_height(&self) -> f32
pub fn total_height(&self) -> f32
Calculates the total scroll height.
Sourcepub fn max_scroll_offset(&self) -> f32
pub fn max_scroll_offset(&self) -> f32
Gets the maximum scroll offset.
Sourcepub fn scroll_offset(&self) -> f32
pub fn scroll_offset(&self) -> f32
Gets the current scroll offset.
Sourcepub fn set_scroll_offset(&mut self, offset: f32)
pub fn set_scroll_offset(&mut self, offset: f32)
Sets the scroll offset directly.
Sourcepub fn scroll_to_item(&mut self, index: usize)
pub fn scroll_to_item(&mut self, index: usize)
Scrolls to show a specific item.
Sourcepub fn scroll_to_item_centered(&mut self, index: usize)
pub fn scroll_to_item_centered(&mut self, index: usize)
Scrolls to center a specific item in the viewport.
Sourcepub fn get_item_offset(&self, index: usize) -> f32
pub fn get_item_offset(&self, index: usize) -> f32
Gets the Y offset for an item at the given index.
Sourcepub fn get_item_at_position(&self, y: f32) -> Option<usize>
pub fn get_item_at_position(&self, y: f32) -> Option<usize>
Gets the item index at a given Y position.
Sourcepub fn update_animation(&mut self, dt: f32) -> bool
pub fn update_animation(&mut self, dt: f32) -> bool
Updates smooth scrolling animation. Returns true if the scroll position changed.
Sourcepub fn calculate_visible_range(&self) -> Range<usize>
pub fn calculate_visible_range(&self) -> Range<usize>
Calculates the visible range based on current scroll position.
Sourcepub fn update_visible(&mut self) -> (Vec<usize>, Vec<usize>)
pub fn update_visible(&mut self) -> (Vec<usize>, Vec<usize>)
Updates the visible range and returns items that need to be mounted/unmounted. Returns (items_to_mount, items_to_unmount).
Sourcepub fn mount_item(&mut self, index: usize, node_id: NodeId, height: f32)
pub fn mount_item(&mut self, index: usize, node_id: NodeId, height: f32)
Records a mounted item.
Sourcepub fn unmount_item(&mut self, index: usize) -> Option<NodeId>
pub fn unmount_item(&mut self, index: usize) -> Option<NodeId>
Unmounts an item and returns its node ID.
Sourcepub fn get_mounted(&self, index: usize) -> Option<&MountedItem>
pub fn get_mounted(&self, index: usize) -> Option<&MountedItem>
Gets the mounted item for an index.
Sourcepub fn mounted_items(&self) -> impl Iterator<Item = (usize, &MountedItem)>
pub fn mounted_items(&self) -> impl Iterator<Item = (usize, &MountedItem)>
Gets all mounted items.
Sourcepub fn visible_range(&self) -> Range<usize>
pub fn visible_range(&self) -> Range<usize>
Gets the current visible range.
Sourcepub fn is_visible(&self, index: usize) -> bool
pub fn is_visible(&self, index: usize) -> bool
Checks if an index is in the visible range.
Sourcepub fn stats(&self) -> &VirtualScrollStats
pub fn stats(&self) -> &VirtualScrollStats
Gets statistics about the virtual scroll.
Sourcepub fn update_stats(&mut self)
pub fn update_stats(&mut self)
Updates statistics.
Sourcepub fn config(&self) -> &VirtualScrollConfig
pub fn config(&self) -> &VirtualScrollConfig
Gets the configuration.
Sourcepub fn config_mut(&mut self) -> &mut VirtualScrollConfig
pub fn config_mut(&mut self) -> &mut VirtualScrollConfig
Gets mutable configuration.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VirtualScrollState
impl RefUnwindSafe for VirtualScrollState
impl Send for VirtualScrollState
impl Sync for VirtualScrollState
impl Unpin for VirtualScrollState
impl UnsafeUnpin for VirtualScrollState
impl UnwindSafe for VirtualScrollState
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> 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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
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