@liiift-studio/mac-os9-ui 0.3.1 → 0.3.3
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 +8 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +10 -10
- package/dist/index.css.map +1 -1
- package/dist/index.js +8 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -819,6 +819,9 @@ var styles$6 = {"window":"Window-module_window","window--active":"Window-module_
|
|
|
819
819
|
* ```
|
|
820
820
|
*/
|
|
821
821
|
const Window = React.forwardRef(({ children, title, titleBar, active = true, width = 'auto', height = 'auto', className = '', contentClassName = '', classes, showControls = true, onClose, onMinimize, onMaximize, onMouseEnter, resizable = false, minWidth = 200, minHeight = 100, maxWidth, maxHeight, onResize, draggable = false, defaultPosition, position: controlledPosition, onPositionChange, }, ref) => {
|
|
822
|
+
// Ref to store the window element being dragged
|
|
823
|
+
// This avoids the need for DOM queries during mousemove
|
|
824
|
+
const dragWindowRef = React.useRef(null);
|
|
822
825
|
// Drag state management
|
|
823
826
|
const [internalPosition, setInternalPosition] = React.useState(defaultPosition || null);
|
|
824
827
|
const [isDragging, setIsDragging] = React.useState(false);
|
|
@@ -848,6 +851,8 @@ const Window = React.forwardRef(({ children, title, titleBar, active = true, wid
|
|
|
848
851
|
const windowElement = event.currentTarget.closest(`.${styles$6.window}`);
|
|
849
852
|
if (!windowElement)
|
|
850
853
|
return;
|
|
854
|
+
// Store the window element reference for use during drag
|
|
855
|
+
dragWindowRef.current = windowElement;
|
|
851
856
|
const rect = windowElement.getBoundingClientRect();
|
|
852
857
|
// Get the parent container to calculate position relative to it
|
|
853
858
|
const parent = windowElement.offsetParent;
|
|
@@ -931,17 +936,8 @@ const Window = React.forwardRef(({ children, title, titleBar, active = true, wid
|
|
|
931
936
|
event.preventDefault();
|
|
932
937
|
if (!dragStartRef.current)
|
|
933
938
|
return;
|
|
934
|
-
//
|
|
935
|
-
const
|
|
936
|
-
let windowElement = null;
|
|
937
|
-
// Find the dragging window (the one with position absolute or the first one)
|
|
938
|
-
for (const el of Array.from(windowElements)) {
|
|
939
|
-
const htmlEl = el;
|
|
940
|
-
if (htmlEl.style.position === 'absolute' || windowElements.length === 1) {
|
|
941
|
-
windowElement = htmlEl;
|
|
942
|
-
break;
|
|
943
|
-
}
|
|
944
|
-
}
|
|
939
|
+
// Use the stored window element reference instead of querying the DOM
|
|
940
|
+
const windowElement = dragWindowRef.current;
|
|
945
941
|
if (!windowElement)
|
|
946
942
|
return;
|
|
947
943
|
// Get parent container to calculate position relative to it
|
|
@@ -966,6 +962,7 @@ const Window = React.forwardRef(({ children, title, titleBar, active = true, wid
|
|
|
966
962
|
const handleMouseUp = () => {
|
|
967
963
|
setIsDragging(false);
|
|
968
964
|
dragStartRef.current = null;
|
|
965
|
+
dragWindowRef.current = null;
|
|
969
966
|
};
|
|
970
967
|
document.addEventListener('mousemove', handleMouseMove);
|
|
971
968
|
document.addEventListener('mouseup', handleMouseUp);
|