diff --git a/src/app/ui/main/main.ui.ts b/src/app/ui/main/main.ui.ts index 9cfd225..68499e9 100644 --- a/src/app/ui/main/main.ui.ts +++ b/src/app/ui/main/main.ui.ts @@ -3,6 +3,7 @@ import { Router } from '@angular/router'; import { DomSanitizer } from '@angular/platform-browser'; import { MatIconRegistry } from '@angular/material/icon'; import { DateAdapter } from '@angular/material/core'; +import { fromEvent } from 'rxjs'; import { AuthService } from '../../services/auth.service'; import { UserService } from '../../services/user.service'; @@ -25,6 +26,10 @@ export class UiMain { authenticated: boolean = false; moderator: boolean = false; + touchThresh: number = 150; + touchStartX: number; + touchX: number; + constructor( private i18n: I18nService, private authService: AuthService, @@ -67,6 +72,8 @@ export class UiMain { } await this.settingsService.getSettings(); + + this.touchEvents(); } setLocale(locale) { @@ -132,4 +139,31 @@ export class UiMain { this.opened = true; } } -} \ No newline at end of file + + touchEvents(): void { + fromEvent(document, 'touchstart').subscribe((event: TouchEvent) => { + if (event.touches[ 0 ]) { + this.touchStartX = event.touches[ 0 ].screenX; + + } + }) + + fromEvent(document, 'touchmove').subscribe((event: TouchEvent) => { + if (event.touches[ 0 ]) { + this.touchX = event.touches[ 0 ].screenX; + } + }) + + fromEvent(document, 'touchend').subscribe((event: TouchEvent) => { + const touchDiff = this.touchStartX - this.touchX; + + if (touchDiff < 0 && touchDiff < (this.touchThresh * -1) && !this.opened) { + this.opened = true; + } else if (touchDiff > 0 && touchDiff > this.touchThresh && this.opened) { + this.opened = false; + } + }) + } + +} + diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 10f8b3e..94df675 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,8 +4,8 @@ export const environment = { production: false, - apiUrl : 'http://localhost:8080/api', - //apiUrl : 'https://brd.bstly.lh8.de/api', + // apiUrl : 'http://localhost:8080/api', + apiUrl : 'https://board.bstly.lh8.de/api', }; /*