Added resize on contentViewChanged hook

This commit is contained in:
Lorenzo Iovino 2017-08-11 12:17:03 +02:00
parent 7106f1df24
commit 1c87abbf2a
2 changed files with 8 additions and 3 deletions

View file

@ -1,9 +1,9 @@
import {Directive, ElementRef, Renderer, Input, AfterViewInit, HostListener, OnInit, OnChanges, SimpleChanges} from '@angular/core';
import {Directive, ElementRef, Renderer, Input, AfterViewInit, AfterViewChecked, HostListener, OnInit, OnChanges, SimpleChanges} from '@angular/core';
@Directive({
selector: '[fittext]'
})
export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges {
export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, AfterViewChecked {
@Input('fittext') fittext: any;
@Input('activateOnResize') activateOnResize: boolean;
@ -101,4 +101,9 @@ export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges {
setTimeout(_ => this.ngAfterViewInit() );
}
}
ngAfterViewChecked() {
this.setFontSize(this.container ? this.container.clientWidth : this.el.nativeElement.parentElement.clientWidth);
this.ngAfterViewInit();
}
}