arrangementStyle 2

This commit is contained in:
Luis Fernando Molina committed 2020-04-02 17:52:18 +02:00
1 parent 187ed77fc0
commit 26194bee1e
4 files changed
+77 -24

No files matched your search

+60 -10
View File
@@ -24,7 +24,7 @@ function newFloatingObject () {
isFrozen: false,
angleToParent: undefined,
distanceToParent: undefined,
arrangementStyle: ARRANGEMENT_STYLE.CIRCULAR,
arrangementStyle: ARRANGEMENT_STYLE.CONCAVE,
isCollapsed: false,
isParentCollapsed: false,
frozenManually: false,
@@ -231,14 +231,23 @@ function newFloatingObject () {
function arrangementStyleToggle () {
switch (thisObject.arrangementStyle) {
case ARRANGEMENT_STYLE.CIRCULAR:
thisObject.arrangementStyle = ARRANGEMENT_STYLE.VERTICAL
case ARRANGEMENT_STYLE.CONCAVE:
thisObject.arrangementStyle = ARRANGEMENT_STYLE.CONVEX
break
case ARRANGEMENT_STYLE.VERTICAL:
thisObject.arrangementStyle = ARRANGEMENT_STYLE.HORIZONTAL
case ARRANGEMENT_STYLE.CONVEX:
thisObject.arrangementStyle = ARRANGEMENT_STYLE.VERTICAL_RIGHT
break
case ARRANGEMENT_STYLE.HORIZONTAL:
thisObject.arrangementStyle = ARRANGEMENT_STYLE.CIRCULAR
case ARRANGEMENT_STYLE.VERTICAL_RIGHT:
thisObject.arrangementStyle = ARRANGEMENT_STYLE.VERTICAL_LEFT
break
case ARRANGEMENT_STYLE.VERTICAL_LEFT:
thisObject.arrangementStyle = ARRANGEMENT_STYLE.HORIZONTAL_BOTTOM
break
case ARRANGEMENT_STYLE.HORIZONTAL_BOTTOM:
thisObject.arrangementStyle = ARRANGEMENT_STYLE.HORIZONTAL_TOP
break
case ARRANGEMENT_STYLE.HORIZONTAL_TOP:
thisObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
break
}
@@ -354,10 +363,51 @@ function newFloatingObject () {
if (distanceToParent > 3000 || thisObject.isPinned === true) { return } // this is introduced to avoid edges cases when importing workspaces.
newPosition = {
x: parent.payload.position.x + distanceToParent * Math.cos(toRadians(thisObject.payload.angle)),
y: parent.payload.position.y + distanceToParent * Math.sin(toRadians(thisObject.payload.angle))
switch (thisObject.arrangementStyle) {
case ARRANGEMENT_STYLE.CONCAVE: {
newPosition = {
x: parent.payload.position.x + distanceToParent * Math.cos(toRadians(thisObject.payload.angle)),
y: parent.payload.position.y + distanceToParent * Math.sin(toRadians(thisObject.payload.angle))
}
break
}
case ARRANGEMENT_STYLE.CONVEX: {
newPosition = {
x: parent.payload.position.x + 2 * distanceToParent * Math.cos(toRadians(lastParentAngle)) + distanceToParent * Math.cos(toRadians(thisObject.payload.angle + 180)),
y: parent.payload.position.y + 2 * distanceToParent * Math.sin(toRadians(lastParentAngle)) + distanceToParent * Math.sin(toRadians(thisObject.payload.angle + 180))
}
break
}
case ARRANGEMENT_STYLE.HORIZONTAL_BOTTOM: {
newPosition = {
x: parent.payload.position.x + distanceToParent * Math.tan(toRadians(thisObject.payload.angle)),
y: parent.payload.position.y + distanceToParent
}
break
}
case ARRANGEMENT_STYLE.HORIZONTAL_TOP: {
newPosition = {
x: parent.payload.position.x - distanceToParent * Math.tan(toRadians(thisObject.payload.angle)),
y: parent.payload.position.y - distanceToParent
}
break
}
case ARRANGEMENT_STYLE.VERTICAL_RIGHT: {
newPosition = {
x: parent.payload.position.x + distanceToParent,
y: parent.payload.position.y + distanceToParent * Math.tan(toRadians(thisObject.payload.angle))
}
break
}
case ARRANGEMENT_STYLE.VERTICAL_LEFT: {
newPosition = {
x: parent.payload.position.x - distanceToParent,
y: parent.payload.position.y - distanceToParent * Math.tan(toRadians(thisObject.payload.angle))
}
break
}
}
if (isNaN(newPosition.x) === false) {
thisObject.container.frame.position.x = newPosition.x
}