Skip to content

Instantly share code, notes, and snippets.

@realtomaszkula
Last active August 6, 2018 09:19
Show Gist options
  • Save realtomaszkula/47147de5ea2a9aa68329127bfc24c10b to your computer and use it in GitHub Desktop.
Save realtomaszkula/47147de5ea2a9aa68329127bfc24c10b to your computer and use it in GitHub Desktop.
export class GradientButtonComponent {
isGradientVisible = false;
gradientTop: number;
gradientLeft: number;
constructor(public el: ElementRef<HTMLElement>) {}
@HostListener('mouseenter')
onMouseEnter() {
this.isGradientVisible = true;
}
@HostListener('mouseleave')
onMouseLeave() {
this.isGradientVisible = false;
}
@HostListener('mousemove', ['$event'])
onMouseMove(event: MouseEvent) {
this.gradientLeft = event.pageX - this.el.nativeElement.offsetLeft;
this.gradientTop = event.pageY - this.el.nativeElement.offsetTop;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment