AltitudeWeb/frontend/src/app/header/header.component.ts

46 lines
1.1 KiB
TypeScript
Raw Normal View History

import {Component, HostListener, Input} from '@angular/core';
import {ALTITUDE_VERSION} from '../constant';
@Component({
standalone: false,
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
})
export class HeaderComponent {
@Input() title: string = '';
@Input() sub_title: string = '';
@Input() current_page: string = ''
public active: string = ''
@HostListener('window:scroll', [])
onWindowScroll(): void {
const scrollPosition = window.scrollY;
if (scrollPosition > 0) {
this.active = 'active';
} else {
this.active = '';
}
}
scrollToSection(): void {
const element = document.getElementById('scrollingpoint');
if (element) {
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
} else {
console.error('Element with id "scrollingpoint" not found.');
}
}
public getCurrentPageId(options: string[]) {
if (options.includes(this.current_page)) {
return 'current_page'
}
return null;
}
protected readonly ALTITUDE_VERSION = ALTITUDE_VERSION;
}