Refactor behaviors functions to a single function called applyBehaviors
This commit is contained in:
parent
f34ba64f7e
commit
e831f95d20
2 changed files with 25 additions and 12 deletions
21
src/Components/Editor/Behaviors/Behaviors.ts
Normal file
21
src/Components/Editor/Behaviors/Behaviors.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue