Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. @Directive({
  2. selector: '.tooltip-container'
  3. })
  4. export class TooltipContainerDirective {
  5. }
  6.  
  7. @Component({
  8. template: `
  9. <div class="tooltip-container" [ngStyle]="{top: top}">
  10. <ng-content></ng-content>
  11. </div>
  12. `,
  13. styles: [...]
  14. })
  15. export class TooltipComponent implements OnInit {
  16. top : string;
  17. @ViewChild(TooltipContainerDirective, { read: ElementRef }) private tooltipContainer;
  18.  
  19. constructor( @Inject('tooltipConfig') private config ) {
  20. }
  21.  
  22. ngOnInit() {
  23. const { top } = this.config.host.getBoundingClientRect();
  24. const { height } = this.tooltipContainer.nativeElement.getBoundingClientRect();
  25. this.top = `${top - height}px`;
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement