refactor: rename internal data field to __vf
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
+15
-15
@@ -91,19 +91,19 @@ export default function flowStore(
|
||||
const node = this.nodes[i]
|
||||
const dimensions = getDimensions(nodeElement)
|
||||
|
||||
if (!node.__rf) node.__rf = {}
|
||||
if (!node.__vf) node.__vf = {}
|
||||
const doUpdate =
|
||||
dimensions.width &&
|
||||
dimensions.height &&
|
||||
(node.__rf.width !== dimensions.width || node.__rf.height !== dimensions.height || forceUpdate)
|
||||
(node.__vf.width !== dimensions.width || node.__vf.height !== dimensions.height || forceUpdate)
|
||||
|
||||
if (doUpdate) {
|
||||
const handleBounds = getHandleBounds(nodeElement, this.transform[2])
|
||||
|
||||
this.nodes.splice(i, 1, {
|
||||
...node,
|
||||
__rf: {
|
||||
...node.__rf,
|
||||
__vf: {
|
||||
...node.__vf,
|
||||
...dimensions,
|
||||
handleBounds,
|
||||
},
|
||||
@@ -124,8 +124,8 @@ export default function flowStore(
|
||||
|
||||
this.nodes.splice(i, 1, {
|
||||
...node,
|
||||
__rf: {
|
||||
...node.__rf,
|
||||
__vf: {
|
||||
...node.__vf,
|
||||
position: pos,
|
||||
},
|
||||
})
|
||||
@@ -134,16 +134,16 @@ export default function flowStore(
|
||||
const update = (node: Node, i: number) => {
|
||||
const updatedNode = {
|
||||
...node,
|
||||
__rf: {
|
||||
...node.__rf,
|
||||
__vf: {
|
||||
...node.__vf,
|
||||
isDragging,
|
||||
},
|
||||
}
|
||||
|
||||
if (diff) {
|
||||
updatedNode.__rf.position = {
|
||||
x: (node.__rf?.position?.x as number) + diff.x,
|
||||
y: (node.__rf?.position?.y as number) + diff.y,
|
||||
updatedNode.__vf.position = {
|
||||
x: (node.__vf?.position?.x as number) + diff.x,
|
||||
y: (node.__vf?.position?.y as number) + diff.y,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ export default function flowStore(
|
||||
this.selectedElements = nextSelectedElements
|
||||
},
|
||||
unsetUserSelection() {
|
||||
const selectedNodes = this.selectedElements?.filter((node) => node && isNode(node) && node.__rf) as Node[]
|
||||
const selectedNodes = this.selectedElements?.filter((node) => node && isNode(node) && node.__vf) as Node[]
|
||||
|
||||
this.selectionActive = false
|
||||
this.userSelectionRect.draw = false
|
||||
@@ -237,9 +237,9 @@ export default function flowStore(
|
||||
this.nodes = this.nodes.map((node) => {
|
||||
return {
|
||||
...node,
|
||||
__rf: {
|
||||
...node.__rf,
|
||||
position: node.__rf?.position && clampPosition(node.__rf.position, nodeExtent),
|
||||
__vf: {
|
||||
...node.__vf,
|
||||
position: node.__vf?.position && clampPosition(node.__vf.position, nodeExtent),
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
+3
-3
@@ -109,16 +109,16 @@ export const parseElements = async (elements: Elements, nodes: Node[], edges: Ed
|
||||
...storeNode,
|
||||
...element,
|
||||
}
|
||||
if (!updatedNode.__rf) updatedNode.__rf = {}
|
||||
if (!updatedNode.__vf) updatedNode.__vf = {}
|
||||
|
||||
if (storeNode.position.x !== element.position.x || storeNode.position.y !== element.position.y) {
|
||||
updatedNode.__rf.position = element.position
|
||||
updatedNode.__vf.position = element.position
|
||||
}
|
||||
|
||||
if (typeof element.type !== 'undefined' && element.type !== storeNode.type) {
|
||||
// we reset the elements dimensions here in order to force a re-calculation of the bounds.
|
||||
// When the type of a node changes it is possible that the number or positions of handles changes too.
|
||||
updatedNode.__rf.width = undefined
|
||||
updatedNode.__vf.width = undefined
|
||||
}
|
||||
|
||||
nextElements.nextNodes.push(updatedNode)
|
||||
|
||||
Reference in New Issue
Block a user