diff --git a/frontend/app/components/workspace/calendar/lab/CrmCalendarZoomLab.vue b/frontend/app/components/workspace/calendar/lab/CrmCalendarZoomLab.vue index 99e175a..ed17c78 100644 --- a/frontend/app/components/workspace/calendar/lab/CrmCalendarZoomLab.vue +++ b/frontend/app/components/workspace/calendar/lab/CrmCalendarZoomLab.vue @@ -73,6 +73,7 @@ function getRectInScene(element: HTMLElement, scene: HTMLElement) { let x = 0; let y = 0; let node: HTMLElement | null = element; + let reachedScene = false; while (node && node !== scene) { x += node.offsetLeft; @@ -80,6 +81,22 @@ function getRectInScene(element: HTMLElement, scene: HTMLElement) { node = node.offsetParent as HTMLElement | null; } + if (node === scene) { + reachedScene = true; + } + + if (!reachedScene) { + const sceneRect = scene.getBoundingClientRect(); + const elementRect = element.getBoundingClientRect(); + const scale = panzoomRef.value?.getScale() ?? 1; + return { + x: (elementRect.left - sceneRect.left) / Math.max(0.0001, scale), + y: (elementRect.top - sceneRect.top) / Math.max(0.0001, scale), + width: Math.max(1, elementRect.width / Math.max(0.0001, scale)), + height: Math.max(1, elementRect.height / Math.max(0.0001, scale)), + }; + } + return { x, y, @@ -459,6 +476,7 @@ onBeforeUnmount(() => { } .calendar-lab-scene { + position: relative; width: 1400px; height: 900px; will-change: transform;