mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
945 B
36 lines
945 B
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
|
|
*/
|
|
|
|
import { Directive, ElementRef, HostListener, Input, Renderer2 } from '@angular/core';
|
|
|
|
@Directive({
|
|
selector: '[sqxHoverBackground]'
|
|
})
|
|
export class HoverBackgroundDirective {
|
|
private previousBackground: string | null;
|
|
|
|
@Input('sqxHoverBackground')
|
|
public background: string;
|
|
|
|
constructor(
|
|
private readonly element: ElementRef,
|
|
private readonly renderer: Renderer2
|
|
) {
|
|
}
|
|
|
|
@HostListener('mouseenter')
|
|
public onEnter() {
|
|
this.previousBackground = (<HTMLElement>this.element.nativeElement).style.background;
|
|
|
|
this.renderer.setStyle(this.element.nativeElement, 'background', this.background);
|
|
}
|
|
|
|
@HostListener('mouseleave')
|
|
public onLEave() {
|
|
this.renderer.setStyle(this.element.nativeElement, 'background', this.previousBackground);
|
|
}
|
|
}
|