diff --git a/package.json b/package.json index 674ee4e..70ca82a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ng2-fittext", - "version": "1.0.19", + "version": "1.0.20", "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 f8f568a..1ed4ed4 100644 --- a/src/ng2fittext.directive.ts +++ b/src/ng2fittext.directive.ts @@ -73,13 +73,14 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit { : this.checkOverflow(this.el.nativeElement.parentElement, this.el.nativeElement); if (overflow) { this.setFontSize(this.calculateFontSize(this.fontSize, this.speed)); + this.ngAfterViewInit(); + } else { if (this.useMaxFontSize) { - if(this.fontSize > this.maxFontSize){ + if(this.fontSize > this.maxFontSize) { this.maxFontSize = parseInt(window.getComputedStyle(this.el.nativeElement).fontSize, null); this.setFontSize(this.maxFontSize); } } - this.ngAfterViewInit(); } } }