@discoveryjs/discovery
Version:
Frontend framework for rapid data (JSON) analysis, shareable serverless reports and dashboards
15 lines (14 loc) • 487 B
JavaScript
import { passiveCaptureOptions } from "./dom.js";
import { Observer } from "../observer.js";
export const pointerXY = /* @__PURE__ */ (() => {
const lastPointerXYPublisher = new Observer(
{ x: 0, y: 0 },
(newCoords, oldCoords) => newCoords.x !== oldCoords.x || newCoords.y !== oldCoords.y
);
document.addEventListener(
"pointermove",
({ x, y }) => lastPointerXYPublisher.set({ x, y }),
passiveCaptureOptions
);
return lastPointerXYPublisher.readonly;
})();