UNPKG

439 BPlain TextView Raw
1/**
2 * Assumes true for a non-browser env, otherwise makes a best effort
3 * @link https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState
4 */
5export function isDocumentVisible(): boolean {
6 // `document` may not exist in non-browser envs (like RN)
7 if (typeof document === 'undefined') {
8 return true
9 }
10 // Match true for visible, prerender, undefined
11 return document.visibilityState !== 'hidden'
12}