All files / app/components/header header.component.ts

100% Statements 7/7
100% Branches 0/0
100% Functions 4/4
100% Lines 7/7

Kamil Chmielowski

Web / Angular

Jasmine code coverage report for cv app.

You can contact with me by email: kamilchmielowski94@gmail.com or my page.

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48                                                1x 17x 17x         17x       17x         1x       18x      
import {
  AfterViewInit,
  ChangeDetectionStrategy,
  Component,
  ElementRef,
  HostListener,
} from '@angular/core';
 
import { DomService } from '../../services/dom/dom.service';
import { environment } from '../../../environments/environment';
import { HeaderImports } from './header.imports';
import { NavComponent } from './nav/nav.component';
 
@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.scss'],
  standalone: true,
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [
    HeaderImports.imports,
    NavComponent
  ],
})
export class HeaderComponent implements AfterViewInit {
  protected readonly environment = environment;
  protected readonly location = location;
 
  protected navFixedLeftPos!: number;
 
  constructor(
    private elementRef: ElementRef<HTMLElement>,
  ) {}
 
  ngAfterViewInit(): void {
    this.updateNavFixedLeftPos();
  }
 
  @HostListener('window:resize', ['$event'])
  private trackWindowResize(): void {
    this.updateNavFixedLeftPos();
  }
 
  private updateNavFixedLeftPos(): void {
    this.navFixedLeftPos = this.elementRef.nativeElement.getBoundingClientRect().right + DomService.remToPixels(3);
  }
}