Ref: maxFontSize instead useMaxFontSize

This commit is contained in:
Lorenzo Iovino 2019-05-03 17:07:42 +02:00
parent ded7196bcc
commit 43d4cf66f4
11 changed files with 275 additions and 252 deletions

View file

@ -18,10 +18,9 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
@Input('activateOnResize') activateOnResize: boolean;
@Input('container') container: HTMLElement;
@Input('activateOnInputEvents') activateOnInputEvents: boolean;
@Input('useMaxFontSize') useMaxFontSize: boolean;
@Input('minFontSize') minFontSize = 7;
@Input('maxFontSize') maxFontSize = 1000;
@Input('modelToWatch') modelToWatch: any;
private maxFontSize = 1000;
private fontSize = 1000;
private speed = 1.05;
private done = false;
@ -35,6 +34,9 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
// force that font size will never be lower than minimal allowed font size
fontSize = this.minFontSize;
}
if(fontSize > this.maxFontSize){
fontSize = this.maxFontSize;
}
this.fontSize = fontSize;
return this.el.nativeElement.style.setProperty('font-size', (fontSize).toString() + 'px');
@ -77,13 +79,10 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
ngOnInit() {
this.done = false;
if (this.useMaxFontSize) {
const fontSize = this.getComputetStyle().fontSize;
if (fontSize) {
this.maxFontSize = parseInt(fontSize, undefined);
}
const fontSize = this.getComputetStyle().fontSize;
if (fontSize) {
this.maxFontSize = parseInt(fontSize, undefined);
}
if (this.fittext) {
this.setFontSize(this.maxFontSize);
}
@ -104,13 +103,11 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, Af
this.ngAfterViewInit();
}
} else {
if (this.useMaxFontSize) {
if (this.fontSize > this.maxFontSize) {
const fontSize = this.getComputetStyle().fontSize;
if (fontSize) {
this.maxFontSize = parseInt(fontSize, undefined);
this.setFontSize(this.maxFontSize);
}
if (this.fontSize > this.maxFontSize) {
const fontSize = this.getComputetStyle().fontSize;
if (fontSize) {
this.maxFontSize = parseInt(fontSize, undefined);
this.setFontSize(this.maxFontSize);
}
}
this.done = true;

View file

@ -1,28 +0,0 @@
{
"name": "angular-amazing",
"version": "1.0.0",
"description": "An amazing module for Angular.",
"main": "bundles/amazing.umd.js",
"module": "index.js",
"typings": "index.d.ts",
"keywords": [
"angular",
"angular2",
"angular 2",
"angular4"
],
"author": "Your name",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/youraccount/angular-amazing.git"
},
"homepage": "https://github.com/youraccount/angular-amazing",
"bugs": {
"url": "https://github.com/youraccount/angular-amazing/issues"
},
"peerDependencies": {
"@angular/core": "^2.4.0 || ^4.0.0",
"rxjs": "^5.0.1"
}
}