pub struct LazyListController { /* private fields */ }Expand description
Persistent state for lazy list components.
This controller holds both the scroll position (ScrollableController)
and the item measurement cache. When retained across navigation (via
retain or retain_with_key), both the scroll position and cached
measurements will be preserved, ensuring correct layout when remounting.
§Examples
use tessera_components::lazy_list::{LazyListController, lazy_column};
use tessera_ui::{LayoutResult, retain_with_key, tessera};
#[tessera]
fn scrollable_page(page_id: String) {
// Both scroll position and measurement cache persist across navigation
let controller = retain_with_key(page_id.clone(), LazyListController::new);
lazy_column().controller(controller).items(100, |i| {
let _ = i;
});
}Implementations§
Source§impl LazyListController
impl LazyListController
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new lazy list controller with default scroll position and empty cache.
Sourcepub fn scroll_controller(&self) -> &ScrollableController
pub fn scroll_controller(&self) -> &ScrollableController
Returns a reference to the underlying scroll controller.
Sourcepub fn scroll_controller_mut(&mut self) -> &mut ScrollableController
pub fn scroll_controller_mut(&mut self) -> &mut ScrollableController
Returns a mutable reference to the underlying scroll controller.
Sourcepub fn scroll_to(&mut self, x: Dp, y: Dp)
pub fn scroll_to(&mut self, x: Dp, y: Dp)
Scrolls to content offsets from the start of each axis, in logical pixels.
The request is applied once when the list next builds. Subsequent wheel and drag input continues from that position.
Sourcepub fn scroll_to_item(&mut self, index: usize, offset: Dp)
pub fn scroll_to_item(&mut self, index: usize, offset: Dp)
Reveals an item at an offset from the viewport start.
Earlier unmeasured items use the list estimate. The requested item is composed and measured before its final visible placement is published. Requests outside the current item range are ignored. Later wheel input continues from the request rather than being overwritten by it.
§Panics
Panics if offset is not finite.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LazyListController
impl RefUnwindSafe for LazyListController
impl Send for LazyListController
impl Sync for LazyListController
impl Unpin for LazyListController
impl UnsafeUnpin for LazyListController
impl UnwindSafe for LazyListController
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§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>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§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.§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.