Enum zng_wgt_scroll::LazyMode
source · 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<()>) -> Self
pub fn lazy(placeholder: WidgetFn<()>) -> Self
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<()>) -> Self
pub fn lazy_vertical(placeholder: WidgetFn<()>) -> Self
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<()>) -> Self
pub fn lazy_horizontal(placeholder: WidgetFn<()>) -> Self
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<()>) -> Self
pub fn once(placeholder: WidgetFn<()>) -> Self
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<()>) -> Self
pub fn once_vertical(placeholder: WidgetFn<()>) -> Self
Like once
, but only considers the height and vertical offset to init.
sourcepub fn once_horizontal(placeholder: WidgetFn<()>) -> Self
pub fn once_horizontal(placeholder: WidgetFn<()>) -> Self
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
)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> 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