fix: rotation
This commit is contained in:
@@ -266,106 +266,46 @@ export function createDeckStore(
|
||||
if (!layer) return;
|
||||
|
||||
const grid = startGrid ?? { x1: layer.x1, y1: layer.y1, x2: layer.x2, y2: layer.y2 };
|
||||
const orientation = layer.orientation || 'n';
|
||||
|
||||
if (orientation === 'e' || orientation === 'w') {
|
||||
updateLayerConfig(layerProp, {
|
||||
x1: grid.x1 + dyGrid,
|
||||
x2: grid.x2 + dyGrid,
|
||||
y1: grid.y1 + dxGrid,
|
||||
y2: grid.y2 + dxGrid
|
||||
});
|
||||
} else {
|
||||
updateLayerConfig(layerProp, {
|
||||
x1: grid.x1 + dxGrid,
|
||||
x2: grid.x2 + dxGrid,
|
||||
y1: grid.y1 + dyGrid,
|
||||
y2: grid.y2 + dyGrid
|
||||
});
|
||||
}
|
||||
updateLayerConfig(layerProp, {
|
||||
x1: grid.x1 + dxGrid,
|
||||
x2: grid.x2 + dxGrid,
|
||||
y1: grid.y1 + dyGrid,
|
||||
y2: grid.y2 + dyGrid
|
||||
});
|
||||
};
|
||||
|
||||
const resizeLayerCorner = (layerProp: string, anchor: 'nw' | 'ne' | 'sw' | 'se', dxGrid: number, dyGrid: number, startGrid: { x1: number; y1: number; x2: number; y2: number }) => {
|
||||
const layer = getLayerConfig(layerProp);
|
||||
if (!layer) return;
|
||||
|
||||
const orientation = layer.orientation || 'n';
|
||||
|
||||
if (orientation === 'e') {
|
||||
const gridAnchorMap: Record<string, { xKey: string; yKey: string }> = {
|
||||
'nw': { xKey: 'y1', yKey: 'x1' },
|
||||
'ne': { xKey: 'y1', yKey: 'x2' },
|
||||
'sw': { xKey: 'y2', yKey: 'x1' },
|
||||
'se': { xKey: 'y2', yKey: 'x2' }
|
||||
};
|
||||
const { xKey, yKey } = gridAnchorMap[anchor];
|
||||
const updates: Partial<LayerConfig> = {};
|
||||
if (xKey === 'y1') updates.y1 = Math.min(startGrid.y2, startGrid.y1 + dxGrid);
|
||||
if (xKey === 'y2') updates.y2 = Math.max(startGrid.y1, startGrid.y2 + dxGrid);
|
||||
if (yKey === 'x1') updates.x1 = Math.min(startGrid.x2, startGrid.x1 + dyGrid);
|
||||
if (yKey === 'x2') updates.x2 = Math.max(startGrid.x1, startGrid.x2 + dyGrid);
|
||||
updateLayerConfig(layerProp, updates);
|
||||
} else if (orientation === 'w') {
|
||||
const gridAnchorMap: Record<string, { xKey: string; yKey: string }> = {
|
||||
'nw': { xKey: 'y2', yKey: 'x2' },
|
||||
'ne': { xKey: 'y2', yKey: 'x1' },
|
||||
'sw': { xKey: 'y1', yKey: 'x2' },
|
||||
'se': { xKey: 'y1', yKey: 'x1' }
|
||||
};
|
||||
const { xKey, yKey } = gridAnchorMap[anchor];
|
||||
const updates: Partial<LayerConfig> = {};
|
||||
if (xKey === 'y1') updates.y1 = Math.max(1, Math.min(startGrid.y2, startGrid.y1 - dxGrid));
|
||||
if (xKey === 'y2') updates.y2 = Math.max(startGrid.y1, Math.min(state.gridH, startGrid.y2 - dxGrid));
|
||||
if (yKey === 'x1') updates.x1 = Math.max(1, Math.min(startGrid.x2, startGrid.x1 - dyGrid));
|
||||
if (yKey === 'x2') updates.x2 = Math.max(startGrid.x1, Math.min(state.gridW, startGrid.x2 - dyGrid));
|
||||
updateLayerConfig(layerProp, updates);
|
||||
} else {
|
||||
const updates: Partial<LayerConfig> = {};
|
||||
if (anchor === 'nw') {
|
||||
updates.x1 = Math.min(startGrid.x2, startGrid.x1 + dxGrid);
|
||||
updates.y1 = Math.min(startGrid.y2, startGrid.y1 + dyGrid);
|
||||
} else if (anchor === 'ne') {
|
||||
updates.x2 = Math.max(startGrid.x1, startGrid.x2 + dxGrid);
|
||||
updates.y1 = Math.min(startGrid.y2, startGrid.y1 + dyGrid);
|
||||
} else if (anchor === 'sw') {
|
||||
updates.x1 = Math.min(startGrid.x2, startGrid.x1 + dxGrid);
|
||||
updates.y2 = Math.max(startGrid.y1, startGrid.y2 + dyGrid);
|
||||
} else if (anchor === 'se') {
|
||||
updates.x2 = Math.max(startGrid.x1, startGrid.x2 + dxGrid);
|
||||
updates.y2 = Math.max(startGrid.y1, startGrid.y2 + dyGrid);
|
||||
}
|
||||
updateLayerConfig(layerProp, updates);
|
||||
const updates: Partial<LayerConfig> = {};
|
||||
if (anchor === 'nw') {
|
||||
updates.x1 = Math.min(startGrid.x2, startGrid.x1 + dxGrid);
|
||||
updates.y1 = Math.min(startGrid.y2, startGrid.y1 + dyGrid);
|
||||
} else if (anchor === 'ne') {
|
||||
updates.x2 = Math.max(startGrid.x1, startGrid.x2 + dxGrid);
|
||||
updates.y1 = Math.min(startGrid.y2, startGrid.y1 + dyGrid);
|
||||
} else if (anchor === 'sw') {
|
||||
updates.x1 = Math.min(startGrid.x2, startGrid.x1 + dxGrid);
|
||||
updates.y2 = Math.max(startGrid.y1, startGrid.y2 + dyGrid);
|
||||
} else if (anchor === 'se') {
|
||||
updates.x2 = Math.max(startGrid.x1, startGrid.x2 + dxGrid);
|
||||
updates.y2 = Math.max(startGrid.y1, startGrid.y2 + dyGrid);
|
||||
}
|
||||
updateLayerConfig(layerProp, updates);
|
||||
};
|
||||
|
||||
const resizeLayerEdge = (layerProp: string, edge: 'n' | 's' | 'e' | 'w', delta: number, startGrid: { x1: number; y1: number; x2: number; y2: number }) => {
|
||||
const layer = getLayerConfig(layerProp);
|
||||
if (!layer) return;
|
||||
|
||||
const orientation = layer.orientation || 'n';
|
||||
|
||||
if (orientation === 'e' || orientation === 'w') {
|
||||
const edgeMap: Record<string, { key: string }> = {
|
||||
'n': { key: 'y1' },
|
||||
's': { key: 'y2' },
|
||||
'e': { key: 'x2' },
|
||||
'w': { key: 'x1' }
|
||||
};
|
||||
const { key } = edgeMap[edge];
|
||||
const updates: Partial<LayerConfig> = {};
|
||||
if (key === 'y1') updates.y1 = Math.min(startGrid.y2, Math.max(1, startGrid.y1 + delta));
|
||||
if (key === 'y2') updates.y2 = Math.max(startGrid.y1, Math.min(state.gridH, startGrid.y2 + delta));
|
||||
if (key === 'x1') updates.x1 = Math.min(startGrid.x2, Math.max(1, startGrid.x1 + delta));
|
||||
if (key === 'x2') updates.x2 = Math.max(startGrid.x1, Math.min(state.gridW, startGrid.x2 + delta));
|
||||
updateLayerConfig(layerProp, updates);
|
||||
} else {
|
||||
const updates: Partial<LayerConfig> = {};
|
||||
if (edge === 'n') updates.y1 = Math.min(startGrid.y2, Math.max(1, startGrid.y1 + delta));
|
||||
if (edge === 's') updates.y2 = Math.max(startGrid.y1, Math.min(state.gridH, startGrid.y2 + delta));
|
||||
if (edge === 'w') updates.x1 = Math.min(startGrid.x2, Math.max(1, startGrid.x1 + delta));
|
||||
if (edge === 'e') updates.x2 = Math.max(startGrid.x1, Math.min(state.gridW, startGrid.x2 + delta));
|
||||
updateLayerConfig(layerProp, updates);
|
||||
}
|
||||
const updates: Partial<LayerConfig> = {};
|
||||
if (edge === 'n') updates.y1 = Math.min(startGrid.y2, Math.max(1, startGrid.y1 + delta));
|
||||
if (edge === 's') updates.y2 = Math.max(startGrid.y1, Math.min(state.gridH, startGrid.y2 + delta));
|
||||
if (edge === 'w') updates.x1 = Math.min(startGrid.x2, Math.max(1, startGrid.x1 + delta));
|
||||
if (edge === 'e') updates.x2 = Math.max(startGrid.x1, Math.min(state.gridW, startGrid.x2 + delta));
|
||||
updateLayerConfig(layerProp, updates);
|
||||
};
|
||||
|
||||
const loadCardsFromPath = async (path: string, rawSrc: string, layersStr: string = '', backLayersStr: string = '') => {
|
||||
|
||||
Reference in New Issue
Block a user