From cf1a3a7eec95ab297edbb37501e1ab4f2e5cb7ac Mon Sep 17 00:00:00 2001 From: Siklos Date: Fri, 5 Aug 2022 11:57:03 +0200 Subject: [PATCH] Default action of AddContainer will now be append --- src/Editor.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Editor.tsx b/src/Editor.tsx index 8b4edb6..5e24be6 100644 --- a/src/Editor.tsx +++ b/src/Editor.tsx @@ -212,13 +212,19 @@ class Editor extends React.Component { throw new Error('[OnPropertyChange] Container model was not found among children of the main container!'); } + let x = 0; + const lastChild: IContainerModel | undefined = parent.children.at(-1); + if (lastChild !== undefined) { + x = lastChild.properties.x + Number(lastChild.properties.width); + } + // Create the container const newContainer = new ContainerModel( parent, { id: `${type}-${count}`, parentId: parent.properties.id, - x: 0, + x, y: 0, width: properties?.Width, height: parent.properties.height,