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

Commit

Permalink
implemented elastic textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
smukov committed Jun 29, 2016
1 parent 3da81aa commit 28aea16
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions Ionic/app/pages/chatPage/chatPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
</ion-item>
</ion-list>



</ion-content>

<ion-footer class="chatPageFooter">
<ion-toolbar>

<ion-item>
<ion-textarea rows="3"
placeholder="Type to compose"
></ion-textarea>
<!--elastic-textarea placeholder="Type to compose"></elastic-textarea-->
<ion-label style="margin:0px;"></ion-label>
<div item-content style="width:100%;">
<elastic-textarea placeholder="Type to compose" lineHeight="22"></elastic-textarea>
</div>
</ion-item>

<ion-buttons right>
<button style="min-width:45px;">
<ion-icon name="send"></ion-icon>
Expand Down
24 changes: 11 additions & 13 deletions Ionic/app/pages/components/elasticTextarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,31 @@ import {Component, ViewChild} from '@angular/core';

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

onChange(newValue){
console.log('new value');
console.log(newValue);
ngAfterViewInit(){
this.txtArea = this.ionTxtArea._elementRef.nativeElement.children[0];
this.txtArea.style.height = this.lineHeight + "px";
}

expandText(){
console.log('expand textarea');
this.txtArea.nativeElement.style.height = "33px";
this.txtArea.nativeElement.style.height = this.txtArea.nativeElement.scrollHeight + "px";
onChange(newValue){
this.txtArea.style.height = this.lineHeight + "px";
this.txtArea.style.height = this.txtArea.scrollHeight + "px";
}
}
4 changes: 3 additions & 1 deletion Ionic/app/pages/loginPage/loginPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Component} from '@angular/core';
import {NavController} from 'ionic-angular';
import {ProfilePage} from '../profilePage/profilePage';
import {ContactPage} from '../contactPage/contactPage';


@Component({
Expand All @@ -18,6 +19,7 @@ export class LoginPage {
}

login(){
this.nav.setRoot(ProfilePage);
//TODO just for testing
this.nav.setRoot(ContactPage);//ProfilePage);
}
}

0 comments on commit 28aea16

Please sign in to comment.