Pinafore-Web-Client-Frontend/routes/_store/observers/pageVisibilityObservers.js

10 lines
212 B
JavaScript

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