Use globals on grid for resizing/dragging flags

This commit is contained in:
Josh Hawkins 2024-06-13 13:25:20 -05:00
parent e56ce993df
commit de432d7dd5

View File

@ -97,8 +97,9 @@ export default function DraggableGridLayout({
const [showCircles, setShowCircles] = useState(true); const [showCircles, setShowCircles] = useState(true);
useEffect(() => { useEffect(() => {
setIsEditMode(false);
setEditGroup(false); setEditGroup(false);
}, [cameraGroup]); }, [cameraGroup, setIsEditMode]);
// camera state // camera state
@ -185,8 +186,6 @@ export default function DraggableGridLayout({
y: 0, // don't set y, grid does automatically y: 0, // don't set y, grid does automatically
w: width, w: width,
h: height, h: height,
isDraggable: isEditMode,
isResizable: isEditMode,
}; };
optionsMap.push(options); optionsMap.push(options);
@ -195,7 +194,6 @@ export default function DraggableGridLayout({
return optionsMap; return optionsMap;
}, [ }, [
cameras, cameras,
isEditMode,
isGridLayoutLoaded, isGridLayoutLoaded,
currentGridLayout, currentGridLayout,
includeBirdseye, includeBirdseye,
@ -204,17 +202,7 @@ export default function DraggableGridLayout({
useEffect(() => { useEffect(() => {
if (currentGridLayout) { if (currentGridLayout) {
const updatedGridLayout = currentGridLayout.map((layout) => ({ setGridLayout(currentGridLayout);
...layout,
isDraggable: isEditMode,
isResizable: isEditMode,
}));
if (isEditMode) {
setGridLayout(updatedGridLayout);
setCurrentGridLayout(updatedGridLayout);
} else {
setGridLayout(updatedGridLayout);
}
} }
// we know that these deps are correct // we know that these deps are correct
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
@ -406,6 +394,8 @@ export default function DraggableGridLayout({
onResize={handleResize} onResize={handleResize}
onResizeStart={() => setShowCircles(false)} onResizeStart={() => setShowCircles(false)}
onResizeStop={handleLayoutChange} onResizeStop={handleLayoutChange}
isDraggable={isEditMode}
isResizable={isEditMode}
> >
{includeBirdseye && birdseyeConfig?.enabled && ( {includeBirdseye && birdseyeConfig?.enabled && (
<BirdseyeLivePlayerGridItem <BirdseyeLivePlayerGridItem