PageVisibility
PageVisibility keeps document visibility state in the store.
What it tracks
The pageVisibility entity keeps:
isSupported— whetherdocument.visibilityStateis availableisVisible— whether the page is currently visibleisWatching— whether the visibility listener is active
Usage
javascript
import { createStore } from "@inglorious/store"
import { PageVisibility } from "@inglorious/web/sensors/page-visibility"
const store = createStore({
types: { PageVisibility },
autoCreateEntities: true,
})
const pageVisibility = store.getEntity("pageVisibility")
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Example
javascript
if (!pageVisibility.isVisible) {
// pause animations, reduce polling, etc.
}
1
2
3
2
3
Inglorious Web