Package org.vaadin.firitin.util
Class PageVisibility
java.lang.Object
org.vaadin.firitin.util.PageVisibility
Deprecated, for removal: This API element is subject to removal in a future version.
Utility class to check the visibility state of the current page in a Vaadin application.
It provides methods to determine if the page is visible, focused, or hidden.
This class uses JavaScript to interact with the browser's visibility API and adds some helpful extra data via `document.hasFocus()` method. This allows it to determine not only hidden tabs, but also tabs that are visible but not focused (and thus often behind another browser window or application).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDeprecated, for removal: This API element is subject to removal in a future version.static enumDeprecated, for removal: This API element is subject to removal in a future version.UsePageVisibilityfrom Vaadin 25.2 instead. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationDeprecated, for removal: This API element is subject to removal in a future version.Adds a listener for visibility change events on the page.static PageVisibilityget()Deprecated, for removal: This API element is subject to removal in a future version.static PageVisibilityget(com.vaadin.flow.component.UI ui) Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.Checks the visibility state of the current page.
-
Method Details
-
get
Deprecated, for removal: This API element is subject to removal in a future version. -
get
Deprecated, for removal: This API element is subject to removal in a future version. -
isVisible
Deprecated, for removal: This API element is subject to removal in a future version.Checks the visibility state of the current page.This method returns a CompletableFuture that resolves to one of the
PageVisibility.Visibilityenum values, indicating whether the page is visible, focused, or hidden.- Returns:
- a CompletableFuture containing the visibility state of the page
-
addVisibilityChangeListener
public com.vaadin.flow.shared.Registration addVisibilityChangeListener(PageVisibility.PageVisibilityListener listener) Deprecated, for removal: This API element is subject to removal in a future version.Adds a listener for visibility change events on the page. In the browser, this is uses both the `visibilitychange` event and the `blur` and `focus` events to determine the visibility and focusing state of the page.- Parameters:
listener- the listener to be notified when the visibility state changes.- Returns:
- a DomListenerRegistration that can be used to remove the listener later.
-
UI.getCurrent().getPage().pageVisibilitySignal(), aSignal<PageVisibility>. A singleSignal.effect(component, ...)readingsignal.get()replaces bothisVisible()andaddVisibilityChangeListener(PageVisibilityListener), and is component-bound so no manualRegistrationcleanup is needed. MapPageVisibility.Visibility.VISIBLEtocom.vaadin.flow.component.page.PageVisibility.VISIBLE.