mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
46063: object list truncation start
This commit is contained in:
26
src/app/shared/truncatable/truncatable.component.ts
Normal file
26
src/app/shared/truncatable/truncatable.component.ts
Normal 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));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user