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 --- .../my-account-settings/my-account-settings.component.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'client/src/app/+my-account/my-account-settings/my-account-settings.component.ts') diff --git a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts index e314cdbea..ada98401c 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts @@ -1,17 +1,18 @@ -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, AfterViewChecked } from '@angular/core' import { Notifier } from '@app/core' import { BytesPipe } from 'ngx-pipes' import { AuthService } from '../../core' import { User } from '../../shared' import { UserService } from '../../shared/users' import { I18n } from '@ngx-translate/i18n-polyfill' +import { ViewportScroller } from '@angular/common' @Component({ selector: 'my-account-settings', templateUrl: './my-account-settings.component.html', styleUrls: [ './my-account-settings.component.scss' ] }) -export class MyAccountSettingsComponent implements OnInit { +export class MyAccountSettingsComponent implements OnInit, AfterViewChecked { user: User = null userVideoQuota = '0' @@ -21,6 +22,7 @@ export class MyAccountSettingsComponent implements OnInit { userVideoQuotaUsedDaily = 0 constructor ( + private viewportScroller: ViewportScroller, private userService: UserService, private authService: AuthService, private notifier: Notifier, @@ -57,6 +59,10 @@ export class MyAccountSettingsComponent implements OnInit { }) } + ngAfterViewChecked () { + if (window.location.hash) this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', '')) + } + onAvatarChange (formData: FormData) { this.userService.changeAvatar(formData) .subscribe( -- cgit v1.2.3