touchsupport
This commit is contained in:
parent
04e1524d8d
commit
2beffaf157
@ -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;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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',
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user