From 64e0f8cf12c804a7a2fa582fd954f686cea9a45b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 16 Jun 2020 09:56:24 +0200 Subject: Fix scrolling with hash in url --- client/src/app/+about/about-instance/about-instance.component.ts | 8 +++++++- client/src/app/+about/about-peertube/about-peertube.component.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'client/src/app/+about') diff --git a/client/src/app/+about/about-instance/about-instance.component.ts b/client/src/app/+about/about-instance/about-instance.component.ts index e1809d7b7..15841be74 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts @@ -35,6 +35,8 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { serverConfig: ServerConfig + private lastScrollHash: string + constructor ( private viewportScroller: ViewportScroller, private route: ActivatedRoute, @@ -74,7 +76,11 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked { } ngAfterViewChecked () { - if (window.location.hash) this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', '')) + if (window.location.hash && window.location.hash !== this.lastScrollHash) { + this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', '')) + + this.lastScrollHash = window.location.hash + } } openContactModal () { diff --git a/client/src/app/+about/about-peertube/about-peertube.component.ts b/client/src/app/+about/about-peertube/about-peertube.component.ts index 98c5f93c3..b175a41bc 100644 --- a/client/src/app/+about/about-peertube/about-peertube.component.ts +++ b/client/src/app/+about/about-peertube/about-peertube.component.ts @@ -8,11 +8,17 @@ import { ViewportScroller } from '@angular/common' }) export class AboutPeertubeComponent implements AfterViewChecked { + private lastScrollHash: string + constructor ( private viewportScroller: ViewportScroller ) {} ngAfterViewChecked () { - if (window.location.hash) this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', '')) + if (window.location.hash && window.location.hash !== this.lastScrollHash) { + this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', '')) + + this.lastScrollHash = window.location.hash + } } } -- cgit v1.2.3