Some code style fixes

This commit is contained in:
Chocobozzz 2020-08-17 10:19:45 +02:00
parent 245b9d27bc
commit 1bfc7b7379
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 11 additions and 12 deletions

View File

@ -180,7 +180,7 @@ export class AppComponent implements OnInit, AfterViewInit {
eventsObs.pipe( eventsObs.pipe(
filter((e: Event): e is GuardsCheckStart => e instanceof GuardsCheckStart), 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 ).subscribe(() => this.menu.setMenuDisplay(false)) // User clicked on a link in the menu, change the page
} }

View File

@ -28,16 +28,17 @@ export class MenuService {
setMenuDisplay (display: boolean) { setMenuDisplay (display: boolean) {
this.isMenuDisplayed = display this.isMenuDisplayed = display
if (!this.screenService.isInTouchScreen()) return
// On touch screens, lock body scroll and display content overlay when memu is opened // On touch screens, lock body scroll and display content overlay when memu is opened
if (this.screenService.isInTouchScreen()) {
if (this.isMenuDisplayed) { if (this.isMenuDisplayed) {
document.body.classList.add('menu-open') document.body.classList.add('menu-open')
this.screenService.onFingerSwipe('left', () => { this.setMenuDisplay(false) }) this.screenService.onFingerSwipe('left', () => { this.setMenuDisplay(false) })
} else { return
}
document.body.classList.remove('menu-open') document.body.classList.remove('menu-open')
} }
}
}
onResize () { onResize () {
this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser
@ -45,9 +46,7 @@ export class MenuService {
private handleWindowResize () { private handleWindowResize () {
// On touch screens, do not handle window resize event since opened menu is handled with a content overlay // On touch screens, do not handle window resize event since opened menu is handled with a content overlay
if (this.screenService.isInTouchScreen()) { if (this.screenService.isInTouchScreen()) return
return
}
fromEvent(window, 'resize') fromEvent(window, 'resize')
.pipe(debounceTime(200)) .pipe(debounceTime(200))

View File

@ -30,7 +30,7 @@ export class ScreenService {
} }
isInTouchScreen () { isInTouchScreen () {
return 'ontouchstart' in window || navigator.msMaxTouchPoints return !!('ontouchstart' in window || navigator.msMaxTouchPoints)
} }
getNumberOfAvailableMiniatures () { getNumberOfAvailableMiniatures () {