Skip to content

Instantly share code, notes, and snippets.

@ZeevKatz
Last active August 12, 2020 06:21
Show Gist options
  • Save ZeevKatz/b966221c233ca2e5fbfd17f1e081b18b to your computer and use it in GitHub Desktop.
Save ZeevKatz/b966221c233ca2e5fbfd17f1e081b18b to your computer and use it in GitHub Desktop.
@Directive({
selector: "[mouse]",
exportAs: "mouse"
})
export class MouseComponent {
private _state = { x: 0, y: 0 };
get state() {
return this._state;
}
@HostListener("mousemove", ['$event'])
handleMouseMove(event: MouseEvent) {
this._state = {
x: event.clientX,
y: event.clientY
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment