highlight directive added

This commit is contained in:
chsakell
2016-10-03 14:39:19 +03:00
parent 66d1a2a07f
commit f23e285a9f
4 changed files with 35 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
import { Directive, ElementRef, HostListener, Input, Renderer } from '@angular/core';
@Directive({
selector: '[feedHighlight]'
})
export class HighlightDirective {
constructor(private el: ElementRef, private renderer: Renderer) {
this.renderer.setElementClass(this.el.nativeElement, 'feed-highlight', true);
}
@HostListener('mouseenter') onMouseEnter() {
this.highlight('white');
}
@HostListener('mouseleave') onMouseLeave() {
this.highlight(null);
}
private highlight(color: string) {
this.renderer.setElementStyle(this.el.nativeElement, 'backgroundColor', color);
}
}