Merge branch 'dev'
This commit is contained in:
commit
e7f655c901
|
|
@ -297,7 +297,7 @@ export class FolkShape extends FolkElement {
|
|||
}
|
||||
|
||||
static GAP = 8; // minimum gap between shapes
|
||||
static pushExemptTags = new Set(["folk-arrow", "folk-slide"]);
|
||||
static pushExemptTags = new Set(["folk-arrow", "folk-slide", "folk-shape"]);
|
||||
|
||||
#highlighted = false;
|
||||
get highlighted() {
|
||||
|
|
|
|||
|
|
@ -3828,10 +3828,12 @@
|
|||
}
|
||||
|
||||
// Collect bounding boxes of all visible shapes on the canvas
|
||||
// Only includes rApps and embedded content — slides, drawings, and arrows are excluded
|
||||
function getExistingShapeRects() {
|
||||
return [...canvasContent.children]
|
||||
.filter(el => el.tagName && el.tagName.includes('-') &&
|
||||
!el.tagName.toLowerCase().includes('arrow') &&
|
||||
!FolkShape.pushExemptTags.has(el.tagName.toLowerCase()) &&
|
||||
!el.dataset?.wbDrawing &&
|
||||
typeof el.x === 'number' && typeof el.width === 'number' &&
|
||||
el.width > 0)
|
||||
.map(el => ({ x: el.x, y: el.y, width: el.width, height: el.height }));
|
||||
|
|
@ -6869,6 +6871,7 @@
|
|||
for (const el of canvasContent.children) {
|
||||
if (!(el instanceof FolkShape)) continue;
|
||||
if (FolkShape.pushExemptTags.has(el.tagName.toLowerCase())) continue;
|
||||
if (el.dataset?.wbDrawing) continue; // wb drawings can overlap freely
|
||||
shapes.push(el);
|
||||
}
|
||||
|
||||
|
|
@ -6889,19 +6892,34 @@
|
|||
if (push < REPEL_THRESHOLD) continue;
|
||||
|
||||
const half = push / 2;
|
||||
const aLocked = a.locked;
|
||||
const bLocked = b.locked;
|
||||
if (aLocked && bLocked) continue; // both locked, skip
|
||||
if (ox < oy) {
|
||||
// Push apart horizontally
|
||||
const sign = (a.x + a.width / 2) < (b.x + b.width / 2) ? -1 : 1;
|
||||
if (aLocked) {
|
||||
b.x -= sign * push;
|
||||
} else if (bLocked) {
|
||||
a.x += sign * push;
|
||||
} else {
|
||||
a.x += sign * half;
|
||||
b.x -= sign * half;
|
||||
}
|
||||
} else {
|
||||
// Push apart vertically
|
||||
const sign = (a.y + a.height / 2) < (b.y + b.height / 2) ? -1 : 1;
|
||||
if (aLocked) {
|
||||
b.y -= sign * push;
|
||||
} else if (bLocked) {
|
||||
a.y += sign * push;
|
||||
} else {
|
||||
a.y += sign * half;
|
||||
b.y -= sign * half;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(repulsionLoop);
|
||||
}
|
||||
requestAnimationFrame(repulsionLoop);
|
||||
|
|
|
|||
Loading…
Reference in New Issue