diff --git a/package.json b/package.json index 70ca82a..e08ff7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ng2-fittext", - "version": "1.0.20", + "version": "1.0.21", "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 1ed4ed4..b3fb0e7 100644 --- a/src/ng2fittext.directive.ts +++ b/src/ng2fittext.directive.ts @@ -57,7 +57,7 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit { ngOnInit() { if (this.useMaxFontSize) { - this.maxFontSize = parseInt(window.getComputedStyle(this.el.nativeElement).fontSize, null); + this.maxFontSize = parseInt(window.getComputedStyle(this.container ? this.container : this.el.nativeElement.parentElement).fontSize, null); } if (this.fittext) { @@ -77,7 +77,7 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit { } else { if (this.useMaxFontSize) { if(this.fontSize > this.maxFontSize) { - this.maxFontSize = parseInt(window.getComputedStyle(this.el.nativeElement).fontSize, null); + this.maxFontSize = parseInt(window.getComputedStyle(this.container ? this.container : this.el.nativeElement.parentElement).fontSize, null); this.setFontSize(this.maxFontSize); } }