pub enum LazyMode {
Disabled,
Enabled {
placeholder: WidgetFn<()>,
deinit: bool,
intersect: ScrollMode,
},
}
Expand description
Lazy loading mode of a widget.
See lazy
property for more details.
Variants§
Disabled
Node always loaded.
Enabled
Node lazy loaded.
Fields
placeholder: WidgetFn<()>
Function that instantiates the node that replaces the widget when it is not in the init viewport.
All node methods are called on the placeholder, except the render methods, it should efficiently estimate the size of the inited widget.
deinit: bool
If the node is deinited when is moved out of the viewport.
If false
the node stays loaded after the first lazy load.
If true
the placeholder size is always used, this is to avoid the app entering a “flickering” loop
when the actual bounds are different causing an immediate deinit. An error is logged if the placeholder
size does not match.
intersect: ScrollMode
The scroll directions that are considered for intersection with the viewport.
If set to ScrollMode::VERTICAL
the widget is inited if it intersects on the vertical dimension only,
even if it is not actually in the viewport due to horizontal offset, and if deinit
is flagged only the placeholder
height is enforced, the width can be different from the actual.
If set to ScrollMode::NONE
this value is ignored, behaving like ScrollMode::PAN
.
Implementations§
source§impl LazyMode
impl LazyMode
sourcepub fn lazy(placeholder: WidgetFn<()>) -> LazyMode
pub fn lazy(placeholder: WidgetFn<()>) -> LazyMode
Enable lazy mode with a node that estimates the widget size.
The widget function must produce a node that is used as the layout placeholder for the actual widget content.
The widget will init when the placeholder stops being culled by render, and deinit when it starts being culled.
Note that in this mode the placeholder size is always used as the widget size, see the deinit
docs in LazyMode::Enabled
for more details.
See FrameBuilder::auto_hide_rect
for more details about render culling.
sourcepub fn lazy_vertical(placeholder: WidgetFn<()>) -> LazyMode
pub fn lazy_vertical(placeholder: WidgetFn<()>) -> LazyMode
Like lazy
, but only considers the height and vertical offset to init and deinit. Like lazy
the placeholder height is enforced, but the width is allowed to change between placeholder and actual.
Note that if the widget is inlined the full size of the widget placeholder is enforced like lazy
,
the widget will still init and deinit considering only the vertical intersection.
sourcepub fn lazy_horizontal(placeholder: WidgetFn<()>) -> LazyMode
pub fn lazy_horizontal(placeholder: WidgetFn<()>) -> LazyMode
Like lazy
, but only considers the width and horizontal offset to init and deinit. Like lazy
the placeholder width is enforced, but the height is allowed to change between placeholder and actual.
Note that if the widget is inlined the full size of the widget placeholder is enforced like lazy
,
the widget will still init and deinit considering only the horizontal intersection.
sourcepub fn once(placeholder: WidgetFn<()>) -> LazyMode
pub fn once(placeholder: WidgetFn<()>) -> LazyMode
Like lazy
but the widget stays inited after the first, even if it is culled by render it will be present in the UI tree.
Note that this mode allows the actual size to be different from the placeholder size, so it can be used for items that can’t estimate their own size exactly.
This mode is only recommended for items that are “heavy” to init, but light after, otherwise the app will show degraded performance after many items are inited.
sourcepub fn once_vertical(placeholder: WidgetFn<()>) -> LazyMode
pub fn once_vertical(placeholder: WidgetFn<()>) -> LazyMode
Like once
, but only considers the height and vertical offset to init.
sourcepub fn once_horizontal(placeholder: WidgetFn<()>) -> LazyMode
pub fn once_horizontal(placeholder: WidgetFn<()>) -> LazyMode
Like once
, but only considers the width and horizontal offset to init.
sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
If lazy init is mode.
sourcepub fn is_disabled(&self) -> bool
pub fn is_disabled(&self) -> bool
If lazy init is disabled.
Trait Implementations§
impl StructuralPartialEq for LazyMode
Auto Trait Implementations§
impl Freeze for LazyMode
impl !RefUnwindSafe for LazyMode
impl Send for LazyMode
impl Sync for LazyMode
impl Unpin for LazyMode
impl !UnwindSafe for LazyMode
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
source§impl<T> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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