aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/misc/screen.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/misc/screen.service.ts')
-rw-r--r--client/src/app/shared/misc/screen.service.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/client/src/app/shared/misc/screen.service.ts b/client/src/app/shared/misc/screen.service.ts
new file mode 100644
index 000000000..5b17a914a
--- /dev/null
+++ b/client/src/app/shared/misc/screen.service.ts
@@ -0,0 +1,23 @@
1import { Injectable, NgZone } from '@angular/core'
2
3@Injectable()
4export class ScreenService {
5 private windowInnerWidth: number
6
7 constructor (private zone: NgZone) {
8 this.windowInnerWidth = window.innerWidth
9
10 // Try to cache a little bit window.innerWidth
11 this.zone.runOutsideAngular(() => {
12 setInterval(() => this.windowInnerWidth = window.innerWidth, 500)
13 })
14 }
15
16 isInSmallView () {
17 return this.windowInnerWidth < 600
18 }
19
20 isInMobileView () {
21 return this.windowInnerWidth < 500
22 }
23}