From ff9b79d9562f1f69e327b0a9c9f67df4aa277286 Mon Sep 17 00:00:00 2001 From: Lorenzo Iovino Date: Mon, 19 Jun 2017 11:54:44 +0200 Subject: [PATCH] Can't stop to commit fixes, need to sleep. Last fix and last version for today. --- package.json | 2 +- src/ng2fittext.directive.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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); } }