mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-05 14:47:40 +03:00
Merge pull request #106 from ibs0d/claude/add-fit-to-screen-mode-XvHoV
Fix fit-to-screen drag reset: use primitive deps in fitLayoutOverride…
This commit is contained in:
commit
4f7d3f41b5
@ -471,7 +471,12 @@ export default function DraggableGridLayout({
|
||||
|
||||
useEffect(() => {
|
||||
setFitLayoutOverride(undefined);
|
||||
}, [fitGridParams, cameras, includeBirdseye]);
|
||||
}, [
|
||||
fitGridParams?.gridUnitsPerCam,
|
||||
fitGridParams?.colsPerRow,
|
||||
cameras,
|
||||
includeBirdseye,
|
||||
]);
|
||||
|
||||
const handleFitDragStop = useCallback(
|
||||
(
|
||||
@ -481,10 +486,7 @@ export default function DraggableGridLayout({
|
||||
_placeholder: LayoutItem | null,
|
||||
_event: Event,
|
||||
) => {
|
||||
if (!fitToScreen || !fitGridParams || !newItem) {
|
||||
console.log("[FitDrag] SKIP: early return", { fitToScreen, fitGridParams: !!fitGridParams, newItem: !!newItem });
|
||||
return;
|
||||
}
|
||||
if (!fitToScreen || !fitGridParams || !newItem) return;
|
||||
|
||||
const w = fitGridParams.gridUnitsPerCam;
|
||||
const colsPerRow = fitGridParams.colsPerRow;
|
||||
@ -512,22 +514,6 @@ export default function DraggableGridLayout({
|
||||
|
||||
const sourceIndex = orderedNames.indexOf(draggedId);
|
||||
|
||||
console.log("[FitDrag] CALC:", {
|
||||
draggedId,
|
||||
sourceIndex,
|
||||
targetIndex,
|
||||
targetCol,
|
||||
targetRow,
|
||||
clampedRow,
|
||||
totalRows,
|
||||
"newItem.x": newItem.x,
|
||||
"newItem.y": newItem.y,
|
||||
w,
|
||||
colsPerRow,
|
||||
orderedNames,
|
||||
willSwap: sourceIndex !== -1 && sourceIndex !== targetIndex,
|
||||
});
|
||||
|
||||
const snapBack = orderedNames.map((name, index) => ({
|
||||
i: name,
|
||||
x: (index % colsPerRow) * w,
|
||||
@ -537,7 +523,6 @@ export default function DraggableGridLayout({
|
||||
}));
|
||||
|
||||
if (sourceIndex === -1 || sourceIndex === targetIndex) {
|
||||
console.log("[FitDrag] SNAP BACK (no swap)");
|
||||
setFitLayoutOverride(snapBack);
|
||||
return;
|
||||
}
|
||||
@ -556,13 +541,6 @@ export default function DraggableGridLayout({
|
||||
h: w,
|
||||
}));
|
||||
|
||||
console.log("[FitDrag] SWAP:", {
|
||||
from: orderedNames[sourceIndex],
|
||||
to: orderedNames[targetIndex],
|
||||
newOrder,
|
||||
normalized: normalized.map(n => `${n.i}(${n.x},${n.y})`),
|
||||
});
|
||||
|
||||
setFitLayoutOverride(normalized);
|
||||
},
|
||||
[fitToScreen, fitGridParams, fitLayoutOverride, fitLayout],
|
||||
@ -570,13 +548,7 @@ export default function DraggableGridLayout({
|
||||
|
||||
const activeGridLayout = useMemo(() => {
|
||||
if (fitToScreen) {
|
||||
const result = fitLayoutOverride ?? fitLayout ?? currentGridLayout;
|
||||
console.log("[FitDrag] activeGridLayout:", {
|
||||
usingOverride: !!fitLayoutOverride,
|
||||
usingFitLayout: !fitLayoutOverride && !!fitLayout,
|
||||
layout: result?.map(n => `${n.i}(${n.x},${n.y})`),
|
||||
});
|
||||
return result;
|
||||
return fitLayoutOverride ?? fitLayout ?? currentGridLayout;
|
||||
}
|
||||
return currentGridLayout;
|
||||
}, [fitToScreen, fitLayoutOverride, fitLayout, currentGridLayout]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user