Implement events for external use + Rename interfaces with a I prefix + add some documentation (#26)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Implement events for external use Rename interfaces with a I prefix Add some documentation Co-authored-by: Eric NGUYEN <enguyen@techform.fr> Reviewed-on: https://git.siklos-chaneru.duckdns.org/Siklos/svg-layout-designer-react/pulls/26
This commit is contained in:
parent
6c601429b9
commit
c81a6fe44b
38 changed files with 228 additions and 116 deletions
|
@ -1,5 +1,5 @@
|
|||
import { IContainerModel } from '../../Interfaces/ContainerModel';
|
||||
import { SizePointer } from '../../Interfaces/SizePointer';
|
||||
import { IContainerModel } from '../../Interfaces/IContainerModel';
|
||||
import { ISizePointer } from '../../Interfaces/ISizePointer';
|
||||
|
||||
/**
|
||||
* "Transform the container into a rigid body"
|
||||
|
@ -167,17 +167,17 @@ function constraintBodyInsideUnallocatedWidth(
|
|||
* (except the fact that disk space is divided by block).
|
||||
* @param container Container where to find an available width
|
||||
* @param exception Container to exclude of the widths (since a container will be moved, it might need to be excluded)
|
||||
* @returns {SizePointer[]} Array of unallocated widths (x=position of the unallocated space, width=size of the allocated space)
|
||||
* @returns {ISizePointer[]} Array of unallocated widths (x=position of the unallocated space, width=size of the allocated space)
|
||||
*/
|
||||
function getAvailableWidths(
|
||||
container: IContainerModel,
|
||||
exception: IContainerModel
|
||||
): SizePointer[] {
|
||||
): ISizePointer[] {
|
||||
// Initialize the first size pointer
|
||||
// which takes full width of the available space
|
||||
const x = 0;
|
||||
const width = Number(container.properties.width);
|
||||
let unallocatedSpaces: SizePointer[] = [{ x, width }];
|
||||
let unallocatedSpaces: ISizePointer[] = [{ x, width }];
|
||||
|
||||
// We will only uses containers that also have the rigid bodies
|
||||
// as out-of-bound or enormouse containers should be ignored
|
||||
|
@ -192,7 +192,7 @@ function getAvailableWidths(
|
|||
}
|
||||
|
||||
// get the space of the child that is inside the parent
|
||||
let newUnallocatedSpace: SizePointer[] = [];
|
||||
let newUnallocatedSpace: ISizePointer[] = [];
|
||||
|
||||
// We will iterate on a mutable variable in order to divide it
|
||||
for (const unallocatedSpace of unallocatedSpaces) {
|
||||
|
@ -229,7 +229,7 @@ function getAvailableWidthsTwoLines(
|
|||
max1: number,
|
||||
min2: number,
|
||||
max2: number
|
||||
): SizePointer[] {
|
||||
): ISizePointer[] {
|
||||
if (min2 < min1 && max2 > max1) {
|
||||
// object 2 is overlapping full width
|
||||
return [];
|
||||
|
@ -276,5 +276,5 @@ function getAvailableWidthsTwoLines(
|
|||
*/
|
||||
const isFitting = (
|
||||
container: IContainerModel,
|
||||
sizePointer: SizePointer
|
||||
sizePointer: ISizePointer
|
||||
): boolean => Number(container.properties.width) <= sizePointer.width;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue