-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): git FileDiff auto-refresh on page focus
- Loading branch information
Guillaume Chau
committed
Mar 27, 2018
1 parent
2b0ac9f
commit 794910b
Showing
2 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Vue from 'vue' | ||
|
||
const vm = new Vue({ | ||
data: { | ||
documentVisible: !document.hidden, | ||
documentFocus: document.hasFocus() | ||
} | ||
}) | ||
|
||
document.addEventListener('visibilitychange', () => { | ||
vm.documentVisible = !document.hidden | ||
}, false) | ||
|
||
window.addEventListener('focus', () => { | ||
vm.documentFocus = true | ||
}) | ||
|
||
window.addEventListener('blur', () => { | ||
vm.documentFocus = false | ||
}) | ||
|
||
// @vue/component | ||
export default { | ||
computed: { | ||
documentVisible () { | ||
return vm.documentVisible | ||
}, | ||
|
||
documentFocus () { | ||
return vm.documentFocus | ||
} | ||
} | ||
} |