]>
Commit | Line | Data |
---|---|---|
bbe0f064 C |
1 | import { Injectable, NgZone } from '@angular/core' |
2 | ||
3 | @Injectable() | |
4 | export 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 | } |