Fixed ngAfterwViewChecked, now compute size with height instead width

This commit is contained in:
Lorenzo Iovino 2017-08-11 14:15:31 +02:00
parent fc5e5e800f
commit 14a7091b53
2 changed files with 6 additions and 4 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "ng2-fittext", "name": "ng2-fittext",
"version": "1.0.22", "version": "1.0.23",
"description": "An Angular2 directive for autoscale the font size of an element to fit an upper level container.", "description": "An Angular2 directive for autoscale the font size of an element to fit an upper level container.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View file

@ -103,7 +103,9 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
} }
ngAfterViewChecked() { ngAfterViewChecked() {
this.setFontSize(this.container ? this.container.clientWidth : this.el.nativeElement.parentElement.clientWidth); if (this.fontSize > this.minFontSize) {
this.setFontSize(this.container ? this.container.clientHeight : this.el.nativeElement.parentElement.clientHeight);
this.ngAfterViewInit(); this.ngAfterViewInit();
} }
} }
}