diff options
author | Chocobozzz <me@florianbigard.com> | 2018-11-15 09:24:56 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-11-15 09:25:32 +0100 |
commit | 2fbe7f1933f4bd5de96e6428234e56965616120e (patch) | |
tree | 7dfd9473d5984a35e35a8395d5da26d3a6c8858d /client/src/app/shared/forms | |
parent | 79c2480f46ba5ffad6131ca599653d8b224b1c32 (diff) | |
download | PeerTube-2fbe7f1933f4bd5de96e6428234e56965616120e.tar.gz PeerTube-2fbe7f1933f4bd5de96e6428234e56965616120e.tar.zst PeerTube-2fbe7f1933f4bd5de96e6428234e56965616120e.zip |
Fix new Angular 7 issues
Diffstat (limited to 'client/src/app/shared/forms')
-rw-r--r-- | client/src/app/shared/forms/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/forms/textarea-autoresize.directive.ts | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/client/src/app/shared/forms/index.ts b/client/src/app/shared/forms/index.ts index 41c321c4c..8febbfee9 100644 --- a/client/src/app/shared/forms/index.ts +++ b/client/src/app/shared/forms/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | export * from './form-validators' | 1 | export * from './form-validators' |
2 | export * from './form-reactive' | 2 | export * from './form-reactive' |
3 | export * from './reactive-file.component' | 3 | export * from './reactive-file.component' |
4 | export * from './textarea-autoresize.directive' | ||
diff --git a/client/src/app/shared/forms/textarea-autoresize.directive.ts b/client/src/app/shared/forms/textarea-autoresize.directive.ts new file mode 100644 index 000000000..f8c855c16 --- /dev/null +++ b/client/src/app/shared/forms/textarea-autoresize.directive.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | // Thanks: https://github.com/evseevdev/ngx-textarea-autosize | ||
2 | import { AfterViewInit, Directive, ElementRef, HostBinding, HostListener } from '@angular/core' | ||
3 | |||
4 | @Directive({ | ||
5 | selector: 'textarea[myAutoResize]' | ||
6 | }) | ||
7 | export class TextareaAutoResizeDirective implements AfterViewInit { | ||
8 | @HostBinding('attr.rows') rows = '1' | ||
9 | @HostBinding('style.overflow') overflow = 'hidden' | ||
10 | |||
11 | constructor (private elem: ElementRef) { } | ||
12 | |||
13 | public ngAfterViewInit () { | ||
14 | this.resize() | ||
15 | } | ||
16 | |||
17 | @HostListener('input') | ||
18 | resize () { | ||
19 | const textarea = this.elem.nativeElement as HTMLTextAreaElement | ||
20 | // Reset textarea height to auto that correctly calculate the new height | ||
21 | textarea.style.height = 'auto' | ||
22 | // Set new height | ||
23 | textarea.style.height = `${textarea.scrollHeight}px` | ||
24 | } | ||
25 | } | ||