diff --git a/package.json b/package.json index cfba17a..267a6be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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.", "main": "index.js", "scripts": { diff --git a/src/ng2fittext.directive.ts b/src/ng2fittext.directive.ts index 7b2207b..e38c07d 100644 --- a/src/ng2fittext.directive.ts +++ b/src/ng2fittext.directive.ts @@ -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(); + } } }