aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/menu/menu.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/menu/menu.component.ts')
-rw-r--r--client/src/app/menu/menu.component.ts33
1 files changed, 30 insertions, 3 deletions
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index 3d6cbda24..f9a0a9f57 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -2,7 +2,8 @@ import { HotkeysService } from 'angular2-hotkeys'
2import * as debug from 'debug' 2import * as debug from 'debug'
3import { switchMap } from 'rxjs/operators' 3import { switchMap } from 'rxjs/operators'
4import { Component, OnInit, ViewChild } from '@angular/core' 4import { Component, OnInit, ViewChild } from '@angular/core'
5import { AuthService, AuthStatus, AuthUser, RedirectService, ScreenService, ServerService, UserService } from '@app/core' 5import { Router } from '@angular/router'
6import { AuthService, AuthStatus, AuthUser, MenuService, RedirectService, ScreenService, ServerService, UserService } from '@app/core'
6import { LanguageChooserComponent } from '@app/menu/language-chooser.component' 7import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
7import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component' 8import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component'
8import { ServerConfig, UserRight, VideoConstant } from '@shared/models' 9import { ServerConfig, UserRight, VideoConstant } from '@shared/models'
@@ -43,8 +44,10 @@ export class MenuComponent implements OnInit {
43 private serverService: ServerService, 44 private serverService: ServerService,
44 private redirectService: RedirectService, 45 private redirectService: RedirectService,
45 private hotkeysService: HotkeysService, 46 private hotkeysService: HotkeysService,
46 private screenService: ScreenService 47 private screenService: ScreenService,
47 ) { } 48 private menuService: MenuService,
49 private router: Router
50 ) { }
48 51
49 get isInMobileView () { 52 get isInMobileView () {
50 return this.screenService.isInMobileView() 53 return this.screenService.isInMobileView()
@@ -192,6 +195,30 @@ export class MenuComponent implements OnInit {
192 return this.languages.find(lang => lang.id === localeId).label 195 return this.languages.find(lang => lang.id === localeId).label
193 } 196 }
194 197
198 onSameUrlRestoreScrollPosition (link: HTMLAnchorElement) {
199 const linkURL = link.getAttribute('href')
200 const linkHash = link.getAttribute('fragment')
201
202 // On same url without fragment restore top scroll position
203 if (!linkHash && this.router.url.includes(linkURL)) {
204 window.scrollTo({
205 left: 0,
206 top: 0,
207 behavior: 'smooth'
208 })
209 }
210
211 // On same url with fragment restore anchor scroll position
212 if (linkHash && this.router.url === linkURL) {
213 const anchor = document.getElementById(link.getAttribute('fragment'))
214 anchor.scrollIntoView({ behavior: 'smooth', inline: 'nearest' })
215 }
216
217 if (this.screenService.isInSmallView()) {
218 this.menuService.toggleMenu()
219 }
220 }
221
195 private buildUserLanguages () { 222 private buildUserLanguages () {
196 if (!this.user) { 223 if (!this.user) {
197 this.videoLanguages = [] 224 this.videoLanguages = []