@@ -38,10 +38,6 @@ const MainBrickDefaults = {
3838
3939const Defaults = {
4040 [ BRICK ] : {
41- position : {
42- x : 50 ,
43- y : 50
44- } ,
4541 size : {
4642 height : 40 ,
4743 width : 100
@@ -66,10 +62,6 @@ const Defaults = {
6662 }
6763 } ,
6864 [ PRIMITIVE ] : {
69- position : {
70- x : 50 ,
71- y : 50
72- } ,
7365 size : {
7466 height : 30 ,
7567 width : 60
@@ -90,6 +82,7 @@ const nextId = () => id++
9082export const newBrick = ( brick , parentId ) => {
9183 const { arity, moduleName, name } = brick
9284 let inputSlots = { }
85+ const elementId = nextId ( )
9386 const outputSlotId = nextId ( )
9487
9588 for ( var i = 0 ; i < arity ; i ++ ) {
@@ -103,7 +96,7 @@ export const newBrick = (brick, parentId) => {
10396
10497 return {
10598 componentName : BRICK ,
106- id : nextId ( ) ,
99+ id : elementId ,
107100 inputSlots,
108101 moduleName,
109102 name,
@@ -118,7 +111,7 @@ export const newBrick = (brick, parentId) => {
118111 }
119112 } ,
120113 parentId,
121- position : Defaults [ BRICK ] . position ,
114+ position : _shiftPosition ( elementId ) ,
122115 size : Defaults [ BRICK ] . size ,
123116 valueId : outputSlotId
124117 }
@@ -177,12 +170,22 @@ export const newPrimitive = (type, parentId) => {
177170 }
178171 } ,
179172 parentId,
180- position : Defaults [ PRIMITIVE ] . position ,
173+ position : _shiftPosition ( elementId ) ,
181174 size : Defaults [ PRIMITIVE ] . size ,
182175 valueId : elementId
183176 }
184177}
185178
179+ const _shiftPosition = ( id ) => {
180+ const xMultiplier = ( id % 5 ) + 1
181+ const yMultiplier = Math . floor ( id / 5 ) + 1
182+
183+ return {
184+ x : 50 * xMultiplier ,
185+ y : 30 * yMultiplier
186+ }
187+ }
188+
186189export const newPipe = ( payload ) => {
187190 const { input, output } = payload
188191
0 commit comments