バックグラウンドで一定時間経過したらページネーションのアイテム更新をしない (#10053)
This commit is contained in:
parent
1c9c9745f5
commit
cc8d60e53b
2 changed files with 53 additions and 3 deletions
19
packages/frontend/src/scripts/use-document-visibility.ts
Normal file
19
packages/frontend/src/scripts/use-document-visibility.ts
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue