Exposed as module

This commit is contained in:
Lorenzo Iovino 2017-03-16 23:03:48 +01:00
parent 6f7cfd8479
commit 8d6dfd3cd0
9 changed files with 23 additions and 15 deletions

View file

@ -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)

View file

@ -1 +1 @@
export {FittextDirective} from './src/fittext.directive'; export {Ng2FittextModule} from './src/ng2fittext.module';

View file

@ -1 +0,0 @@
export {FittextDirective} from './src/fittext.directive';

1
ng2fittext.ts Normal file
View file

@ -0,0 +1 @@
export {Ng2FittextModule} from './src/ng2fittext.module';

View file

@ -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": {

View file

@ -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
View file

@ -0,0 +1,11 @@
import { NgModule } from '@angular/core';
import { Ng2FittextDirective } from "./ng2fittext.directive";
@NgModule({
declarations: [
Ng2FittextDirective
],
exports: [Ng2FittextDirective]
})
export class Ng2FittextModule {};

View file

@ -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"
] ]
} }