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 49 | 1x 25x 25x 25x 25x 2x 2x 2x | import {
ChangeDetectionStrategy,
Component,
HostBinding,
HostListener,
Inject,
Input,
} from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { RouterLink, RouterLinkActive } from '@angular/router';
import { SvgIconComponent } from 'angular-svg-icon';
import { TranslateModule } from '@ngx-translate/core';
import { DomService } from '../../../services/dom/dom.service';
@Component({
selector: 'app-nav',
templateUrl: './nav.component.html',
styleUrls: ['./nav.component.scss'],
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
RouterLink,
SvgIconComponent,
TranslateModule,
RouterLinkActive,
]
})
export class NavComponent {
@Input({ required: true }) fixedLeft!: number;
@HostBinding('style.left') styleLeft!: number | string;
@HostBinding('class.sticky') sticky: boolean = false;
private readonly fixedScrollYInRem = 9;
constructor(private domService: DomService,
@Inject(DOCUMENT) private document: Document) {}
@HostListener('window:scroll', ['$event'])
trackScrollPosition(): void {
if (this.domService.isDesktop()) {
this.sticky = (this.domService.getWindow().scrollY || 0) > DomService.remToPixels(this.fixedScrollYInRem);
this.styleLeft = this.sticky ? `${this.fixedLeft}px` : 'inherit';
}
}
}
|