Skip to content
Snippets Groups Projects
Commit 50507b5e authored by Tom Käsler's avatar Tom Käsler
Browse files

Merge branch '314-comment-list-auto-scrolling-is-really-disturbing' into 'master'

Add button for scrolling to the top

Closes #314

See merge request !279
parents 89d2b2fa 97bf74c4
1 merge request!279Add button for scrolling to the top
Pipeline #27969 passed with stages
in 8 minutes and 9 seconds
...@@ -72,6 +72,10 @@ ...@@ -72,6 +72,10 @@
</mat-menu> </mat-menu>
</div> </div>
<button mat-icon-button class="scrollTop" [ngClass]="{'visible': scrollExtended}" (click)="scrollToTop()">
<mat-icon>arrow_upward</mat-icon>
</button>
<div fxLayout="row" fxLayoutAlign="center" *ngIf="comments.length < 3"> <div fxLayout="row" fxLayoutAlign="center" *ngIf="comments.length < 3">
<button mat-fab class="fab-extended" (click)="openCreateDialog()"> <button mat-fab class="fab-extended" (click)="openCreateDialog()">
<mat-icon class="add">add</mat-icon> <mat-icon class="add">add</mat-icon>
......
...@@ -33,7 +33,6 @@ input { ...@@ -33,7 +33,6 @@ input {
margin-bottom: 2%; margin-bottom: 2%;
position: fixed; position: fixed;
top: 10px; top: 10px;
right: center;
width: 92%; width: 92%;
max-width: 800px; max-width: 800px;
z-index: 1; z-index: 1;
...@@ -146,3 +145,18 @@ h4 { ...@@ -146,3 +145,18 @@ h4 {
margin-left: 4%; margin-left: 4%;
color: var(--on-primary); color: var(--on-primary);
} }
.scrollTop {
position: fixed;
bottom: 3%;
left: -40px;
z-index: 1;
background-color: var(--background);
transition: 0.5s;
}
.visible {
left: 5%;
transition: 0.5s;
background-color: var(--secondary);
}
...@@ -41,6 +41,7 @@ export class CommentListComponent implements OnInit { ...@@ -41,6 +41,7 @@ export class CommentListComponent implements OnInit {
currentFilter = ''; currentFilter = '';
commentVoteMap = new Map<string, Vote>(); commentVoteMap = new Map<string, Vote>();
scroll = false; scroll = false;
scrollExtended = false;
constructor(private commentService: CommentService, constructor(private commentService: CommentService,
private translateService: TranslateService, private translateService: TranslateService,
...@@ -82,11 +83,9 @@ export class CommentListComponent implements OnInit { ...@@ -82,11 +83,9 @@ export class CommentListComponent implements OnInit {
} }
checkScroll(): void { checkScroll(): void {
if (document.documentElement.scrollTop >= 65) { const currentScroll = document.documentElement.scrollTop;
this.scroll = true; this.scroll = currentScroll >= 65;
} else { this.scrollExtended = currentScroll >= 300;
this.scroll = false;
}
} }
scrollToTop(): void { scrollToTop(): void {
...@@ -215,7 +214,6 @@ export class CommentListComponent implements OnInit { ...@@ -215,7 +214,6 @@ export class CommentListComponent implements OnInit {
return !c.read; return !c.read;
} }
}); });
this.scrollToTop();
} }
sortComments(type: string): void { sortComments(type: string): void {
...@@ -231,6 +229,5 @@ export class CommentListComponent implements OnInit { ...@@ -231,6 +229,5 @@ export class CommentListComponent implements OnInit {
} }
}); });
this.currentSort = type; this.currentSort = type;
this.scrollToTop();
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment