1 |
60843
|
stefania.m
|
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
2 |
|
|
import { ActivatedRoute } from '@angular/router';
|
3 |
|
|
import { Subscription } from 'rxjs';
|
4 |
58610
|
stefania.m
|
|
5 |
|
|
@Component({
|
6 |
|
|
selector: 'app-methodology',
|
7 |
|
|
templateUrl: './methodology.component.html',
|
8 |
|
|
// styleUrls: ['./top-menu.component.css'],
|
9 |
|
|
encapsulation: ViewEncapsulation.None
|
10 |
|
|
})
|
11 |
|
|
|
12 |
60843
|
stefania.m
|
export class MethodologyPageComponent implements OnInit, OnDestroy {
|
13 |
|
|
|
14 |
|
|
private subscriptions: any[] = [];
|
15 |
|
|
|
16 |
|
|
constructor(private route: ActivatedRoute) {
|
17 |
|
|
}
|
18 |
|
|
|
19 |
|
|
ngOnInit(): void {
|
20 |
|
|
this.subscriptions.push(this.route.fragment.subscribe(fragment => {
|
21 |
|
|
setTimeout(() => {
|
22 |
|
|
this.goTo(fragment);
|
23 |
|
|
}, 100);
|
24 |
|
|
}));
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
goTo(id: string) {
|
28 |
|
|
const yOffset = -100;
|
29 |
|
|
const element = document.getElementById(id);
|
30 |
|
|
if (element) {
|
31 |
|
|
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
|
32 |
|
|
window.scrollTo({top: y, behavior: 'smooth'});
|
33 |
|
|
}
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
ngOnDestroy(): void {
|
37 |
|
|
this.subscriptions.forEach(subscription => {
|
38 |
|
|
if (subscription instanceof Subscription) {
|
39 |
|
|
subscription.unsubscribe();
|
40 |
|
|
}
|
41 |
|
|
});
|
42 |
|
|
}
|
43 |
58610
|
stefania.m
|
}
|