routie dev init since i didn't adhere to any proper guidance up until now
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
// Utilities
|
||||
import { onBeforeUnmount, shallowRef } from 'vue';
|
||||
import { IN_BROWSER } from "../util/globals.js";
|
||||
export function useDocumentVisibility() {
|
||||
const visibility = shallowRef(IN_BROWSER ? document.visibilityState : 'visible');
|
||||
if (IN_BROWSER) {
|
||||
const onVisibilityChange = () => {
|
||||
visibility.value = document.visibilityState;
|
||||
};
|
||||
document.addEventListener('visibilitychange', onVisibilityChange, {
|
||||
passive: true
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
||||
});
|
||||
}
|
||||
return visibility;
|
||||
}
|
||||
//# sourceMappingURL=documentVisibility.js.map
|
||||
Reference in New Issue
Block a user