inherting from siblings
This commit is contained in:
1 parent
55342ef967
commit
9a04d7d058
2 files changed
+75
-5
No files matched your search
@@ -22,8 +22,8 @@ function newFloatingObject () {
|
||||
targetRadius: 0, // This is the target radius of the floating object with zoom applied. It should be animated until reaching this value.
|
||||
isPinned: false,
|
||||
isFrozen: false,
|
||||
angleToParent: ANGLE_TO_PARENT.RANGE_90,
|
||||
distanceToParent: DISTANCE_TO_PARENT.PARENT_100X,
|
||||
angleToParent: undefined,
|
||||
distanceToParent: undefined,
|
||||
isCollapsed: false,
|
||||
isParentCollapsed: false,
|
||||
frozenManually: false,
|
||||
|
||||
@@ -65,10 +65,80 @@ function newUiObjectConstructor () {
|
||||
}
|
||||
}
|
||||
|
||||
/* For brand new objects being created directly by the user, we will make them inherit some properties from their parents. */
|
||||
/*
|
||||
For brand new objects being created directly by the user, we will make them inherit some properties
|
||||
from their closest siblings, and if they don't have, from their parents.
|
||||
*/
|
||||
|
||||
if (userAddingNew === true) {
|
||||
floatingObject.angleToParent = payload.parentNode.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = payload.parentNode.payload.floatingObject.distanceToParent
|
||||
let definition = APP_SCHEMA_MAP.get(payload.parentNode.type)
|
||||
for (let i = 0; i < definition.properties.length; i++) {
|
||||
let property = definition.properties[i]
|
||||
if (property.childType === payload.node.type) {
|
||||
if (property.type === 'array') {
|
||||
let parentNode = payload.parentNode
|
||||
let parentNodeArray = parentNode[property.name]
|
||||
if (parentNodeArray.length > 1) { // the new node was already added
|
||||
let closestSibling = parentNodeArray[parentNodeArray.length - 2]
|
||||
if (closestSibling !== undefined) {
|
||||
floatingObject.angleToParent = closestSibling.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = closestSibling.payload.floatingObject.distanceToParent
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (floatingObject.angleToParent === undefined) {
|
||||
for (let j = i - 1; j >= 0; j--) {
|
||||
let siblingProperty = definition.properties[j]
|
||||
let parentNode = payload.parentNode
|
||||
let parentNodeProperty = parentNode[siblingProperty.name]
|
||||
if (siblingProperty.type === 'array') {
|
||||
if (parentNodeProperty.length > 0) {
|
||||
let closestSibling = parentNodeProperty[parentNodeProperty.length - 1]
|
||||
if (closestSibling !== undefined) {
|
||||
floatingObject.angleToParent = closestSibling.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = closestSibling.payload.floatingObject.distanceToParent
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let closestSibling = parentNodeProperty
|
||||
if (closestSibling !== undefined) {
|
||||
floatingObject.angleToParent = closestSibling.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = closestSibling.payload.floatingObject.distanceToParent
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
for (let j = i + 1; j < definition.properties.length; j++) {
|
||||
let siblingProperty = definition.properties[j]
|
||||
let parentNode = payload.parentNode
|
||||
let parentNodeProperty = parentNode[siblingProperty.name]
|
||||
if (siblingProperty.type === 'array') {
|
||||
if (parentNodeProperty.length > 0) {
|
||||
let closestSibling = parentNodeProperty[parentNodeProperty.length - 1]
|
||||
if (closestSibling !== undefined) {
|
||||
floatingObject.angleToParent = closestSibling.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = closestSibling.payload.floatingObject.distanceToParent
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let closestSibling = parentNodeProperty
|
||||
if (closestSibling !== undefined) {
|
||||
floatingObject.angleToParent = closestSibling.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = closestSibling.payload.floatingObject.distanceToParent
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (floatingObject.angleToParent === undefined) {
|
||||
floatingObject.angleToParent = payload.parentNode.payload.floatingObject.angleToParent
|
||||
floatingObject.distanceToParent = payload.parentNode.payload.floatingObject.distanceToParent
|
||||
}
|
||||
}
|
||||
|
||||
let uiObject = newUiObject()
|
||||
|
||||
Reference in new issue
Block a user