diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 36a6239..428dc97 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,19 +4,13 @@
-
+
-
-
-
-
-
-
@@ -89,54 +83,57 @@
-
-
+
+
-
+
-
+
-
+
-
-
+
+
+
-
+
+
-
-
-
-
+
+
+
+
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
-
+
@@ -144,10 +141,13 @@
-
+
-
-
+
+
+
+
+
@@ -155,48 +155,55 @@
-
-
+
+
-
-
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -205,13 +212,10 @@
-
+
-
-
-
-
-
+
+
@@ -228,8 +232,8 @@
-
-
+
+
@@ -257,8 +261,11 @@
tar
maxFontSize
useMax
- use
useFont
+ use
+ useMA
+ console
+ this.maxFontSize
Ngx
@@ -286,13 +293,14 @@
-
-
-
+
+
+
-
+
+
@@ -325,7 +333,6 @@
-
@@ -338,12 +345,6 @@
-
-
-
-
-
-
@@ -362,6 +363,14 @@
+
+
+
+
+
+
+
+
@@ -377,6 +386,7 @@
+
@@ -389,7 +399,7 @@
-
+
@@ -409,7 +419,7 @@
-
+
@@ -440,13 +450,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -474,12 +496,14 @@
-
+
+
+
-
+
@@ -491,7 +515,7 @@
-
+
@@ -577,9 +601,6 @@
-
-
-
@@ -600,65 +621,44 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
+
+
+
-
-
+
+
-
+
@@ -673,50 +673,81 @@
-
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
diff --git a/examples/dev/src/app/app.component.html b/examples/dev/src/app/app.component.html
index 9cbc1f6..5f9ade3 100644
--- a/examples/dev/src/app/app.component.html
+++ b/examples/dev/src/app/app.component.html
@@ -1,4 +1,4 @@
-Add text or remove text from div
+Add text or remove text from div (max and min font size)
+
+Add text or remove text from div (no max and no min font size)
+
+
+
Write text in input box (text fit inside without overflowing)
diff --git a/examples/dev/src/app/ng2-fittext.directive.ts b/examples/dev/src/app/ng2-fittext.directive.ts
index 36c8d10..be04819 100644
--- a/examples/dev/src/app/ng2-fittext.directive.ts
+++ b/examples/dev/src/app/ng2-fittext.directive.ts
@@ -31,7 +31,6 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
setFontSize(fontSize: number) {
if (this.isVisible() && !this.done) {
if (fontSize < this.minFontSize) {
- // force that font size will never be lower than minimal allowed font size
fontSize = this.minFontSize;
}
if(fontSize > this.maxFontSize){
@@ -44,7 +43,6 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
}
calculateFontSize(fontSize: number, speed: number) {
- // TODO Do with Gauss
return Math.floor(fontSize / speed);
}
@@ -79,14 +77,6 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
ngOnInit() {
this.done = false;
- const fontSize = this.getComputetStyle().fontSize;
- if (fontSize) {
- this.maxFontSize = parseInt(fontSize, undefined);
- }
- if (this.fittext) {
- this.setFontSize(this.maxFontSize);
- }
-
this.el.nativeElement.style.setProperty('will-change', 'content');
this.ngAfterViewInit();
}
@@ -103,13 +93,6 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
this.ngAfterViewInit();
}
} else {
- if (this.fontSize > this.maxFontSize) {
- const fontSize = this.getComputetStyle().fontSize;
- if (fontSize) {
- this.maxFontSize = parseInt(fontSize, undefined);
- this.setFontSize(this.maxFontSize);
- }
- }
this.done = true;
}
}
@@ -134,10 +117,6 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
}
}
- private getComputetStyle(): CSSStyleDeclaration {
- return window.getComputedStyle(this.container ? this.container : this.el.nativeElement.parentElement);
- }
-
private getStartFontSizeFromHeight(): number {
return this.container ? this.container.clientHeight : this.el.nativeElement.parentElement.clientHeight;
}
diff --git a/package.json b/package.json
index 08f178d..ffa1183 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ng2-fittext",
- "version": "1.2.3",
+ "version": "1.2.4",
"description": "Ng2 Fittext, an Angular library",
"main": "./bundles/ng2-fittext.umd.js",
"module": "./ng2-fittext.es5.js",
diff --git a/publishPackage.json b/publishPackage.json
index 197a9cd..9070969 100644
--- a/publishPackage.json
+++ b/publishPackage.json
@@ -1,6 +1,6 @@
{
"name": "ng2-fittext",
- "version": "1.2.3",
+ "version": "1.2.4",
"description": "Ng2-fittext: An Angular2+ directive that change the font size until it fit the upper level container dimension.",
"main": "./bundles/ng2-fittext.umd.js",
"module": "./ng2-fittext.es5.js",
diff --git a/src/directives/ng2-fittext.directive.ts b/src/directives/ng2-fittext.directive.ts
index e484a31..8d85b56 100644
--- a/src/directives/ng2-fittext.directive.ts
+++ b/src/directives/ng2-fittext.directive.ts
@@ -31,7 +31,6 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
setFontSize(fontSize: number) {
if (this.isVisible() && !this.done) {
if (fontSize < this.minFontSize) {
- // force that font size will never be lower than minimal allowed font size
fontSize = this.minFontSize;
}
if(fontSize > this.maxFontSize){
@@ -44,7 +43,6 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
}
calculateFontSize(fontSize: number, speed: number) {
- // TODO Do with Gauss
return Math.floor(fontSize / speed);
}
@@ -79,14 +77,6 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
ngOnInit() {
this.done = false;
- const fontSize = this.getComputetStyle().fontSize;
- if (fontSize) {
- this.maxFontSize = parseInt(fontSize, undefined);
- }
- if (this.fittext) {
- this.setFontSize(this.maxFontSize);
- }
-
this.el.nativeElement.style.setProperty('will-change', 'content');
this.ngAfterViewInit();
}
@@ -103,13 +93,6 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
this.ngAfterViewInit();
}
} else {
- if (this.fontSize > this.maxFontSize) {
- const fontSize = this.getComputetStyle().fontSize;
- if (fontSize) {
- this.maxFontSize = parseInt(fontSize, undefined);
- this.setFontSize(this.maxFontSize);
- }
- }
this.done = true;
}
}
@@ -134,10 +117,6 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
}
}
- private getComputetStyle(): CSSStyleDeclaration {
- return window.getComputedStyle(this.container ? this.container : this.el.nativeElement.parentElement);
- }
-
private getStartFontSizeFromHeight(): number {
return this.container ? this.container.clientHeight : this.el.nativeElement.parentElement.clientHeight;
}