fix(ui): avoid CSS transition on page navigation (#1833)

This commit is contained in:
Alex
2026-06-28 08:36:59 +01:00
committed by GitHub
parent c2c867ead4
commit be574d5b16
3 changed files with 33 additions and 0 deletions
@@ -0,0 +1,23 @@
import { DOCUMENT } from '@angular/common';
import { afterNextRender, inject, Injectable, Injector } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
@Injectable({ providedIn: 'root' })
export class NavigationTransitionGuard {
private readonly root = inject(DOCUMENT).documentElement;
private readonly injector = inject(Injector);
constructor() {
inject(Router).events.subscribe((event) => {
if (event instanceof NavigationEnd) {
this.root.classList.add('route-settling');
afterNextRender(() => this.release(), { injector: this.injector });
}
});
}
private release(): void {
getComputedStyle(this.root).getPropertyValue('opacity');
setTimeout(() => this.root.classList.remove('route-settling'), 1);
}
}