print commit

This commit is contained in:
Lotte Hofstede
2017-12-18 13:57:01 +01:00
parent 71a8ed05d1
commit d7c2b09697
2 changed files with 11 additions and 4 deletions

View File

@@ -1 +1,2 @@
<span dsShave [shave]="{character: '...'}" [shaveHeight]="height | async" [innerHTML]="innerHTML"></span>
<span dsShave [shave]="{character: '...'}" [shaveHeight]="styles.toString()" [innerHTML]="innerHTML"></span>
{{print(styles)}}

View File

@@ -11,16 +11,22 @@ import { NativeWindowRef, NativeWindowService } from '../window.service';
selector: 'ds-truncatable',
templateUrl: './truncatable.component.html'
})
export class TruncatableComponent implements AfterViewChecked {
export class TruncatableComponent implements OnInit {
@Input() lines: Observable<number>;
@Input() innerHTML;
@Input() height: Observable<number>;
styles: any;
public constructor(private elementRef:ElementRef, @Inject(NativeWindowService) private _window: NativeWindowRef) { }
ngAfterViewChecked(): void {
ngOnInit(): void {
const lineHeight = this._window.nativeWindow.getComputedStyle(this.elementRef.nativeElement).lineHeight.replace('px', '');
this.styles = this._window.nativeWindow.getComputedStyle(this.elementRef.nativeElement);
this.height = this.lines.map((lines) => (lines * lineHeight)).startWith(0);
this.height.subscribe((h) => console.log('height: ', h));
this.print(this.styles);
}
print(styles) {
console.log(styles);
}
}