Refactor behaviors into a single function (#35)
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:
Siklos 2022-08-18 06:11:40 -04:00
parent f34ba64f7e
commit 0e161ffce0
4 changed files with 29 additions and 13 deletions

View file

@ -3,9 +3,8 @@ import { IContainerModel, ContainerModel } from '../../Interfaces/IContainerMode
import { IHistoryState } from '../../Interfaces/IHistoryState';
import { findContainerById } from '../../utils/itertools';
import { getCurrentHistory } from './Editor';
import { RecalculatePhysics } from './Behaviors/RigidBodyBehaviors';
import { ImposePosition } from './Behaviors/AnchorBehaviors';
import { restoreX } from '../SVG/Elements/Container';
import { ApplyBehaviors } from './Behaviors/Behaviors';
/**
* Handled the property change event in the properties form
@ -43,13 +42,7 @@ export function OnPropertyChange(
(container.properties as any)[key] = value;
}
if (container.properties.isAnchor) {
ImposePosition(container);
}
if (container.properties.isRigidBody) {
RecalculatePhysics(container);
}
ApplyBehaviors(container);
history.push({
LastAction: `Change ${key} of ${container.properties.id}`,
@ -116,9 +109,8 @@ export function OnPropertiesSubmit(
submitCSSForm(form, styleProperty, container);
}
if (container.properties.isRigidBody) {
RecalculatePhysics(container);
}
// Apply the behaviors
ApplyBehaviors(container);
history.push({
LastAction: `Change properties of ${container.properties.id}`,