Skip to content

Commit

Permalink
Add content overlay on touchscreens when menu is opened
Browse files Browse the repository at this point in the history
  • Loading branch information
kimsible committed Aug 15, 2020
1 parent 275df8d commit c59b170
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
26 changes: 22 additions & 4 deletions client/src/app/core/menu/menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export class MenuService {
this.setMenuDisplay(false)
}

fromEvent(window, 'resize')
.pipe(debounceTime(200))
.subscribe(() => this.onResize())
this.handleWindowResize()
}

toggleMenu () {
Expand All @@ -29,9 +27,29 @@ export class MenuService {

setMenuDisplay (display: boolean) {
this.isMenuDisplayed = display

// 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')
} else {
document.body.classList.remove('menu-open')
}
}
}

onResize () {
this.isMenuDisplayed = window.innerWidth >= 800 && !this.screenService.isInTouchScreen() && !this.isMenuChangedByUser
this.isMenuDisplayed = window.innerWidth >= 800 && !this.isMenuChangedByUser
}

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
}

fromEvent(window, 'resize')
.pipe(debounceTime(200))
.subscribe(() => this.onResize())
}
}
18 changes: 17 additions & 1 deletion client/src/sass/bootstrap.scss
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,25 @@ $icon-font-path: '~@neos21/bootstrap3-glyphicons/assets/fonts/';

// On touchscreen devices, simply overflow: hidden to avoid detached overlay on scroll
@media (hover: none) and (pointer: coarse) {
.modal-open {
.modal-open, .menu-open {
overflow: hidden !important;
}

// On touchscreen devices display content overlay when opened menu
.menu-open {
.main-col {
&::before {
background-color: black;
width: 100vw;
height: 100vh;
opacity: 0.75;
content: '';
display: block;
position: fixed;
z-index: z('header');
}
}
}
}

// Nav customizations
Expand Down

0 comments on commit c59b170

Please sign in to comment.