Fix für Anzeigefehler im SectionToggle

This commit is contained in:
Andreas Schickinger
2022-10-12 16:40:29 +02:00
parent ed6ee36509
commit 886f063d1b

View File

@@ -9,6 +9,7 @@ import {
AfterViewInit,
OnChanges,
SimpleChanges,
OnDestroy,
} from '@angular/core';
@Component({
@@ -17,7 +18,9 @@ import {
styleUrls: ['section-toggle.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ShellSectionToggleComponent implements AfterViewInit, OnChanges {
export class ShellSectionToggleComponent implements AfterViewInit, OnChanges, OnDestroy {
private _interval: any;
@Input()
section: string = 'customer';
@@ -32,6 +35,10 @@ export class ShellSectionToggleComponent implements AfterViewInit, OnChanges {
constructor(private readonly _elementRef: ElementRef, private readonly _renderer: Renderer2) {}
ngOnDestroy(): void {
clearInterval(this._interval);
}
ngOnChanges(changes: SimpleChanges): void {
if (changes.section) {
this.updateSwitchPositionAndSize();
@@ -39,6 +46,7 @@ export class ShellSectionToggleComponent implements AfterViewInit, OnChanges {
}
ngAfterViewInit(): void {
this._interval = setInterval(() => this.updateSwitchPositionAndSize(), 1000);
this.updateSwitchPositionAndSize();
}
@@ -47,6 +55,7 @@ export class ShellSectionToggleComponent implements AfterViewInit, OnChanges {
this.section = section;
this.sectionChange.emit(section);
}
this.updateSwitchPositionAndSize();
}