|
Last change
on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
427 bytes
|
| Line | |
|---|
| 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 | */
|
|---|
| 5 | export 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 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.