Compare commits

..

No commits in common. "f0c1803e101611d4076c7634363f7c139a8abad1" and "3da8a0c55e2a0c006a1bce910cae1b05722c7056" have entirely different histories.

3 changed files with 9 additions and 17 deletions

View file

@ -152,7 +152,7 @@ export function constraintBodyInsideUnallocatedWidth(
// Check if the container actually fit inside
// It will usually fit if it was alrady fitting
const availableWidthFound = availableWidths.find((width) =>
isFitting(container.properties.width, width)
isFitting(container, width)
);
if (availableWidthFound === undefined) {
@ -163,21 +163,12 @@ export function constraintBodyInsideUnallocatedWidth(
// We want the container to fit automatically inside the available space
// even if it means to resize the container
const availableWidth: ISizePointer | undefined = availableWidths.find((width) => {
if (container.properties.minWidth === undefined) {
return true;
}
return isFitting(container.properties.minWidth, width);
});
if (availableWidth === undefined) {
console.warn(`Container ${container.properties.id} cannot fit in any space due to its minimum width being to large. Consequently, its rigid body property is disabled.`);
container.properties.isRigidBody = false;
return container;
}
// The end goal is that the code never show the error message no matter what action is done
// TODO: Actually give an option to not fit and show the error message shown below
const availableWidth = availableWidths[0];
container.properties.x = availableWidth.x;
container.properties.width = availableWidth.width;
// throw new Error('[constraintBodyInsideUnallocatedWidth] BIGERR: No available space found on the parent container, even though there is some.');
return container;
}
@ -197,9 +188,9 @@ export function constraintBodyInsideUnallocatedWidth(
* @returns
*/
const isFitting = (
containerWidth: number,
container: IContainerModel,
sizePointer: ISizePointer
): boolean => containerWidth <= sizePointer.width;
): boolean => container.properties.width <= sizePointer.width;
/**
* Get the unallocated widths inside a container

View file

@ -4,8 +4,10 @@ import { IConfiguration } from '../../Interfaces/IConfiguration';
import { ContainerModel, IContainerModel } from '../../Interfaces/IContainerModel';
import { findContainerById } from '../../utils/itertools';
import { getCurrentHistory } from './Editor';
import IProperties from '../../Interfaces/IProperties';
import { AddMethod } from '../../Enums/AddMethod';
import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
import { XPositionReference } from '../../Enums/XPositionReference';
import { GetDefaultContainerProps } from '../../utils/default';
/**

View file

@ -54,7 +54,6 @@ const GetSVGLayoutConfiguration = () => {
{
Type: 'Chassis',
Width: 500,
MinWidth: 200,
Style: {
fillOpacity: 1,
strokeWidth: 2,