aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/comment/video-comments.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-14 11:25:49 +0200
committerChocobozzz <me@florianbigard.com>2018-06-14 11:43:19 +0200
commitbf079b7bfd7f0fb75ceb28e333bb4b74d8840dd4 (patch)
treeb6d9c153eff0485f154311870a10dddc7f0fe14f /client/src/app/videos/+video-watch/comment/video-comments.component.ts
parent4dae00e68b71ee3725a94eef891f3c43e10040b0 (diff)
downloadPeerTube-bf079b7bfd7f0fb75ceb28e333bb4b74d8840dd4.tar.gz
PeerTube-bf079b7bfd7f0fb75ceb28e333bb4b74d8840dd4.tar.zst
PeerTube-bf079b7bfd7f0fb75ceb28e333bb4b74d8840dd4.zip
Automatically jump to the highlighted thread
Diffstat (limited to 'client/src/app/videos/+video-watch/comment/video-comments.component.ts')
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.ts15
1 files changed, 13 insertions, 2 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
index 72f66ff09..274c32d31 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
@@ -1,4 +1,4 @@
1import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core' 1import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild, ElementRef } from '@angular/core'
2import { ActivatedRoute } from '@angular/router' 2import { ActivatedRoute } from '@angular/router'
3import { ConfirmService } from '@app/core' 3import { ConfirmService } from '@app/core'
4import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
@@ -19,6 +19,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
19 styleUrls: ['./video-comments.component.scss'] 19 styleUrls: ['./video-comments.component.scss']
20}) 20})
21export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { 21export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
22 @ViewChild('commentHighlightBlock') commentHighlightBlock: ElementRef
22 @Input() video: VideoDetails 23 @Input() video: VideoDetails
23 @Input() user: User 24 @Input() user: User
24 25
@@ -76,7 +77,17 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
76 this.threadComments[commentId] = res 77 this.threadComments[commentId] = res
77 this.threadLoading[commentId] = false 78 this.threadLoading[commentId] = false
78 79
79 if (highlightThread) this.highlightedThread = new VideoComment(res.comment) 80 if (highlightThread) {
81 this.highlightedThread = new VideoComment(res.comment)
82
83 // Scroll to the highlighted thread
84 setTimeout(() => {
85 // -60 because of the fixed header
86 console.log(this.commentHighlightBlock.nativeElement.offsetTop)
87 const scrollY = this.commentHighlightBlock.nativeElement.offsetTop - 60
88 window.scroll(0, scrollY)
89 }, 500)
90 }
80 }, 91 },
81 92
82 err => this.notificationsService.error(this.i18n('Error'), err.message) 93 err => this.notificationsService.error(this.i18n('Error'), err.message)