Compare commits
3 commits
3da8a0c55e
...
f0c1803e10
Author | SHA1 | Date | |
---|---|---|---|
|
f0c1803e10 | ||
|
4bf4f01dc2 | ||
|
83d4990bba |
3 changed files with 17 additions and 9 deletions
|
@ -152,7 +152,7 @@ export function constraintBodyInsideUnallocatedWidth(
|
||||||
// Check if the container actually fit inside
|
// Check if the container actually fit inside
|
||||||
// It will usually fit if it was alrady fitting
|
// It will usually fit if it was alrady fitting
|
||||||
const availableWidthFound = availableWidths.find((width) =>
|
const availableWidthFound = availableWidths.find((width) =>
|
||||||
isFitting(container, width)
|
isFitting(container.properties.width, width)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (availableWidthFound === undefined) {
|
if (availableWidthFound === undefined) {
|
||||||
|
@ -163,12 +163,21 @@ export function constraintBodyInsideUnallocatedWidth(
|
||||||
|
|
||||||
// We want the container to fit automatically inside the available space
|
// We want the container to fit automatically inside the available space
|
||||||
// even if it means to resize the container
|
// even if it means to resize the container
|
||||||
// The end goal is that the code never show the error message no matter what action is done
|
const availableWidth: ISizePointer | undefined = availableWidths.find((width) => {
|
||||||
// TODO: Actually give an option to not fit and show the error message shown below
|
if (container.properties.minWidth === undefined) {
|
||||||
const availableWidth = availableWidths[0];
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
container.properties.x = availableWidth.x;
|
container.properties.x = availableWidth.x;
|
||||||
container.properties.width = availableWidth.width;
|
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;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,9 +197,9 @@ export function constraintBodyInsideUnallocatedWidth(
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const isFitting = (
|
const isFitting = (
|
||||||
container: IContainerModel,
|
containerWidth: number,
|
||||||
sizePointer: ISizePointer
|
sizePointer: ISizePointer
|
||||||
): boolean => container.properties.width <= sizePointer.width;
|
): boolean => containerWidth <= sizePointer.width;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the unallocated widths inside a container
|
* Get the unallocated widths inside a container
|
||||||
|
|
|
@ -4,10 +4,8 @@ import { IConfiguration } from '../../Interfaces/IConfiguration';
|
||||||
import { ContainerModel, IContainerModel } from '../../Interfaces/IContainerModel';
|
import { ContainerModel, IContainerModel } from '../../Interfaces/IContainerModel';
|
||||||
import { findContainerById } from '../../utils/itertools';
|
import { findContainerById } from '../../utils/itertools';
|
||||||
import { getCurrentHistory } from './Editor';
|
import { getCurrentHistory } from './Editor';
|
||||||
import IProperties from '../../Interfaces/IProperties';
|
|
||||||
import { AddMethod } from '../../Enums/AddMethod';
|
import { AddMethod } from '../../Enums/AddMethod';
|
||||||
import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
|
import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
|
||||||
import { XPositionReference } from '../../Enums/XPositionReference';
|
|
||||||
import { GetDefaultContainerProps } from '../../utils/default';
|
import { GetDefaultContainerProps } from '../../utils/default';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,6 +54,7 @@ const GetSVGLayoutConfiguration = () => {
|
||||||
{
|
{
|
||||||
Type: 'Chassis',
|
Type: 'Chassis',
|
||||||
Width: 500,
|
Width: 500,
|
||||||
|
MinWidth: 200,
|
||||||
Style: {
|
Style: {
|
||||||
fillOpacity: 1,
|
fillOpacity: 1,
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue