From d4e231f67bfdecfd1d45fb44f4a43353068deba5 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Sun, 6 Apr 2025 17:47:12 +0200 Subject: [PATCH] Add OnInit to components to scroll to top on initialization Updated Privacy, Team, Terms, and About components to implement OnInit. Each component now calls the `scrollToTop` method of the `ScrollService` in the `ngOnInit` lifecycle to ensure the page starts at the top when initialized. --- frontend/src/app/about/about.component.ts | 8 ++++++-- frontend/src/app/privacy/privacy.component.ts | 8 ++++++-- frontend/src/app/team/team.component.ts | 8 ++++++-- frontend/src/app/terms/terms.component.ts | 8 ++++++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/about/about.component.ts b/frontend/src/app/about/about.component.ts index 2f80864..3285859 100644 --- a/frontend/src/app/about/about.component.ts +++ b/frontend/src/app/about/about.component.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {ScrollService} from '../scroll/scroll.service'; @Component({ @@ -7,7 +7,11 @@ import {ScrollService} from '../scroll/scroll.service'; templateUrl: './about.component.html', styleUrl: './about.component.scss' }) -export class AboutComponent { +export class AboutComponent implements OnInit { constructor(public scrollService: ScrollService) { } + + ngOnInit(): void { + this.scrollService.scrollToTop(); + } } diff --git a/frontend/src/app/privacy/privacy.component.ts b/frontend/src/app/privacy/privacy.component.ts index 396ccd9..9ced929 100644 --- a/frontend/src/app/privacy/privacy.component.ts +++ b/frontend/src/app/privacy/privacy.component.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {ScrollService} from '../scroll/scroll.service'; @Component({ @@ -7,8 +7,12 @@ import {ScrollService} from '../scroll/scroll.service'; templateUrl: './privacy.component.html', styleUrl: './privacy.component.scss' }) -export class PrivacyComponent { +export class PrivacyComponent implements OnInit { constructor(public scrollService: ScrollService) { } + ngOnInit(): void { + this.scrollService.scrollToTop(); + } + } diff --git a/frontend/src/app/team/team.component.ts b/frontend/src/app/team/team.component.ts index 3ad56de..1936075 100644 --- a/frontend/src/app/team/team.component.ts +++ b/frontend/src/app/team/team.component.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {ScrollService} from '../scroll/scroll.service'; @Component({ @@ -7,7 +7,11 @@ import {ScrollService} from '../scroll/scroll.service'; templateUrl: './team.component.html', styleUrl: './team.component.scss' }) -export class TeamComponent { +export class TeamComponent implements OnInit { constructor(public scrollService: ScrollService) { } + + ngOnInit(): void { + this.scrollService.scrollToTop(); + } } diff --git a/frontend/src/app/terms/terms.component.ts b/frontend/src/app/terms/terms.component.ts index 59f7183..57944c5 100644 --- a/frontend/src/app/terms/terms.component.ts +++ b/frontend/src/app/terms/terms.component.ts @@ -1,4 +1,4 @@ -import {Component} from '@angular/core'; +import {Component, OnInit} from '@angular/core'; import {ScrollService} from '../scroll/scroll.service'; @Component({ @@ -7,8 +7,12 @@ import {ScrollService} from '../scroll/scroll.service'; templateUrl: './terms.component.html', styleUrl: './terms.component.scss' }) -export class TermsComponent { +export class TermsComponent implements OnInit { constructor(public scrollService: ScrollService) { } + ngOnInit(): void { + this.scrollService.scrollToTop(); + } + }