バックグラウンドで一定時間経過したらページネーションのアイテム更新をしない (#10053)

This commit is contained in:
YS
2023-02-25 08:18:12 +09:00
committed by GitHub
parent 1c9c9745f5
commit cc8d60e53b
2 changed files with 53 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
import { onMounted, onUnmounted, ref, Ref } from 'vue';
export function useDocumentVisibility(): Ref<DocumentVisibilityState> {
const visibility = ref(document.visibilityState);
const onChange = (): void => {
visibility.value = document.visibilityState;
};
onMounted(() => {
document.addEventListener('visibilitychange', onChange);
});
onUnmounted(() => {
document.removeEventListener('visibilitychange', onChange);
});
return visibility;
}