From 45e0d6697c107d77dce73d8e354867dc1959741d Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Wed, 11 Mar 2020 19:38:17 +0100 Subject: Properly scroll to anchors in links, especially in admin config --- .../app/+about/about-instance/about-instance.component.html | 5 ++--- .../src/app/+about/about-instance/about-instance.component.ts | 11 ++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'client/src/app/+about') diff --git a/client/src/app/+about/about-instance/about-instance.component.html b/client/src/app/+about/about-instance/about-instance.component.html index 043f63354..1df1ef2ad 100644 --- a/client/src/app/+about/about-instance/about-instance.component.html +++ b/client/src/app/+about/about-instance/about-instance.component.html @@ -96,9 +96,8 @@
-
- STATISTICS -
+
+
STATISTICS
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 c8c156105..e1809d7b7 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts @@ -1,17 +1,18 @@ -import { Component, OnInit, ViewChild } from '@angular/core' +import { Component, OnInit, ViewChild, AfterViewChecked } from '@angular/core' import { Notifier, ServerService } from '@app/core' import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' import { InstanceService } from '@app/shared/instance/instance.service' import { ServerConfig } from '@shared/models' import { ActivatedRoute } from '@angular/router' import { ResolverData } from './about-instance.resolver' +import { ViewportScroller } from '@angular/common' @Component({ selector: 'my-about-instance', templateUrl: './about-instance.component.html', styleUrls: [ './about-instance.component.scss' ] }) -export class AboutInstanceComponent implements OnInit { +export class AboutInstanceComponent implements OnInit, AfterViewChecked { @ViewChild('contactAdminModal', { static: true }) contactAdminModal: ContactAdminModalComponent shortDescription = '' @@ -35,8 +36,8 @@ export class AboutInstanceComponent implements OnInit { serverConfig: ServerConfig constructor ( + private viewportScroller: ViewportScroller, private route: ActivatedRoute, - private notifier: Notifier, private serverService: ServerService, private instanceService: InstanceService ) {} @@ -72,6 +73,10 @@ export class AboutInstanceComponent implements OnInit { this.html = await this.instanceService.buildHtml(about) } + ngAfterViewChecked () { + if (window.location.hash) this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', '')) + } + openContactModal () { return this.contactAdminModal.show() } -- cgit v1.2.3