Add option to apply behaviors to children
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ff5c3d00da
commit
022ad38163
3 changed files with 17 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
|||
import { IContainerModel } from '../../../Interfaces/IContainerModel';
|
||||
import { APPLY_BEHAVIORS_ON_CHILDREN } from '../../../utils/default';
|
||||
import { ImposePosition } from './AnchorBehaviors';
|
||||
import { RecalculatePhysics } from './RigidBodyBehaviors';
|
||||
|
||||
|
@ -17,5 +18,12 @@ export function ApplyBehaviors(container: IContainerModel): IContainerModel {
|
|||
RecalculatePhysics(container);
|
||||
}
|
||||
|
||||
if (APPLY_BEHAVIORS_ON_CHILDREN) {
|
||||
// Apply DFS by recursion
|
||||
for (const child of container.children) {
|
||||
ApplyBehaviors(child);
|
||||
}
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
|
|
@ -231,14 +231,15 @@ function getAvailableWidths(
|
|||
const width = container.properties.width;
|
||||
let unallocatedSpaces: ISizePointer[] = [{ x, width }];
|
||||
|
||||
// We will only uses containers that also are rigid or are anchors
|
||||
const solidBodies = container.children.filter(
|
||||
(child) => child.properties.isRigidBody || child.properties.isAnchor
|
||||
);
|
||||
for (const child of container.children) {
|
||||
if (unallocatedSpaces.length < 1) {
|
||||
return unallocatedSpaces;
|
||||
}
|
||||
|
||||
for (const child of solidBodies) {
|
||||
// Ignore the exception
|
||||
if (child === exception) {
|
||||
// And we will also only uses containers that also are rigid or are anchors
|
||||
if (child === exception ||
|
||||
(!child.properties.isRigidBody && !child.properties.isAnchor)) {
|
||||
continue;
|
||||
}
|
||||
const childX = child.properties.x;
|
||||
|
|
|
@ -4,7 +4,7 @@ import { IConfiguration } from '../Interfaces/IConfiguration';
|
|||
import { IContainerModel } from '../Interfaces/IContainerModel';
|
||||
import IProperties from '../Interfaces/IProperties';
|
||||
|
||||
/// CONTAINRE DEFAULTS ///
|
||||
/// CONTAINER DEFAULTS ///
|
||||
|
||||
export const SHOW_TEXT = true;
|
||||
export const DEFAULTCHILDTYPE_ALLOW_CYCLIC = false;
|
||||
|
@ -22,6 +22,7 @@ export const NOTCHES_LENGTH = 4;
|
|||
|
||||
export const ENABLE_SHORTCUTS = true;
|
||||
export const MAX_HISTORY = 200;
|
||||
export const APPLY_BEHAVIORS_ON_CHILDREN = true;
|
||||
|
||||
export const DEFAULT_CONFIG: IConfiguration = {
|
||||
AvailableContainers: [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue