forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppVisibility.js
More file actions
39 lines (33 loc) · 1.01 KB
/
Copy pathAppVisibility.js
File metadata and controls
39 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import defineReactivePlugin from '../utils/private/define-reactive-plugin.js'
import { injectProp } from '../utils/private/inject-obj-prop.js'
const Plugin = defineReactivePlugin({
appVisible: true
}, {
install ({ $q }) {
if (__QUASAR_SSR_SERVER__) {
this.appVisible = $q.appVisible = true
return
}
injectProp($q, 'appVisible', () => this.appVisible)
}
})
if (__QUASAR_SSR_SERVER__ !== true) {
let prop, evt
if (typeof document.hidden !== 'undefined') { // Opera 12.10 and Firefox 18 and later support
prop = 'hidden'
evt = 'visibilitychange'
}
else if (typeof document.msHidden !== 'undefined') {
prop = 'msHidden'
evt = 'msvisibilitychange'
}
else if (typeof document.webkitHidden !== 'undefined') {
prop = 'webkitHidden'
evt = 'webkitvisibilitychange'
}
if (evt && typeof document[ prop ] !== 'undefined') {
const update = () => { Plugin.appVisible = !document[ prop ] }
document.addEventListener(evt, update, false)
}
}
export default Plugin