pinafore/routes/_store/observers/pageVisibilityObservers.js

10 lines
210 B
JavaScript

export function pageVisibilityObservers (store) {
if (!process.browser) {
return
}
document.addEventListener('visibilitychange', () => {
store.set({pageVisibilityHidden: document.hidden})
})
}