Exposed as module
This commit is contained in:
parent
6f7cfd8479
commit
8d6dfd3cd0
9 changed files with 23 additions and 15 deletions
13
README.md
13
README.md
|
|
@ -18,17 +18,14 @@ $ npm install --save ng2-fittext
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
Import it in your Angular2 project like a directive
|
Import it in your Angular2 project like a module
|
||||||
|
|
||||||
1) Declare it in your module
|
1) Declare it in your module
|
||||||
```sh
|
```sh
|
||||||
import {FittextDirective} from "ng2-fittext/ng2-fittext";
|
import {Ng2FittextModule} from "ng2-fittext/ng2-fittext";
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
...
|
Ng2FittextModule
|
||||||
],
|
|
||||||
declarations: [
|
|
||||||
FittextDirective
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -41,7 +38,7 @@ Import it in your Angular2 project like a directive
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'label',
|
selector: 'label',
|
||||||
template: `<div #container>
|
template: `<div #container>
|
||||||
<div [fittext]="true" [onResize]="true" [container]="container">Bla bla bla...</div>
|
<div [fittext]="true" [activateOnResize]="true" [container]="container">Bla bla bla...</div>
|
||||||
</div>`
|
</div>`
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -55,7 +52,7 @@ Import it in your Angular2 project like a directive
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| fittext | is the selector of the directive | true/false
|
| fittext | is the selector of the directive | true/false
|
||||||
| container | the container to fit | ElementRef
|
| container | the container to fit | ElementRef
|
||||||
| onResize | enable/disable the autofit in case of window resize | true or false (default false)
|
| activateOnResize | enable/disable the autofit in case of window resize | true or false (default false)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
2
index.ts
2
index.ts
|
|
@ -1 +1 @@
|
||||||
export {FittextDirective} from './src/fittext.directive';
|
export {Ng2FittextModule} from './src/ng2fittext.module';
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
export {FittextDirective} from './src/fittext.directive';
|
|
||||||
1
ng2fittext.ts
Normal file
1
ng2fittext.ts
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export {Ng2FittextModule} from './src/ng2fittext.module';
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ng2-fittext",
|
"name": "ng2-fittext",
|
||||||
"version": "1.0.3",
|
"version": "1.0.5",
|
||||||
"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": {
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@ import {Directive, ElementRef, Renderer, Input, AfterViewInit, HostListener} fro
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[fittext]'
|
selector: '[fittext]'
|
||||||
})
|
})
|
||||||
export class FittextDirective implements AfterViewInit {
|
export class Ng2FittextDirective implements AfterViewInit {
|
||||||
|
|
||||||
@Input('fittext') fittext: any;
|
@Input('fittext') fittext: any;
|
||||||
@Input('container') container: any;
|
@Input('container') container: any;
|
||||||
@Input('onResize') activateOnResize: boolean;
|
@Input('activateOnResize') activateOnResize: boolean;
|
||||||
public fontSize:number = 0;
|
public fontSize:number = 0;
|
||||||
public speed:number = 1.05;
|
public speed:number = 1.05;
|
||||||
|
|
||||||
11
src/ng2fittext.module.ts
Normal file
11
src/ng2fittext.module.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { Ng2FittextDirective } from "./ng2fittext.directive";
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
Ng2FittextDirective
|
||||||
|
],
|
||||||
|
exports: [Ng2FittextDirective]
|
||||||
|
})
|
||||||
|
|
||||||
|
export class Ng2FittextModule {};
|
||||||
|
|
@ -12,8 +12,8 @@
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ng2-fittext.ts",
|
"ng2fittext.ts",
|
||||||
"ng2-fittext.d.ts",
|
"ng2fittext.d.ts",
|
||||||
"index.ts"
|
"index.ts"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue