Skip to content

Commit b05fb77

Browse files
committed
feat(emitter): adding 'resized' event
1 parent f5b8438 commit b05fb77

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,17 @@ Example
6161
Hello, this is an example of Autosize in Angular2.
6262
</textarea>
6363
```
64+
## Events / Outputs
65+
Name | Description
66+
--- | ---
67+
resized | Called whenever textarea has changes its size. New height as a param.
6468

69+
Example
70+
```
71+
<textarea autosize (resized)="onResized($event)">
72+
You need to implement 'onResized' yourself
73+
</textarea>
74+
```
6575

6676
## Origins
6777
This small lib is based on great

package-lock.json

+9-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-autosize-app",
3-
"version": "1.7.5",
3+
"version": "1.8.0-next",
44
"homepage": "https://chrum.it/pages/ngx-autosize",
55
"description": "Directive that automatically adjusts textarea height to fit content",
66
"repository": {
@@ -46,6 +46,7 @@
4646
"@angular/platform-browser-dynamic": "~8.2.2",
4747
"@angular/router": "~8.2.2",
4848
"core-js": "^2.6.9",
49+
"ngx-autosize": "^1.8.0-next",
4950
"rxjs": "~6.5.2",
5051
"tslib": "^1.10.0",
5152
"zone.js": "~0.9.1"

projects/autosize/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-autosize",
3-
"version": "1.7.5",
3+
"version": "1.8.0-next",
44
"homepage": "https://chrum.it/pages/ngx-autosize",
55
"description": "Directive that automatically adjusts textarea height to fit content",
66
"repository": {

projects/autosize/src/lib/autosize.directive.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
HostListener,
44
Directive,
55
Input,
6-
NgZone, OnDestroy, OnChanges, AfterContentChecked
6+
NgZone, OnDestroy, OnChanges, AfterContentChecked, Output, EventEmitter
77
} from '@angular/core';
88

99
const MAX_LOOKUP_RETRIES = 3;
@@ -26,6 +26,8 @@ export class AutosizeDirective implements OnDestroy, OnChanges, AfterContentChec
2626
@Input() onlyGrow = false;
2727
@Input() useImportant = false;
2828

29+
@Output() resized = new EventEmitter<number>();
30+
2931
private retries = 0;
3032
private textAreaEl: any;
3133

@@ -172,6 +174,8 @@ export class AutosizeDirective implements OnDestroy, OnChanges, AfterContentChec
172174
const important = this.useImportant ? 'important' : '';
173175

174176
this.textAreaEl.style.setProperty('height', heightStyle, important);
177+
178+
this.resized.emit(height);
175179
}
176180

177181
parent.removeChild(clone);

0 commit comments

Comments
 (0)