usage-counts/src/app/about/about.component.ts

36 lines
940 B
TypeScript

import {AfterViewChecked, Component, OnInit} from '@angular/core';
import {faqs} from './faqs';
import {ActivatedRoute} from '@angular/router';
import {Title} from '@angular/platform-browser';
@Component({
selector: 'about',
templateUrl: 'about.component.html',
styleUrls: ['about.component.css'],
})
export class AboutComponent implements OnInit {
faqs: any[] = faqs;
constructor(private title: Title,
private route: ActivatedRoute) {
}
ngOnInit() {
this.title.setTitle('OpenAIRE - UsageCounts | About');
this.route.fragment.subscribe(fragment => {
setTimeout(() => {
this.goTo(fragment);
}, 100);
});
}
goTo(id: string) {
const yOffset = -100;
const element = document.getElementById(id);
if(element) {
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
window.scrollTo({top: y, behavior: 'smooth'});
}
}
}