aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorkimsible <kimsible@users.noreply.github.com>2020-11-17 15:42:45 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-18 09:08:21 +0100
commit363726fe9aedfad3c5c4c593f4e5b7a92656c090 (patch)
treecaaa0f40861a73489f5822127e3ebd33f69c43c8
parent11c449eb1e7f1461125c86127c4a20db18954409 (diff)
downloadPeerTube-363726fe9aedfad3c5c4c593f4e5b7a92656c090.tar.gz
PeerTube-363726fe9aedfad3c5c4c593f4e5b7a92656c090.tar.zst
PeerTube-363726fe9aedfad3c5c4c593f4e5b7a92656c090.zip
Memorize scroll position when maximized mode used with markdown textarea
-rw-r--r--client/src/app/shared/shared-forms/markdown-textarea.component.ts9
1 files changed, 8 insertions, 1 deletions
diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.ts b/client/src/app/shared/shared-forms/markdown-textarea.component.ts
index 8dad5314c..d47f22d1d 100644
--- a/client/src/app/shared/shared-forms/markdown-textarea.component.ts
+++ b/client/src/app/shared/shared-forms/markdown-textarea.component.ts
@@ -1,3 +1,4 @@
1import { ViewportScroller } from '@angular/common'
1import truncate from 'lodash-es/truncate' 2import truncate from 'lodash-es/truncate'
2import { Subject } from 'rxjs' 3import { Subject } from 'rxjs'
3import { debounceTime, distinctUntilChanged } from 'rxjs/operators' 4import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
@@ -35,8 +36,12 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
35 isMaximized = false 36 isMaximized = false
36 37
37 private contentChanged = new Subject<string>() 38 private contentChanged = new Subject<string>()
39 private scrollPosition: [number, number]
38 40
39 constructor (private markdownService: MarkdownService) {} 41 constructor (
42 private viewportScroller: ViewportScroller,
43 private markdownService: MarkdownService
44 ) { }
40 45
41 ngOnInit () { 46 ngOnInit () {
42 this.contentChanged 47 this.contentChanged
@@ -86,11 +91,13 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
86 } 91 }
87 92
88 private lockBodyScroll () { 93 private lockBodyScroll () {
94 this.scrollPosition = this.viewportScroller.getScrollPosition()
89 document.getElementById('content').classList.add('lock-scroll') 95 document.getElementById('content').classList.add('lock-scroll')
90 } 96 }
91 97
92 private unlockBodyScroll () { 98 private unlockBodyScroll () {
93 document.getElementById('content').classList.remove('lock-scroll') 99 document.getElementById('content').classList.remove('lock-scroll')
100 this.viewportScroller.scrollToPosition(this.scrollPosition)
94 } 101 }
95 102
96 private async updatePreviews () { 103 private async updatePreviews () {