Skip to content

Instantly share code, notes, and snippets.

@ssougnez
Created June 9, 2018 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssougnez/f90d0a82e85da61f80c6048b4ac80141 to your computer and use it in GitHub Desktop.
Save ssougnez/f90d0a82e85da61f80c6048b4ac80141 to your computer and use it in GitHub Desktop.
import { fromEvent } from "rxjs";
import { debounceTime, map } from "rxjs/operators";
let span = document.querySelector("#span-location");
fromEvent(document, "mousemove")
.pipe(
map((e) => {
return { x: e.clientX, y: e.clientY };
}),
debounceTime(100)
)
.subscribe((e) => {
span.innerHTML = `X: ${e.x} - Y: ${e.y}`;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment