Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
creating elastic text area
Browse files Browse the repository at this point in the history
  • Loading branch information
smukov committed Jun 29, 2016
1 parent 741f64e commit 3da81aa
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions Ionic/app/pages/chatPage/chatPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ion-textarea rows="3"
placeholder="Type to compose"
></ion-textarea>
<!--elastic-textarea placeholder="Type to compose"></elastic-textarea-->
</ion-item>
<ion-buttons right>
<button style="min-width:45px;">
Expand Down
3 changes: 2 additions & 1 deletion Ionic/app/pages/chatPage/chatPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import {Component} from '@angular/core';
import {NavController, NavParams} from 'ionic-angular';

import {ChatBubble} from '../components/chatBubble/chatBubble';
import {ElasticTextarea} from '../components/elasticTextarea';

@Component({
templateUrl: 'build/pages/chatPage/chatPage.html',
directives: [ChatBubble]
directives: [ChatBubble, ElasticTextarea]
})
export class ChatPage {
static get parameters() {
Expand Down
34 changes: 34 additions & 0 deletions Ionic/app/pages/components/elasticTextarea.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {Component, ViewChild} from '@angular/core';

@Component({
selector: 'elastic-textarea',
inputs: ['placeholder'],
template:
`
<textarea #txtArea cols='1'
placeholder='{{placeholder}}'
(keyup)='expandText()'
(keydown)='expandText();'
[(ngModel)]="content"
(ngModelChange)='onChange($event)'></textarea>
`,
queries: {
txtArea: new ViewChild('txtArea')
}
})
export class ElasticTextarea {
constructor() {
this.content = "";
}

onChange(newValue){
console.log('new value');
console.log(newValue);
}

expandText(){
console.log('expand textarea');
this.txtArea.nativeElement.style.height = "33px";
this.txtArea.nativeElement.style.height = this.txtArea.nativeElement.scrollHeight + "px";
}
}

0 comments on commit 3da81aa

Please sign in to comment.