aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/generativeFill/generativeFillUtils/PointerHandler.ts
blob: 9e620ad1174a0a486478a1333d9413e1322d0f93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { Point } from "./generativeFillInterfaces";

export class PointerHandler {
  static getPointRelativeToElement = (
    element: HTMLElement,
    e: React.PointerEvent | PointerEvent,
    scale: number
  ): Point => {
    const boundingBox = element.getBoundingClientRect();
    return {
      x: (e.clientX - boundingBox.x) / scale,
      y: (e.clientY - boundingBox.y) / scale,
    };
  };
}