diff options
author | BO41 <lukasw41@gmail.com> | 2018-10-05 11:22:24 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-05 11:22:24 +0200 |
commit | a585824160d016db7c9bff0e1cb1ffa3aaf73d74 (patch) | |
tree | 72fe865d307c10ce41b239e4ac12c0c888b856c5 /client/src/app | |
parent | 4232d092bbba9a0bc0dfb0e82322829970c49454 (diff) | |
download | PeerTube-a585824160d016db7c9bff0e1cb1ffa3aaf73d74.tar.gz PeerTube-a585824160d016db7c9bff0e1cb1ffa3aaf73d74.tar.zst PeerTube-a585824160d016db7c9bff0e1cb1ffa3aaf73d74.zip |
add resize listener (#1182)
* add resize listener
* respect user decision
* change listener to rxjs
* review changes
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/app.component.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 7cd0fff1b..dc4d0bf6a 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts | |||
@@ -4,9 +4,10 @@ import { GuardsCheckStart, NavigationEnd, Router } from '@angular/router' | |||
4 | import { AuthService, RedirectService, ServerService, ThemeService } from '@app/core' | 4 | import { AuthService, RedirectService, ServerService, ThemeService } from '@app/core' |
5 | import { is18nPath } from '../../../shared/models/i18n' | 5 | import { is18nPath } from '../../../shared/models/i18n' |
6 | import { ScreenService } from '@app/shared/misc/screen.service' | 6 | import { ScreenService } from '@app/shared/misc/screen.service' |
7 | import { skip } from 'rxjs/operators' | 7 | import { skip, debounceTime } from 'rxjs/operators' |
8 | import { HotkeysService, Hotkey } from 'angular2-hotkeys' | 8 | import { HotkeysService, Hotkey } from 'angular2-hotkeys' |
9 | import { I18n } from '@ngx-translate/i18n-polyfill' | 9 | import { I18n } from '@ngx-translate/i18n-polyfill' |
10 | import { fromEvent } from 'rxjs' | ||
10 | 11 | ||
11 | @Component({ | 12 | @Component({ |
12 | selector: 'my-app', | 13 | selector: 'my-app', |
@@ -28,6 +29,7 @@ export class AppComponent implements OnInit { | |||
28 | } | 29 | } |
29 | 30 | ||
30 | isMenuDisplayed = true | 31 | isMenuDisplayed = true |
32 | isMenuChangedByUser = false | ||
31 | 33 | ||
32 | customCSS: SafeHtml | 34 | customCSS: SafeHtml |
33 | 35 | ||
@@ -165,6 +167,10 @@ export class AppComponent implements OnInit { | |||
165 | return false | 167 | return false |
166 | }, undefined, this.i18n('Toggle Dark theme')) | 168 | }, undefined, this.i18n('Toggle Dark theme')) |
167 | ]) | 169 | ]) |
170 | |||
171 | fromEvent(window, 'resize') | ||
172 | .pipe(debounceTime(200)) | ||
173 | .subscribe(() => this.onResize()) | ||
168 | } | 174 | } |
169 | 175 | ||
170 | isUserLoggedIn () { | 176 | isUserLoggedIn () { |
@@ -173,5 +179,10 @@ export class AppComponent implements OnInit { | |||
173 | 179 | ||
174 | toggleMenu () { | 180 | toggleMenu () { |
175 | this.isMenuDisplayed = !this.isMenuDisplayed | 181 | this.isMenuDisplayed = !this.isMenuDisplayed |
182 | this.isMenuChangedByUser = true | ||
183 | } | ||
184 | |||
185 | onResize () { | ||
186 | this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser | ||
176 | } | 187 | } |
177 | } | 188 | } |