@liiift-studio/mac-os9-ui 0.2.26 → 0.3.2
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/README.md +29 -2
- package/dist/base.css +99 -0
- package/dist/base.css.map +1 -0
- package/dist/index.cjs +8 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +7 -57
- package/dist/index.css.map +1 -1
- package/dist/index.js +8 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -817,6 +817,9 @@ var styles$6 = {"window":"Window-module_window","window--active":"Window-module_
|
|
|
817
817
|
* ```
|
|
818
818
|
*/
|
|
819
819
|
const Window = 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) => {
|
|
820
|
+
// Ref to store the window element being dragged
|
|
821
|
+
// This avoids the need for DOM queries during mousemove
|
|
822
|
+
const dragWindowRef = useRef(null);
|
|
820
823
|
// Drag state management
|
|
821
824
|
const [internalPosition, setInternalPosition] = useState(defaultPosition || null);
|
|
822
825
|
const [isDragging, setIsDragging] = useState(false);
|
|
@@ -846,6 +849,8 @@ const Window = forwardRef(({ children, title, titleBar, active = true, width = '
|
|
|
846
849
|
const windowElement = event.currentTarget.closest(`.${styles$6.window}`);
|
|
847
850
|
if (!windowElement)
|
|
848
851
|
return;
|
|
852
|
+
// Store the window element reference for use during drag
|
|
853
|
+
dragWindowRef.current = windowElement;
|
|
849
854
|
const rect = windowElement.getBoundingClientRect();
|
|
850
855
|
// Get the parent container to calculate position relative to it
|
|
851
856
|
const parent = windowElement.offsetParent;
|
|
@@ -929,17 +934,8 @@ const Window = forwardRef(({ children, title, titleBar, active = true, width = '
|
|
|
929
934
|
event.preventDefault();
|
|
930
935
|
if (!dragStartRef.current)
|
|
931
936
|
return;
|
|
932
|
-
//
|
|
933
|
-
const
|
|
934
|
-
let windowElement = null;
|
|
935
|
-
// Find the dragging window (the one with position absolute or the first one)
|
|
936
|
-
for (const el of Array.from(windowElements)) {
|
|
937
|
-
const htmlEl = el;
|
|
938
|
-
if (htmlEl.style.position === 'absolute' || windowElements.length === 1) {
|
|
939
|
-
windowElement = htmlEl;
|
|
940
|
-
break;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
937
|
+
// Use the stored window element reference instead of querying the DOM
|
|
938
|
+
const windowElement = dragWindowRef.current;
|
|
943
939
|
if (!windowElement)
|
|
944
940
|
return;
|
|
945
941
|
// Get parent container to calculate position relative to it
|
|
@@ -964,6 +960,7 @@ const Window = forwardRef(({ children, title, titleBar, active = true, width = '
|
|
|
964
960
|
const handleMouseUp = () => {
|
|
965
961
|
setIsDragging(false);
|
|
966
962
|
dragStartRef.current = null;
|
|
963
|
+
dragWindowRef.current = null;
|
|
967
964
|
};
|
|
968
965
|
document.addEventListener('mousemove', handleMouseMove);
|
|
969
966
|
document.addEventListener('mouseup', handleMouseUp);
|