Missing condition for do work it in case of resize and not overflow

This commit is contained in:
Lorenzo Iovino 2017-06-19 11:49:51 +02:00
parent 85d3b3af89
commit 5173c610e6
2 changed files with 4 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "ng2-fittext", "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.", "description": "An Angular2 directive for autoscale the font size of an element to fit an upper level container.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View file

@ -73,13 +73,14 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit {
: this.checkOverflow(this.el.nativeElement.parentElement, this.el.nativeElement); : this.checkOverflow(this.el.nativeElement.parentElement, this.el.nativeElement);
if (overflow) { if (overflow) {
this.setFontSize(this.calculateFontSize(this.fontSize, this.speed)); this.setFontSize(this.calculateFontSize(this.fontSize, this.speed));
this.ngAfterViewInit();
} else {
if (this.useMaxFontSize) { if (this.useMaxFontSize) {
if(this.fontSize > this.maxFontSize) { if(this.fontSize > this.maxFontSize) {
this.maxFontSize = parseInt(window.getComputedStyle(this.el.nativeElement).fontSize, null); this.maxFontSize = parseInt(window.getComputedStyle(this.el.nativeElement).fontSize, null);
this.setFontSize(this.maxFontSize); this.setFontSize(this.maxFontSize);
} }
} }
this.ngAfterViewInit();
} }
} }
} }