svg-layout-designer-react/src/Components/Editor/Behaviors/Behaviors.ts

21 lines
644 B
TypeScript

import { IContainerModel } from '../../../Interfaces/IContainerModel';
import { ImposePosition } from './AnchorBehaviors';
import { RecalculatePhysics } from './RigidBodyBehaviors';
/**
* Recalculate the position of the container and its neighbors
* Mutate and returns the updated container
* @param container Container to recalculate its positions
* @returns Updated container
*/
export function applyBehaviors(container: IContainerModel): IContainerModel {
if (container.properties.isAnchor) {
ImposePosition(container);
}
if (container.properties.isRigidBody) {
RecalculatePhysics(container);
}
return container;
}