|
|
@ -1,21 +1,19 @@ |
|
|
|
import { Directive, ElementRef, HostListener, Renderer2 } from '@angular/core'; |
|
|
|
import { Directive, HostBinding, HostListener } from '@angular/core'; |
|
|
|
|
|
|
|
@Directive({ |
|
|
|
selector: '[appOverHighlight]' |
|
|
|
selector: '[appOverHighlight]', |
|
|
|
}) |
|
|
|
export class OverHighlightDirective { |
|
|
|
@HostBinding('class.overing') |
|
|
|
isOvering = false; |
|
|
|
|
|
|
|
constructor(private elRef: ElementRef, private renderer: Renderer2) { |
|
|
|
|
|
|
|
} |
|
|
|
@HostListener('mouseover') |
|
|
|
onMouseOver() { |
|
|
|
this.renderer.setStyle(this.elRef.nativeElement, 'color', 'red'); |
|
|
|
this.isOvering = true; |
|
|
|
} |
|
|
|
|
|
|
|
@HostListener('mouseout') |
|
|
|
onMouseOut() { |
|
|
|
this.renderer.removeStyle(this.elRef.nativeElement, 'color'); |
|
|
|
this.isOvering = false; |
|
|
|
} |
|
|
|
|
|
|
|
} |