fix touch menu toggle
This commit is contained in:
@@ -17,8 +17,7 @@ import { MatSidenav } from '@angular/material/sidenav';
|
||||
})
|
||||
export class MainComponent {
|
||||
|
||||
@ViewChild(MatSidenav) sidenav: MatSidenav;
|
||||
|
||||
opened : boolean = true;
|
||||
darkTheme = "false";
|
||||
title = 'we.bstly';
|
||||
currentLocale: String;
|
||||
@@ -53,9 +52,9 @@ export class MainComponent {
|
||||
|
||||
const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
||||
if (width < 768) {
|
||||
this.sidenav?.close();
|
||||
this.opened = false;
|
||||
} else {
|
||||
this.sidenav?.open();
|
||||
this.opened = true;
|
||||
}
|
||||
|
||||
if (localStorage.getItem("bstly.darkTheme") == "true") {
|
||||
@@ -145,9 +144,9 @@ export class MainComponent {
|
||||
@HostListener('window:resize', [ '$event' ])
|
||||
onResize(event) {
|
||||
if (event.target.innerWidth < 768) {
|
||||
this.sidenav?.close();
|
||||
this.opened = false;
|
||||
} else {
|
||||
this.sidenav?.open();
|
||||
this.opened = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,10 +169,10 @@ export class MainComponent {
|
||||
const touchDiff = this.touchStartX - this.touchX;
|
||||
this.touchStartX = 0;
|
||||
this.touchX = 0;
|
||||
if (touchDiff < 0 && touchDiff < (this.touchThresh * -1) && !this.sidenav.opened) {
|
||||
this.sidenav.open();
|
||||
} else if (touchDiff > 0 && touchDiff > this.touchThresh && this.sidenav.opened) {
|
||||
this.sidenav.close();
|
||||
if (touchDiff < 0 && touchDiff < (this.touchThresh * -1) && !this.opened) {
|
||||
this.opened = true;
|
||||
} else if (touchDiff > 0 && touchDiff > this.touchThresh && this.opened) {
|
||||
this.opened = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user