Skip to content
Snippets Groups Projects
Commit 3f03effb authored by Lukas Haase's avatar Lukas Haase
Browse files

scroll selected comment into view

parent a728dbee
Branches
Tags
No related merge requests found
...@@ -54,7 +54,9 @@ import { MatIconModule } from '@angular/material/icon'; ...@@ -54,7 +54,9 @@ import { MatIconModule } from '@angular/material/icon';
ThemeTestComponent, ThemeTestComponent,
BaseTestComponent, BaseTestComponent,
MenuWrapperDirective, MenuWrapperDirective,
ButtonWrapperDirective ButtonWrapperDirective,
ButtonBaseDirective,
MaterialBtnComponent
] ]
}) })
export class ArsModule { } export class ArsModule { }
<ars-screen ars-flex-box class="questionwall-screen"> <ars-screen ars-flex-box class="questionwall-screen">
<ars-row [height]="50" class="questionwall-header"> <ars-row [height]="50" class="questionwall-header">
<button *ngIf="room" routerLink="/participant/room/{{room.shortId}}/comments">BACK</button> <ars-style-btn-material *ngIf="room" style="width:100%;height:100%;" ars-flex-box>
<ars-col ars-btn-wrp [xp]="16" [extra]="true">
<button ars-btn routerLink="/participant/room/{{room.shortId}}/comments"><p>BACK</p></button>
</ars-col>
</ars-style-btn-material>
</ars-row> </ars-row>
<ars-fill ars-flex-box> <ars-fill ars-flex-box>
<ars-fill style="overflow:hidden;"> <ars-fill style="overflow:hidden;">
...@@ -10,7 +14,7 @@ ...@@ -10,7 +14,7 @@
</ars-row> </ars-row>
</ars-fill> </ars-fill>
<ars-col [width]="450" [overflow]="'auto'" class="questionwall-comment-list" #colComponent> <ars-col [width]="450" [overflow]="'auto'" class="questionwall-comment-list" #colComponent>
<ars-row *ngFor="let comment of comments"> <ars-row *ngFor="let comment of comments" class="questionwall-comment-anchor">
<div class="questionwall-comment"> <div class="questionwall-comment">
<div class="questionwall-comment-box" (click)="focusComment(comment)" <div class="questionwall-comment-box" (click)="focusComment(comment)"
[style.box-shadow]="commentFocus===comment?'inset 0px 0px 0px 1px var(--ars-paragraph-color)':null"> [style.box-shadow]="commentFocus===comment?'inset 0px 0px 0px 1px var(--ars-paragraph-color)':null">
...@@ -24,12 +28,20 @@ ...@@ -24,12 +28,20 @@
</ars-row> </ars-row>
</ars-col> </ars-col>
</ars-fill> </ars-fill>
<ars-row [height]="50" class="questionwall-footer"> <ars-row [height]="50" class="questionwall-footer">
<button (click)="prevComment()">prev</button> <ars-style-btn-material style="width:100%;" ars-flex-box>
<button (click)="nextComment()">next</button> <ars-col ars-btn-wrp [xp]="16" [extra]="true">
<p>new Comments: {{unreadComments}}</p> <button ars-btn (click)="prevComment()"><p>PREVIOUS</p></button>
<button (click)="play()">play</button> <button ars-btn (click)="nextComment()"><p>NEXT</p></button>
<button (click)="stop()">stop</button> </ars-col>
<p>auto focus: {{focusIncommingComments}}</p> <ars-col>
</ars-row> <p style="padding:15px 5px;box-sizing:border-box;" class="questionwall-text-color">new Comments: {{unreadComments}}</p>
</ars-col>
<ars-fill></ars-fill>
<ars-col ars-btn-wrp [xp]="16" [extra]="true">
<button ars-btn (click)="stop()"><p [style.color]="focusIncommingComments?'RED':null">PAUSE</p></button>
<button ars-btn (click)="play()"><p [style.color]="focusIncommingComments?null:'RED'">PLAY</p></button>
</ars-col>
</ars-style-btn-material>
</ars-row>
</ars-screen> </ars-screen>
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
.questionwall{ .questionwall{
&-header{ &-header{
background-color:var(--ars-foreground-color); background-color:var(--ars-foreground-color);
box-shadow:0px 2px 4px rgba(0,0,0,0.3); border-bottom:solid 1px var(--ars-border-color);
z-index:4; z-index:4;
} }
&-footer{ &-footer{
background-color:var(--ars-foreground-color); background-color:var(--ars-foreground-color);
box-shadow:0px -2px 4px rgba(0,0,0,0.3); border-top:solid 1px var(--ars-border-color);
z-index:4; z-index:54;
>*{ >*{
height:100%; height:100%;
float:left; float:left;
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
&-box{ &-box{
background-color:var(--ars-foreground-color); background-color:var(--ars-foreground-color);
border-radius:2px; border-radius:2px;
box-shadow:0px 2px 4px rgba(0,0,0,0.3); box-shadow:0px 2px 2px rgba(0,0,0,0.3);
box-sizing:border-box; box-sizing:border-box;
padding:16px; padding:16px;
cursor:pointer; cursor:pointer;
...@@ -57,6 +57,11 @@ ...@@ -57,6 +57,11 @@
&-screen{ &-screen{
background-color:var(--ars-background-color); background-color:var(--ars-background-color);
} }
&-text{
&-color{
color:var(--ars-paragraph-color);
}
}
} }
} }
...@@ -41,6 +41,7 @@ export class QuestionWallComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -41,6 +41,7 @@ export class QuestionWallComponent implements OnInit, AfterViewInit, OnDestroy {
ngOnInit(): void { ngOnInit(): void {
// StyleDebug.border('c'); // StyleDebug.border('c');
this.commentService.getAckComments(this.roomId).subscribe(e => { this.commentService.getAckComments(this.roomId).subscribe(e => {
e.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
e.forEach(c => { e.forEach(c => {
this.comments.push(new QuestionWallComment(c, true)); this.comments.push(new QuestionWallComment(c, true));
}); });
...@@ -52,7 +53,9 @@ export class QuestionWallComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -52,7 +53,9 @@ export class QuestionWallComponent implements OnInit, AfterViewInit, OnDestroy {
this.commentService.getComment(JSON.parse(e.body).payload.id).subscribe(c => { this.commentService.getComment(JSON.parse(e.body).payload.id).subscribe(c => {
const qwComment = this.pushIncommingComment(c); const qwComment = this.pushIncommingComment(c);
if (this.focusIncommingComments) { if (this.focusIncommingComments) {
this.focusComment(qwComment); setTimeout(() => {
this.focusComment(qwComment);
}, 2);
} }
}); });
}); });
...@@ -76,13 +79,25 @@ export class QuestionWallComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -76,13 +79,25 @@ export class QuestionWallComponent implements OnInit, AfterViewInit, OnDestroy {
this.moveComment(-1); this.moveComment(-1);
} }
getDOMComments() {
return Array.from(document.getElementsByClassName('questionwall-comment-anchor'));
}
getDOMCommentFocus() {
return this.getDOMComments()[this.getCommentFocusIndex()];
}
getCommentFocusIndex() {
return this.comments.indexOf(this.commentFocus);
}
moveComment(fx: number) { moveComment(fx: number) {
if (this.comments.length === 0) { if (this.comments.length === 0) {
return; return;
} else if (!this.commentFocus) { } else if (!this.commentFocus) {
this.focusComment(this.comments[0]); this.focusComment(this.comments[0]);
} else { } else {
const cursor = this.comments.indexOf(this.commentFocus); const cursor = this.getCommentFocusIndex();
if (cursor + fx >= this.comments.length || cursor + fx < 0) { if (cursor + fx >= this.comments.length || cursor + fx < 0) {
return; return;
} else { } else {
...@@ -104,9 +119,10 @@ export class QuestionWallComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -104,9 +119,10 @@ export class QuestionWallComponent implements OnInit, AfterViewInit, OnDestroy {
comment.old = true; comment.old = true;
this.unreadComments--; this.unreadComments--;
} }
setTimeout(() => { this.getDOMCommentFocus().scrollIntoView({
QuestionWallComponent.wrap(this.colComponent.ref.nativeElement, e => e.scrollTop = e.scrollHeight); behavior: 'smooth',
}, 10); block: 'center'
});
} }
play() { play() {
......
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