feat(dees-dashboardgrid): enhance drag-and-drop functionality with preview state and previous position tracking
This commit is contained in:
@@ -129,6 +129,7 @@ export const resolveWidgetPlacement = (
|
||||
widgetId: string,
|
||||
next: { x: number; y: number; w?: number; h?: number },
|
||||
columns: number,
|
||||
previousPosition?: DashboardLayoutItem,
|
||||
): PlacementResult | null => {
|
||||
const sourceWidgets = cloneWidgets(widgets);
|
||||
const moving = sourceWidgets.find(widget => widget.id === widgetId);
|
||||
@@ -160,8 +161,9 @@ export const resolveWidgetPlacement = (
|
||||
if (!other.locked && !other.noMove && other.w === moving.w && other.h === moving.h) {
|
||||
const otherClone = sourceWidgets.find(widget => widget.id === other.id);
|
||||
if (otherClone) {
|
||||
otherClone.x = original.x;
|
||||
otherClone.y = original.y;
|
||||
const swapTarget = previousPosition ?? original;
|
||||
otherClone.x = swapTarget.x;
|
||||
otherClone.y = swapTarget.y;
|
||||
return { widgets: sourceWidgets, movedWidgets: [moving.id, otherClone.id], swappedWith: otherClone.id };
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user