Compare commits
No commits in common. "c1139216c2141728e1e2fc25181ea11135102d4d" and "f34ba64f7eac9c2f208cf7d295e1d55d395d71cb" have entirely different histories.
c1139216c2
...
f34ba64f7e
4 changed files with 13 additions and 29 deletions
|
@ -1,21 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
|
@ -7,7 +7,6 @@ import { getCurrentHistory } from './Editor';
|
||||||
import { AddMethod } from '../../Enums/AddMethod';
|
import { AddMethod } from '../../Enums/AddMethod';
|
||||||
import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
|
import { IAvailableContainer } from '../../Interfaces/IAvailableContainer';
|
||||||
import { GetDefaultContainerProps } from '../../utils/default';
|
import { GetDefaultContainerProps } from '../../utils/default';
|
||||||
import { ApplyBehaviors } from './Behaviors/Behaviors';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select a container
|
* Select a container
|
||||||
|
@ -225,8 +224,6 @@ export function AddContainer(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
ApplyBehaviors(newContainer);
|
|
||||||
|
|
||||||
// And push it the the parent children
|
// And push it the the parent children
|
||||||
if (index === parentClone.children.length) {
|
if (index === parentClone.children.length) {
|
||||||
parentClone.children.push(newContainer);
|
parentClone.children.push(newContainer);
|
||||||
|
|
|
@ -3,8 +3,9 @@ import { IContainerModel, ContainerModel } from '../../Interfaces/IContainerMode
|
||||||
import { IHistoryState } from '../../Interfaces/IHistoryState';
|
import { IHistoryState } from '../../Interfaces/IHistoryState';
|
||||||
import { findContainerById } from '../../utils/itertools';
|
import { findContainerById } from '../../utils/itertools';
|
||||||
import { getCurrentHistory } from './Editor';
|
import { getCurrentHistory } from './Editor';
|
||||||
|
import { RecalculatePhysics } from './Behaviors/RigidBodyBehaviors';
|
||||||
|
import { ImposePosition } from './Behaviors/AnchorBehaviors';
|
||||||
import { restoreX } from '../SVG/Elements/Container';
|
import { restoreX } from '../SVG/Elements/Container';
|
||||||
import { ApplyBehaviors } from './Behaviors/Behaviors';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handled the property change event in the properties form
|
* Handled the property change event in the properties form
|
||||||
|
@ -42,7 +43,13 @@ export function OnPropertyChange(
|
||||||
(container.properties as any)[key] = value;
|
(container.properties as any)[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplyBehaviors(container);
|
if (container.properties.isAnchor) {
|
||||||
|
ImposePosition(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (container.properties.isRigidBody) {
|
||||||
|
RecalculatePhysics(container);
|
||||||
|
}
|
||||||
|
|
||||||
history.push({
|
history.push({
|
||||||
LastAction: `Change ${key} of ${container.properties.id}`,
|
LastAction: `Change ${key} of ${container.properties.id}`,
|
||||||
|
@ -109,8 +116,9 @@ export function OnPropertiesSubmit(
|
||||||
submitCSSForm(form, styleProperty, container);
|
submitCSSForm(form, styleProperty, container);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the behaviors
|
if (container.properties.isRigidBody) {
|
||||||
ApplyBehaviors(container);
|
RecalculatePhysics(container);
|
||||||
|
}
|
||||||
|
|
||||||
history.push({
|
history.push({
|
||||||
LastAction: `Change properties of ${container.properties.id}`,
|
LastAction: `Change properties of ${container.properties.id}`,
|
||||||
|
|
|
@ -59,7 +59,7 @@ export const GetDefaultContainerProps = (
|
||||||
y,
|
y,
|
||||||
width: containerConfig.Width ?? containerConfig.MinWidth ?? parent.properties.width,
|
width: containerConfig.Width ?? containerConfig.MinWidth ?? parent.properties.width,
|
||||||
height: containerConfig.Height ?? parent.properties.height,
|
height: containerConfig.Height ?? parent.properties.height,
|
||||||
isRigidBody: false, // set this to true to replicate Florian's project
|
isRigidBody: false,
|
||||||
isAnchor: false,
|
isAnchor: false,
|
||||||
XPositionReference: containerConfig.XPositionReference ?? XPositionReference.Left,
|
XPositionReference: containerConfig.XPositionReference ?? XPositionReference.Left,
|
||||||
minWidth: containerConfig.MinWidth ?? 0,
|
minWidth: containerConfig.MinWidth ?? 0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue