tasto back e bugfix editor
This commit is contained in:
@@ -3,10 +3,11 @@ import { ThemeService } from './services/theme.service';
|
||||
import { CantiService } from './services/canti.service';
|
||||
import { SettingsService } from './services/settings.service';
|
||||
import { VERSION } from './version';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { ToastController } from '@ionic/angular';
|
||||
import { Router, ActivatedRoute, NavigationStart } from '@angular/router';
|
||||
import { ToastController, Platform } from '@ionic/angular';
|
||||
import { SwUpdate, VersionReadyEvent } from '@angular/service-worker';
|
||||
import { filter, first } from 'rxjs/operators';
|
||||
import { App } from '@capacitor/app';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@@ -19,6 +20,7 @@ export class AppComponent implements OnInit {
|
||||
public cantiService = inject(CantiService);
|
||||
public settingsService = inject(SettingsService);
|
||||
public version = VERSION;
|
||||
private platform = inject(Platform);
|
||||
private router = inject(Router);
|
||||
private route = inject(ActivatedRoute);
|
||||
private toastCtrl = inject(ToastController);
|
||||
@@ -60,6 +62,27 @@ export class AppComponent implements OnInit {
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
// Gestione tasto back per PWA/Browser (intercettando popstate di Angular Router)
|
||||
this.router.events.subscribe(event => {
|
||||
if (event instanceof NavigationStart && event.navigationTrigger === 'popstate') {
|
||||
const targetUrl = event.url.split('?')[0];
|
||||
if (targetUrl !== '/home' && targetUrl !== '/') {
|
||||
this.router.navigate(['/home'], { replaceUrl: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Gestione tasto back hardware per nativo (Capacitor/Cordova)
|
||||
this.platform.backButton.subscribeWithPriority(9999, () => {
|
||||
const currentUrl = this.router.url;
|
||||
const path = currentUrl.split('?')[0];
|
||||
if (path !== '/home' && path !== '/') {
|
||||
this.router.navigate(['/home']);
|
||||
} else {
|
||||
App.exitApp();
|
||||
}
|
||||
});
|
||||
|
||||
// Add global horizontal scroll support for wheel on horizontal containers
|
||||
window.addEventListener('wheel', (event: WheelEvent) => {
|
||||
if (Math.abs(event.deltaY) > 0 && Math.abs(event.deltaX) === 0) {
|
||||
|
||||
Reference in New Issue
Block a user