Enum Class PageVisibility

java.lang.Object
java.lang.Enum<PageVisibility>
com.vaadin.flow.component.page.PageVisibility
All Implemented Interfaces:
Serializable, Comparable<PageVisibility>, Constable

public enum PageVisibility extends Enum<PageVisibility>
The visibility state of the browser page, as reported by Page.pageVisibilitySignal().

Distinguishes three observable states ? the page is visible and focused (VISIBLE), visible but not focused (VISIBLE_NOT_FOCUSED), and hidden (HIDDEN) ? plus an UNKNOWN sentinel used before the browser has reported its first value. Use it to pause work the user cannot see, such as polling or animations:


 Page page = UI.getCurrent().getPage();
 Signal.effect(this, () -> {
     if (page.pageVisibilitySignal().get() == PageVisibility.HIDDEN) {
         pausePolling();
     } else {
         resumePolling();
     }
 });
 
Since:
25.2
See Also:
  • Enum Constant Details

    • UNKNOWN

      public static final PageVisibility UNKNOWN
      The browser has not reported a value yet. This is only the signal's initial value before the first client round-trip completes; in practice a real value is in place before any application code runs, and the signal never returns to UNKNOWN once it has a real value. Treat it as "not known yet" if you ever observe it.
    • VISIBLE

      public static final PageVisibility VISIBLE
      The page is visible and currently has focus ? the user is looking at this tab and it is the active window.
    • VISIBLE_NOT_FOCUSED

      public static final PageVisibility VISIBLE_NOT_FOCUSED
      The page is visible but does not have focus, for example when it sits behind another window or the user is interacting with a different application.
    • HIDDEN

      public static final PageVisibility HIDDEN
      The page is not visible, for example when its browser tab is in the background or the window is minimized.
  • Method Details

    • values

      public static PageVisibility[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static PageVisibility valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null