Class PageVisibility

java.lang.Object
org.vaadin.firitin.util.PageVisibility

@Deprecated(since="3.6", forRemoval=true) public class PageVisibility extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
Vaadin 25.2 exposes page visibility natively via UI.getCurrent().getPage().pageVisibilitySignal(), a Signal<PageVisibility>. A single Signal.effect(component, ...) reading signal.get() replaces both isVisible() and addVisibilityChangeListener(PageVisibilityListener), and is component-bound so no manual Registration cleanup is needed. Map PageVisibility.Visibility.VISIBLE to com.vaadin.flow.component.page.PageVisibility.VISIBLE.
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).

  • Method Details

    • get

      public static PageVisibility get()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • get

      public static PageVisibility get(com.vaadin.flow.component.UI ui)
      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.Visibility enum 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.