From d4e231f67bfdecfd1d45fb44f4a43353068deba5 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Sun, 6 Apr 2025 17:47:12 +0200 Subject: [PATCH 1/3] 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(); + } + } From 6f0c667bddd492d509fee2d91315b98ea1f152ff Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Sun, 6 Apr 2025 17:48:44 +0200 Subject: [PATCH 2/3] Revert "Add OnInit to components to scroll to top on initialization" This reverts commit d4e231f67bfdecfd1d45fb44f4a43353068deba5. --- 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, 8 insertions(+), 24 deletions(-) diff --git a/frontend/src/app/about/about.component.ts b/frontend/src/app/about/about.component.ts index 3285859..2f80864 100644 --- a/frontend/src/app/about/about.component.ts +++ b/frontend/src/app/about/about.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit} from '@angular/core'; +import {Component} from '@angular/core'; import {ScrollService} from '../scroll/scroll.service'; @Component({ @@ -7,11 +7,7 @@ import {ScrollService} from '../scroll/scroll.service'; templateUrl: './about.component.html', styleUrl: './about.component.scss' }) -export class AboutComponent implements OnInit { +export class AboutComponent { 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 9ced929..396ccd9 100644 --- a/frontend/src/app/privacy/privacy.component.ts +++ b/frontend/src/app/privacy/privacy.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit} from '@angular/core'; +import {Component} from '@angular/core'; import {ScrollService} from '../scroll/scroll.service'; @Component({ @@ -7,12 +7,8 @@ import {ScrollService} from '../scroll/scroll.service'; templateUrl: './privacy.component.html', styleUrl: './privacy.component.scss' }) -export class PrivacyComponent implements OnInit { +export class PrivacyComponent { 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 1936075..3ad56de 100644 --- a/frontend/src/app/team/team.component.ts +++ b/frontend/src/app/team/team.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit} from '@angular/core'; +import {Component} from '@angular/core'; import {ScrollService} from '../scroll/scroll.service'; @Component({ @@ -7,11 +7,7 @@ import {ScrollService} from '../scroll/scroll.service'; templateUrl: './team.component.html', styleUrl: './team.component.scss' }) -export class TeamComponent implements OnInit { +export class TeamComponent { 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 57944c5..59f7183 100644 --- a/frontend/src/app/terms/terms.component.ts +++ b/frontend/src/app/terms/terms.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit} from '@angular/core'; +import {Component} from '@angular/core'; import {ScrollService} from '../scroll/scroll.service'; @Component({ @@ -7,12 +7,8 @@ import {ScrollService} from '../scroll/scroll.service'; templateUrl: './terms.component.html', styleUrl: './terms.component.scss' }) -export class TermsComponent implements OnInit { +export class TermsComponent { constructor(public scrollService: ScrollService) { } - ngOnInit(): void { - this.scrollService.scrollToTop(); - } - } From b256b9f66bd7c3328e2aa8c8f72073c1f007bb53 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Sun, 6 Apr 2025 17:51:16 +0200 Subject: [PATCH 3/3] Enable scroll position restoration in app routing --- frontend/src/app/app.module.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 840c9d1..b013fef 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -45,7 +45,9 @@ const routes: Routes = [ ], imports: [ BrowserModule, - RouterModule.forRoot(routes), + RouterModule.forRoot(routes, { + scrollPositionRestoration: 'enabled', + }), NgOptimizedImage, CopyIpComponent, ],