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

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