46063: object list truncation start

This commit is contained in:
Lotte Hofstede
2017-11-24 10:45:50 +01:00
parent 07cdf650f8
commit 71a8ed05d1
11 changed files with 90 additions and 7 deletions

View File

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