@liiift-studio/mac-os9-ui 0.2.24 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +25 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -839,10 +839,14 @@ const Window = React.forwardRef(({ children, title, titleBar, active = true, wid
|
|
|
839
839
|
if (!windowElement)
|
|
840
840
|
return;
|
|
841
841
|
const rect = windowElement.getBoundingClientRect();
|
|
842
|
-
//
|
|
842
|
+
// Get the parent container to calculate position relative to it
|
|
843
|
+
const parent = windowElement.offsetParent;
|
|
844
|
+
const parentRect = parent ? parent.getBoundingClientRect() : { left: 0, top: 0 };
|
|
845
|
+
// Store drag start info - offset from mouse to window position within parent
|
|
846
|
+
// This accounts for the parent's coordinate system
|
|
843
847
|
dragStartRef.current = {
|
|
844
|
-
x: event.clientX - rect.left,
|
|
845
|
-
y: event.clientY - rect.top,
|
|
848
|
+
x: event.clientX - (rect.left - parentRect.left),
|
|
849
|
+
y: event.clientY - (rect.top - parentRect.top),
|
|
846
850
|
};
|
|
847
851
|
setIsDragging(true);
|
|
848
852
|
}, [draggable]);
|
|
@@ -854,9 +858,25 @@ const Window = React.forwardRef(({ children, title, titleBar, active = true, wid
|
|
|
854
858
|
event.preventDefault();
|
|
855
859
|
if (!dragStartRef.current)
|
|
856
860
|
return;
|
|
861
|
+
// Get the window element to find its parent
|
|
862
|
+
const windowElements = document.querySelectorAll(`.${styles$6.window}`);
|
|
863
|
+
let windowElement = null;
|
|
864
|
+
// Find the dragging window (the one with position absolute or the first one)
|
|
865
|
+
for (const el of Array.from(windowElements)) {
|
|
866
|
+
const htmlEl = el;
|
|
867
|
+
if (htmlEl.style.position === 'absolute' || windowElements.length === 1) {
|
|
868
|
+
windowElement = htmlEl;
|
|
869
|
+
break;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
if (!windowElement)
|
|
873
|
+
return;
|
|
874
|
+
// Get parent container to calculate position relative to it
|
|
875
|
+
const parent = windowElement.offsetParent;
|
|
876
|
+
const parentRect = parent ? parent.getBoundingClientRect() : { left: 0, top: 0 };
|
|
857
877
|
const newPosition = {
|
|
858
|
-
x: event.clientX - dragStartRef.current.x,
|
|
859
|
-
y: event.clientY - dragStartRef.current.y,
|
|
878
|
+
x: event.clientX - parentRect.left - dragStartRef.current.x,
|
|
879
|
+
y: event.clientY - parentRect.top - dragStartRef.current.y,
|
|
860
880
|
};
|
|
861
881
|
// Update position
|
|
862
882
|
if (controlledPosition && onPositionChange) {
|