Added rxjs in packege.json; Added activateOnInputEvents proprierty for listen the events in input element and resize when it occurs
This commit is contained in:
parent
9dc59fd560
commit
c76d6dbb1a
2 changed files with 14 additions and 4 deletions
|
|
@ -28,7 +28,8 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/lokenxo/ng2-fittext#readme",
|
"homepage": "https://github.com/lokenxo/ng2-fittext#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/core": "^4.0.1"
|
"@angular/core": "^4.0.1",
|
||||||
|
"rxjs": "^5.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "~2.2.2"
|
"typescript": "~2.2.2"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit {
|
||||||
@Input('fittext') fittext: any;
|
@Input('fittext') fittext: any;
|
||||||
@Input('container') container: any;
|
@Input('container') container: any;
|
||||||
@Input('activateOnResize') activateOnResize: boolean;
|
@Input('activateOnResize') activateOnResize: boolean;
|
||||||
|
@Input('activateOnInputEvents') activateOnInputEvents: boolean;
|
||||||
private fontSize: number = 0;
|
private fontSize: number = 0;
|
||||||
private speed: number = 1.05;
|
private speed: number = 1.05;
|
||||||
|
|
||||||
|
|
@ -38,6 +39,14 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@HostListener('input', ['$event'])
|
||||||
|
onInputEvents() {
|
||||||
|
if(this.activateOnInputEvents && this.fittext) {
|
||||||
|
this.setFontSize(this.container.clientHeight);
|
||||||
|
this.ngAfterViewInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.fittext) {
|
if (this.fittext) {
|
||||||
this.setFontSize(this.container.clientWidth);
|
this.setFontSize(this.container.clientWidth);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue