aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/generativeFill/generativeFillUtils/PointerHandler.ts
blob: 260923a647e119befaf3850f7f6d7b4a82ddcddb (plain)
1
2
3
4
5
6
7
8
9
10
11
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,
        };
    };
}