Refactor behaviors into a single function (#35)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.siklos-chaneru.duckdns.org/Siklos/svg-layout-designer-react/pulls/35
This commit is contained in:
parent
f34ba64f7e
commit
0e161ffce0
4 changed files with 29 additions and 13 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