touchsupport

This commit is contained in:
_Bastler 2021-10-11 17:03:29 +02:00
parent 04e1524d8d
commit 2beffaf157
2 changed files with 37 additions and 3 deletions

View File

@ -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;
}
}
}
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;
}
})
}
}

View File

@ -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',
};
/*