first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import {InteractableRect} from '../interactable-event';
export function restrictResizableWithinBoundary(
rect: InteractableRect,
boundaryRect: InteractableRect
) {
const boundedRect = {...rect};
// restrict to left edge of boundary
boundedRect.left = Math.max(0, boundedRect.left);
// compensate width when left is bounded
const leftRestriction = boundedRect.left - rect.left;
if (leftRestriction > 0) {
boundedRect.width -= leftRestriction;
}
// restrict to top edge of boundary
boundedRect.top = Math.max(0, boundedRect.top);
// compensate height when top is bounded
const topRestriction = boundedRect.top - rect.top;
if (topRestriction > 0) {
boundedRect.height -= topRestriction;
}
// restrict to right edge of boundary
boundedRect.width = Math.min(
boundedRect.width,
boundaryRect.width - boundedRect.left
);
// restrict to bottom edge of boundary
boundedRect.height = Math.min(
boundedRect.height,
boundaryRect.height - boundedRect.top
);
return boundedRect;
}