diff options
author | kimsible <kimsible@users.noreply.github.com> | 2020-11-17 15:42:45 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-18 09:08:21 +0100 |
commit | 363726fe9aedfad3c5c4c593f4e5b7a92656c090 (patch) | |
tree | caaa0f40861a73489f5822127e3ebd33f69c43c8 /client/src/app | |
parent | 11c449eb1e7f1461125c86127c4a20db18954409 (diff) | |
download | PeerTube-363726fe9aedfad3c5c4c593f4e5b7a92656c090.tar.gz PeerTube-363726fe9aedfad3c5c4c593f4e5b7a92656c090.tar.zst PeerTube-363726fe9aedfad3c5c4c593f4e5b7a92656c090.zip |
Memorize scroll position when maximized mode used with markdown textarea
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/shared/shared-forms/markdown-textarea.component.ts | 9 |
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 @@ | |||
1 | import { ViewportScroller } from '@angular/common' | ||
1 | import truncate from 'lodash-es/truncate' | 2 | import truncate from 'lodash-es/truncate' |
2 | import { Subject } from 'rxjs' | 3 | import { Subject } from 'rxjs' |
3 | import { debounceTime, distinctUntilChanged } from 'rxjs/operators' | 4 | import { 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 () { |