aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/imageEditor/imageEditorUtils/PointerHandler.ts
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2025-03-11 17:43:05 +0100
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2025-03-11 17:43:05 +0100
commitfa937182bc93aa2c6faadda80ea998cdfd479b4e (patch)
treecba8e16edcccc6fd2932173484ac444cb79abea2 /src/client/views/nodes/imageEditor/imageEditorUtils/PointerHandler.ts
parentcf91c46cfec6e3e36b9184764016f9c1b5c997d4 (diff)
parent04669ffeb163688c7aefd7b5face7998252abdca (diff)
Merge branch 'master' of https://github.com/brown-dash/Dash-Web into DocCreatorMenu-work
Diffstat (limited to 'src/client/views/nodes/imageEditor/imageEditorUtils/PointerHandler.ts')
-rw-r--r--src/client/views/nodes/imageEditor/imageEditorUtils/PointerHandler.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/client/views/nodes/imageEditor/imageEditorUtils/PointerHandler.ts b/src/client/views/nodes/imageEditor/imageEditorUtils/PointerHandler.ts
new file mode 100644
index 000000000..e86f46636
--- /dev/null
+++ b/src/client/views/nodes/imageEditor/imageEditorUtils/PointerHandler.ts
@@ -0,0 +1,11 @@
+import { Point } from './imageEditorInterfaces';
+
+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,
+ };
+ };
+}