From 1bfc7b737975201645f43e58b485e864b3589bb3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 17 Aug 2020 10:19:45 +0200 Subject: Some code style fixes --- client/src/app/app.component.ts | 2 +- client/src/app/core/menu/menu.service.ts | 19 +++++++++---------- client/src/app/core/wrappers/screen.service.ts | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) (limited to 'client/src/app') diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 5b0439e6b..edec3216e 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -180,7 +180,7 @@ export class AppComponent implements OnInit, AfterViewInit { eventsObs.pipe( filter((e: Event): e is GuardsCheckStart => e instanceof GuardsCheckStart), - filter(() => this.screenService.isInSmallView() || !!this.screenService.isInTouchScreen()) + filter(() => this.screenService.isInSmallView() || this.screenService.isInTouchScreen()) ).subscribe(() => this.menu.setMenuDisplay(false)) // User clicked on a link in the menu, change the page } diff --git a/client/src/app/core/menu/menu.service.ts b/client/src/app/core/menu/menu.service.ts index 671ee3e4f..9c0433bca 100644 --- a/client/src/app/core/menu/menu.service.ts +++ b/client/src/app/core/menu/menu.service.ts @@ -28,15 +28,16 @@ export class MenuService { setMenuDisplay (display: boolean) { this.isMenuDisplayed = display + if (!this.screenService.isInTouchScreen()) return + // On touch screens, lock body scroll and display content overlay when memu is opened - if (this.screenService.isInTouchScreen()) { - if (this.isMenuDisplayed) { - document.body.classList.add('menu-open') - this.screenService.onFingerSwipe('left', () => { this.setMenuDisplay(false) }) - } else { - document.body.classList.remove('menu-open') - } + if (this.isMenuDisplayed) { + document.body.classList.add('menu-open') + this.screenService.onFingerSwipe('left', () => { this.setMenuDisplay(false) }) + return } + + document.body.classList.remove('menu-open') } onResize () { @@ -45,9 +46,7 @@ export class MenuService { private handleWindowResize () { // On touch screens, do not handle window resize event since opened menu is handled with a content overlay - if (this.screenService.isInTouchScreen()) { - return - } + if (this.screenService.isInTouchScreen()) return fromEvent(window, 'resize') .pipe(debounceTime(200)) diff --git a/client/src/app/core/wrappers/screen.service.ts b/client/src/app/core/wrappers/screen.service.ts index 88cf662b3..a085e5bdc 100644 --- a/client/src/app/core/wrappers/screen.service.ts +++ b/client/src/app/core/wrappers/screen.service.ts @@ -30,7 +30,7 @@ export class ScreenService { } isInTouchScreen () { - return 'ontouchstart' in window || navigator.msMaxTouchPoints + return !!('ontouchstart' in window || navigator.msMaxTouchPoints) } getNumberOfAvailableMiniatures () { -- cgit v1.2.3