diff --git a/src/Components/Editor/Behaviors/RigidBodyBehaviors.ts b/src/Components/Editor/Behaviors/RigidBodyBehaviors.ts index e0ffb2f..85ad94f 100644 --- a/src/Components/Editor/Behaviors/RigidBodyBehaviors.ts +++ b/src/Components/Editor/Behaviors/RigidBodyBehaviors.ts @@ -252,6 +252,9 @@ function getAvailableWidthsTwoLines( rectLeft: number, rectRight: number ): ISizePointer[] { + // let object 1 be the unallocated space + // and object 2 be the rect + if (unallocatedSpaceRight < rectLeft || unalloctedSpaceLeft > rectRight ) { @@ -269,6 +272,10 @@ function getAvailableWidthsTwoLines( if (unalloctedSpaceLeft >= rectLeft) { // object 2 is partially overlapping on the left + if (unallocatedSpaceRight - rectRight <= 0) { + return []; + } + return [ { x: rectRight, @@ -279,6 +286,10 @@ function getAvailableWidthsTwoLines( if (rectRight >= unallocatedSpaceRight) { // object 2 is partially overlapping on the right + if (unalloctedSpaceLeft - rectRight <= 0) { + return []; + } + return [ { x: unalloctedSpaceLeft, @@ -288,16 +299,20 @@ function getAvailableWidthsTwoLines( } // object 2 is overlapping in the middle - return [ - { + const sizePointers: ISizePointer[] = []; + if (rectLeft - unalloctedSpaceLeft > 0) { + sizePointers.push({ x: unalloctedSpaceLeft, width: rectLeft - unalloctedSpaceLeft - }, - { + }); + } + if (unallocatedSpaceRight - rectRight > 0) { + sizePointers.push({ x: rectRight, width: unallocatedSpaceRight - rectRight - } - ]; + }); + } + return sizePointers; } /**