Add shift+drag to constrain movement to horizontal or vertical axis
Holding Shift while dragging locks movement to the dominant axis (whichever has the larger delta from drag start). Works for both single and multi-selection moves. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b4e3a7d6ff
commit
31ea4c0908
@ -490,6 +490,14 @@ function onMousemove(e: MouseEvent) {
|
|||||||
if (!pastDragThreshold(pos.x, pos.y, dragState.startX!, dragState.startY!, DRAG_THRESHOLD)) return;
|
if (!pastDragThreshold(pos.x, pos.y, dragState.startX!, dragState.startY!, DRAG_THRESHOLD)) return;
|
||||||
dragState.dragActivated = true;
|
dragState.dragActivated = true;
|
||||||
}
|
}
|
||||||
|
// Shift: constrain to orthogonal axis (horizontal or vertical)
|
||||||
|
if (e.shiftKey) {
|
||||||
|
if (Math.abs(pos.x - dragState.startX!) >= Math.abs(pos.y - dragState.startY!)) {
|
||||||
|
pos.y = dragState.startY!;
|
||||||
|
} else {
|
||||||
|
pos.x = dragState.startX!;
|
||||||
|
}
|
||||||
|
}
|
||||||
const sym = layout.symbols.find(s => s.id === dragState!.placedId);
|
const sym = layout.symbols.find(s => s.id === dragState!.placedId);
|
||||||
if (!sym) return;
|
if (!sym) return;
|
||||||
const bb = getAABB(0, 0, sym.w, sym.h, sym.rotation);
|
const bb = getAABB(0, 0, sym.w, sym.h, sym.rotation);
|
||||||
@ -508,6 +516,14 @@ function onMousemove(e: MouseEvent) {
|
|||||||
if (!pastDragThreshold(pos.x, pos.y, dragState.startX!, dragState.startY!, DRAG_THRESHOLD)) return;
|
if (!pastDragThreshold(pos.x, pos.y, dragState.startX!, dragState.startY!, DRAG_THRESHOLD)) return;
|
||||||
dragState.dragActivated = true;
|
dragState.dragActivated = true;
|
||||||
}
|
}
|
||||||
|
// Shift: constrain to orthogonal axis
|
||||||
|
if (e.shiftKey) {
|
||||||
|
if (Math.abs(pos.x - dragState.startX!) >= Math.abs(pos.y - dragState.startY!)) {
|
||||||
|
pos.y = dragState.startY!;
|
||||||
|
} else {
|
||||||
|
pos.x = dragState.startX!;
|
||||||
|
}
|
||||||
|
}
|
||||||
for (const { id, offsetX, offsetY } of dragState.multiOffsets) {
|
for (const { id, offsetX, offsetY } of dragState.multiOffsets) {
|
||||||
const sym = layout.symbols.find(s => s.id === id);
|
const sym = layout.symbols.find(s => s.id === id);
|
||||||
if (!sym) continue;
|
if (!sym) continue;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user