refactor(nodes): Remove position func
* it's not improving on existing methods, i.e. no real benefit to it
This commit is contained in:
@@ -103,12 +103,7 @@ const createGraphNodes = (nodes: Node[], getNode: Getters['getNode'], currGraphN
|
|||||||
if (node.parentNode && !nextNodes.find((n) => n.id === node.parentNode)) {
|
if (node.parentNode && !nextNodes.find((n) => n.id === node.parentNode)) {
|
||||||
console.warn(`[vueflow]: Parent node ${node.parentNode} not found`)
|
console.warn(`[vueflow]: Parent node ${node.parentNode} not found`)
|
||||||
}
|
}
|
||||||
const position =
|
|
||||||
(<any>node).position instanceof Function
|
|
||||||
? (<any>node).position(node, currGraphNodes, node.parentNode ? getNode(node.parentNode) : undefined)
|
|
||||||
: node.position
|
|
||||||
|
|
||||||
if (position) node.position = position
|
|
||||||
if (node.parentNode || parentNodes[node.id]) {
|
if (node.parentNode || parentNodes[node.id]) {
|
||||||
if (parentNodes[node.id]) {
|
if (parentNodes[node.id]) {
|
||||||
node.isParent = true
|
node.isParent = true
|
||||||
|
|||||||
@@ -10,17 +10,12 @@ export type NodeHandleBounds = {
|
|||||||
target?: HandleElement[]
|
target?: HandleElement[]
|
||||||
}
|
}
|
||||||
|
|
||||||
type PositionFunc = <Data = ElementData>(
|
|
||||||
node: GraphNode<Data>,
|
|
||||||
currNodes: GraphNode<Data>[],
|
|
||||||
parentNode: GraphNode<Data>,
|
|
||||||
) => XYPosition
|
|
||||||
type WidthFunc = <Data = ElementData>(node: GraphNode<Data>) => number | string | void
|
type WidthFunc = <Data = ElementData>(node: GraphNode<Data>) => number | string | void
|
||||||
type HeightFunc = <Data = ElementData>(node: GraphNode<Data>) => number | string | void
|
type HeightFunc = <Data = ElementData>(node: GraphNode<Data>) => number | string | void
|
||||||
|
|
||||||
export interface Node<Data = ElementData> extends Element<Data> {
|
export interface Node<Data = ElementData> extends Element<Data> {
|
||||||
/** initial node position x, y */
|
/** initial node position x, y */
|
||||||
position: XYPosition | PositionFunc
|
position: XYPosition
|
||||||
/** node type, can be a default type or a custom type */
|
/** node type, can be a default type or a custom type */
|
||||||
type?: keyof DefaultNodeTypes | string
|
type?: keyof DefaultNodeTypes | string
|
||||||
/** handle position */
|
/** handle position */
|
||||||
@@ -60,8 +55,6 @@ export interface Node<Data = ElementData> extends Element<Data> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface GraphNode<Data = ElementData> extends Node<Data> {
|
export interface GraphNode<Data = ElementData> extends Node<Data> {
|
||||||
/** current node position x, y */
|
|
||||||
position: XYPosition
|
|
||||||
/** absolute position in relation to parent elements + z-index */
|
/** absolute position in relation to parent elements + z-index */
|
||||||
computedPosition: XYZPosition
|
computedPosition: XYZPosition
|
||||||
handleBounds: NodeHandleBounds
|
handleBounds: NodeHandleBounds
|
||||||
|
|||||||
Reference in New Issue
Block a user