C - Type of component that is lazy-loaded.public class LazyLoad<C extends com.vaadin.flow.component.Component> extends com.vaadin.flow.component.Composite<LazyLoad.LazyLoadElement> implements WithIdMixin<LazyLoad<C>>, com.vaadin.flow.component.HasStyle
| Modifier and Type | Class and Description |
|---|---|
static class |
LazyLoad.LazyLoadElement
This class exists so that
LazyLoad can have a custom tag name. |
| Modifier and Type | Field and Description |
|---|---|
static String |
EMPTY_CLASS_NAME
Style name when this component is empty (not showing anything).
|
static String |
LOADED_CLASS_NAME
Style name when this component has content.
|
| Constructor and Description |
|---|
LazyLoad(C contents)
Creates lazy load wrapper for given contents.
|
LazyLoad(C contents,
boolean removeOnHide)
Creates lazy load wrapper for given contents.
|
LazyLoad(C contents,
com.vaadin.flow.function.SerializableSupplier<ComponentObserver> observerSupplier)
Creates lazy load wrapper for given contents.
|
LazyLoad(com.vaadin.flow.function.SerializableSupplier<C> supplier)
Creates lazy load wrapper for given component supplier.
|
LazyLoad(com.vaadin.flow.function.SerializableSupplier<C> supplier,
boolean removeOnHide)
Creates lazy load wrapper for given component supplier.
|
LazyLoad(com.vaadin.flow.function.SerializableSupplier<C> contentSupplier,
com.vaadin.flow.function.SerializableSupplier<ComponentObserver> observerSupplier)
Creates lazy load wrapper for given component supplier.
|
LazyLoad(com.vaadin.flow.function.SerializableSupplier<C> contentSupplier,
com.vaadin.flow.function.SerializableSupplier<ComponentObserver> observerSupplier,
boolean removeOnHide)
Creates lazy load wrapper for given component supplier.
|
| Modifier and Type | Method and Description |
|---|---|
double |
getContentHiddenVisibilityRange()
Returns the current range for considering the lazy-loaded component hidden.
|
double |
getContentShownVisibilityRange()
Returns the current range for considering the lazy-loaded component visible.
|
Optional<C> |
getLoadedContent()
Gets the content if it was already loaded (
isOnlyLoadedOnce() ()} is true) or if it is currently showing. |
boolean |
isLoaded()
Checks if the content has been already loaded (
isOnlyLoadedOnce() ()} is true) or is currently loaded. |
boolean |
isOnlyLoadedOnce()
Returns if the lazy loading happens only on the first showing.
|
protected void |
onNowHidden()
Called when the content becomes hidden.
|
protected void |
onNowVisible()
Called when the content becomes visible.
|
void |
setContentVisibilityRanges(double hiddenOnOrBelow,
double visibleOnOrAbove)
Defines visibility ranges.
|
LazyLoad<C> |
withContentVisibilityRanges(double hiddenOnOrBelow,
double visibleOnOrAbove)
Chains
setContentVisibilityRanges(double, double) and returns itself. |
getChildren, getContent, getElement, initContentaddListener, fireEvent, from, get, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitwithIdpublic static final String EMPTY_CLASS_NAME
public static final String LOADED_CLASS_NAME
public LazyLoad(C contents)
contents - Contents to wrap for lazy loading.public LazyLoad(com.vaadin.flow.function.SerializableSupplier<C> supplier)
supplier - Supplier that will be called when the component gets into view.public LazyLoad(C contents, boolean removeOnHide)
contents - Contents to wrap for lazy loading.removeOnHide - Whether to remove the component when this object gets hidden.public LazyLoad(com.vaadin.flow.function.SerializableSupplier<C> supplier, boolean removeOnHide)
supplier - Supplier that will be called when the component gets into view.removeOnHide - Whether to remove the component when this object gets hidden.public LazyLoad(C contents, com.vaadin.flow.function.SerializableSupplier<ComponentObserver> observerSupplier)
contents - Contents to wrap for lazy loading.observerSupplier - a way to create a customised ComponentObserver that will be used by this component.public LazyLoad(com.vaadin.flow.function.SerializableSupplier<C> contentSupplier, com.vaadin.flow.function.SerializableSupplier<ComponentObserver> observerSupplier)
contentSupplier - Supplier that will be called when the component gets into view.observerSupplier - a way to create a customised ComponentObserver that will be used by this component.public LazyLoad(com.vaadin.flow.function.SerializableSupplier<C> contentSupplier, com.vaadin.flow.function.SerializableSupplier<ComponentObserver> observerSupplier, boolean removeOnHide)
contentSupplier - Supplier that will be called when the component gets into view.observerSupplier - a way to create a customised ComponentObserver that will be used by this component.removeOnHide - Whether to remove the component when this object gets hidden.public double getContentHiddenVisibilityRange()
getContentShownVisibilityRange() (inclusive).setContentVisibilityRanges(double, double)public double getContentShownVisibilityRange()
getContentHiddenVisibilityRange() (inclusive) and 1 (inclusive).setContentVisibilityRanges(double, double)public void setContentVisibilityRanges(double hiddenOnOrBelow,
double visibleOnOrAbove)
LazyLoad uses a ComponentObserver to decide if the content should be shown or not.
By default, the component is lazy-loaded when LazyLoad is fully visible and hidden when it is fully invisible.
Defining ranges allows for lazy-loading the contents when it becomes partially visible. Be sure to know what you are doing and why.hiddenOnOrBelow - Visibility range at which or below which the component is considered hidden. Must be between 0 (inclusive) and the other parameter (inclusive).visibleOnOrAbove - Visibility range at which or above which the component is considered visible. Must be between the other parameter (inclusive) and 1 (inclusive).IllegalArgumentException - when either range is below 0, above 1, or the first parameter is greater than the secondpublic LazyLoad<C> withContentVisibilityRanges(double hiddenOnOrBelow, double visibleOnOrAbove)
setContentVisibilityRanges(double, double) and returns itself.hiddenOnOrBelow - Visibility range at which or below which the component is considered hidden. Must be between 0 (inclusive) and the other parameter (inclusive).visibleOnOrAbove - Visibility range at which or above which the component is considered visible. Must be between the other parameter (inclusive) and 1 (inclusive).setContentVisibilityRanges(double, double)protected void onNowHidden()
protected void onNowVisible()
public boolean isOnlyLoadedOnce()
true when the target component will be loaded only once, the first time this component is shown; otherwise false.public Optional<C> getLoadedContent()
isOnlyLoadedOnce() ()} is true) or if it is currently showing.Optional.empty().isLoaded(),
isOnlyLoadedOnce()public boolean isLoaded()
isOnlyLoadedOnce() ()} is true) or is currently loaded.getLoadedContent(),
isOnlyLoadedOnce()Copyright © 2024 Miki. All rights reserved.