mirror of
https://github.com/stan-smith/FossFLOW.git
synced 2025-12-23 22:48:57 -05:00
resolved issue where rectangles were taking priority over normal items during lasso operations, this needs to be fixed in future
This commit is contained in:
@@ -52,10 +52,15 @@ const dragItems = (
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle non-item references (rectangles, textboxes, connector anchors)
|
||||
otherRefs.forEach((item) => {
|
||||
if (item.type === 'RECTANGLE') {
|
||||
// Skip rectangles if regular items are also being dragged
|
||||
// This is because items use snap-to-grid logic, while rectangles move freely
|
||||
// Moving them together would cause desynchronization
|
||||
if (itemRefs.length > 0) return;
|
||||
|
||||
const rectangle = getItemByIdOrThrow(scene.rectangles, item.id).value;
|
||||
const newFrom = CoordsUtils.add(rectangle.from, delta);
|
||||
const newTo = CoordsUtils.add(rectangle.to, delta);
|
||||
|
||||
@@ -18,13 +18,19 @@ const getItemsInFreehandBounds = (
|
||||
}
|
||||
});
|
||||
|
||||
// Check all rectangles (check center point)
|
||||
// Check all rectangles - they must be FULLY enclosed (all 4 corners inside)
|
||||
scene.rectangles.forEach((rectangle: any) => {
|
||||
const centerX = (rectangle.from.x + rectangle.to.x) / 2;
|
||||
const centerY = (rectangle.from.y + rectangle.to.y) / 2;
|
||||
const center = { x: centerX, y: centerY };
|
||||
const corners = [
|
||||
rectangle.from,
|
||||
{ x: rectangle.to.x, y: rectangle.from.y },
|
||||
rectangle.to,
|
||||
{ x: rectangle.from.x, y: rectangle.to.y }
|
||||
];
|
||||
|
||||
if (isPointInPolygon(center, pathTiles)) {
|
||||
// Rectangle is only selected if ALL corners are inside the polygon
|
||||
const allCornersInside = corners.every(corner => isPointInPolygon(corner, pathTiles));
|
||||
|
||||
if (allCornersInside) {
|
||||
items.push({ type: 'RECTANGLE', id: rectangle.id });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,13 +17,21 @@ const getItemsInBounds = (
|
||||
}
|
||||
});
|
||||
|
||||
// Check all rectangles
|
||||
// Check all rectangles - they must be FULLY enclosed (all 4 corners inside)
|
||||
scene.rectangles.forEach((rectangle: any) => {
|
||||
// Check if rectangle's center or any corner is within bounds
|
||||
if (
|
||||
isWithinBounds(rectangle.from, [startTile, endTile]) ||
|
||||
isWithinBounds(rectangle.to, [startTile, endTile])
|
||||
) {
|
||||
const corners = [
|
||||
rectangle.from,
|
||||
{ x: rectangle.to.x, y: rectangle.from.y },
|
||||
rectangle.to,
|
||||
{ x: rectangle.from.x, y: rectangle.to.y }
|
||||
];
|
||||
|
||||
// Rectangle is only selected if ALL corners are inside the bounds
|
||||
const allCornersInside = corners.every(corner =>
|
||||
isWithinBounds(corner, [startTile, endTile])
|
||||
);
|
||||
|
||||
if (allCornersInside) {
|
||||
items.push({ type: 'RECTANGLE', id: rectangle.id });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user