Re: [csswg-drafts] Page Visibility hook (#7028)

> JavaScript can know when a page has gone into the background, or a tab has lost focus, etc

Not quite. As far as I see, the JS API works only when the page is losing visibility: it’s minimized or when you switch to a different desktop (on macOS). This behavior is less useful for CSS than what the `:-moz-window-inactive` implementation does: it changes behavior when the window goes to the background but is still visible.

I realized I needed this behavior while building a control mimicking a system one. It turned out that only native built-in browser controls can dim their `accent-color` to become less destructive when the window goes to the background. It seems like a very useful UX feature missing from CSS.

I’d say we need both a pseudo-class (for simple per-element cases) and a media feature (for more complex cases) to have a convenient API.

-- 
GitHub Notification of comment by pepelsbey
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7028#issuecomment-2579951256 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 9 January 2025 11:45:10 UTC