aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main
diff options
context:
space:
mode:
authorKim <1877318+kimsible@users.noreply.github.com>2020-08-17 10:13:31 +0200
committerGitHub <noreply@github.com>2020-08-17 10:13:31 +0200
commit30d55e75cae1adec3fc43c84691975bf8b97db34 (patch)
tree74df7fabda72d88b60d6d8d20ba9cd95d1cf4858 /client/src/app/shared/shared-main
parent28fbb88f93859a7f6bbf124cb8df1e1a37fd1285 (diff)
downloadPeerTube-30d55e75cae1adec3fc43c84691975bf8b97db34.tar.gz
PeerTube-30d55e75cae1adec3fc43c84691975bf8b97db34.tar.zst
PeerTube-30d55e75cae1adec3fc43c84691975bf8b97db34.zip
Add restore scroll position on user-dropdown anchors links and scroll to top on active sub-menu links (#3066)
* Add restore scroll position on router same url * Remove settings top anchor * Add scrollToTop on active links fixed sub-menu * Add restore scroll position on notification avatar links * Toggle menu and close pophover when click on active dropdown menu-left link * Add onSameUrlRestoreScrollPosition on user dropdown channels link * Same behavior scrollTop and scroll to anchor everywhere Co-authored-by: kimsible <kimsible@users.noreply.github.com>
Diffstat (limited to 'client/src/app/shared/shared-main')
-rw-r--r--client/src/app/shared/shared-main/misc/top-menu-dropdown.component.html8
-rw-r--r--client/src/app/shared/shared-main/misc/top-menu-dropdown.component.ts10
2 files changed, 15 insertions, 3 deletions
diff --git a/client/src/app/shared/shared-main/misc/top-menu-dropdown.component.html b/client/src/app/shared/shared-main/misc/top-menu-dropdown.component.html
index 416bd9bc8..ee3346ea9 100644
--- a/client/src/app/shared/shared-main/misc/top-menu-dropdown.component.html
+++ b/client/src/app/shared/shared-main/misc/top-menu-dropdown.component.html
@@ -1,7 +1,7 @@
1<div class="sub-menu" [ngClass]="{ 'sub-menu-fixed': !isBroadcastMessageDisplayed, 'no-scroll': isModalOpened }"> 1<div class="sub-menu" [ngClass]="{ 'sub-menu-fixed': !isBroadcastMessageDisplayed, 'no-scroll': isModalOpened }">
2 <ng-container *ngFor="let menuEntry of menuEntries; index as id"> 2 <ng-container *ngFor="let menuEntry of menuEntries; index as id">
3 3
4 <a *ngIf="menuEntry.routerLink && isDisplayed(menuEntry)" [routerLink]="menuEntry.routerLink" routerLinkActive="active" class="title-page title-page-settings">{{ menuEntry.label }}</a> 4 <a *ngIf="menuEntry.routerLink && isDisplayed(menuEntry)" [routerLink]="menuEntry.routerLink" routerLinkActive="active" class="title-page title-page-settings" #routerLink (click)="onActiveLinkScrollToTop(routerLink)">{{ menuEntry.label }}</a>
5 5
6 <div *ngIf="!menuEntry.routerLink && isDisplayed(menuEntry)" ngbDropdown class="parent-entry" 6 <div *ngIf="!menuEntry.routerLink && isDisplayed(menuEntry)" ngbDropdown class="parent-entry"
7 #dropdown="ngbDropdown" autoClose="true"> 7 #dropdown="ngbDropdown" autoClose="true">
@@ -28,7 +28,8 @@
28 <ng-container *ngFor="let menuChild of menuEntry.children"> 28 <ng-container *ngFor="let menuChild of menuEntry.children">
29 <a *ngIf="isDisplayed(menuChild)" class="dropdown-item" 29 <a *ngIf="isDisplayed(menuChild)" class="dropdown-item"
30 [ngClass]="{ icon: hasIcons }" 30 [ngClass]="{ icon: hasIcons }"
31 [routerLink]="menuChild.routerLink"> 31 [routerLink]="menuChild.routerLink"
32 #routerLink (click)="onActiveLinkScrollToTop(routerLink)">
32 <my-global-icon *ngIf="menuChild.iconName" [iconName]="menuChild.iconName" aria-hidden="true"></my-global-icon> 33 <my-global-icon *ngIf="menuChild.iconName" [iconName]="menuChild.iconName" aria-hidden="true"></my-global-icon>
33 34
34 {{ menuChild.label }} 35 {{ menuChild.label }}
@@ -46,7 +47,8 @@
46 <ng-container *ngFor="let menuChild of menuEntry.children"> 47 <ng-container *ngFor="let menuChild of menuEntry.children">
47 <a *ngIf="isDisplayed(menuChild)" 48 <a *ngIf="isDisplayed(menuChild)"
48 [ngClass]="{ icon: hasIcons }" 49 [ngClass]="{ icon: hasIcons }"
49 [routerLink]="menuChild.routerLink" routerLinkActive="active" (click)="dismissOtherModals()"> 50 [routerLink]="menuChild.routerLink" routerLinkActive="active"
51 #routerLink (click)="dismissOtherModals(); onActiveLinkScrollToTop(routerLink)">
50 <my-global-icon *ngIf="menuChild.iconName" [iconName]="menuChild.iconName" aria-hidden="true"></my-global-icon> 52 <my-global-icon *ngIf="menuChild.iconName" [iconName]="menuChild.iconName" aria-hidden="true"></my-global-icon>
51 53
52 {{ menuChild.label }} 54 {{ menuChild.label }}
diff --git a/client/src/app/shared/shared-main/misc/top-menu-dropdown.component.ts b/client/src/app/shared/shared-main/misc/top-menu-dropdown.component.ts
index 043b647c9..ba5568595 100644
--- a/client/src/app/shared/shared-main/misc/top-menu-dropdown.component.ts
+++ b/client/src/app/shared/shared-main/misc/top-menu-dropdown.component.ts
@@ -94,6 +94,16 @@ export class TopMenuDropdownComponent implements OnInit, OnDestroy {
94 this.isModalOpened = false 94 this.isModalOpened = false
95 } 95 }
96 96
97 onActiveLinkScrollToTop (link: HTMLAnchorElement) {
98 if (!this.isBroadcastMessageDisplayed && this.router.url.includes(link.getAttribute('href'))) {
99 window.scrollTo({
100 left: 0,
101 top: 0,
102 behavior: 'smooth'
103 })
104 }
105 }
106
97 dismissOtherModals () { 107 dismissOtherModals () {
98 this.modalService.dismissAll() 108 this.modalService.dismissAll()
99 } 109 }