react-lineage-dag
Advanced tools
Comparing version 2.0.13 to 2.0.15
{ | ||
"name": "react-lineage-dag", | ||
"version": "2.0.13", | ||
"version": "2.0.15", | ||
"description": "表格/字段血缘React组件", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -22,2 +22,15 @@ import {Canvas, Layout} from 'butterfly-dag'; | ||
} | ||
this.on('custom.edge.redraw', (data) => { | ||
let node = data.node; | ||
let points = data.points; | ||
let edges = []; | ||
if (points) { | ||
points.forEach((_point) => { | ||
edges = edges.concat(this.getNeighborEdgesByEndpoint(node.id, _point.id)); | ||
}); | ||
} else { | ||
edges = this.getNeighborEdges(node.id); | ||
} | ||
edges.forEach((edge) => edge.redraw()); | ||
}); | ||
} | ||
@@ -106,3 +119,2 @@ focus(nodeId) { | ||
_precollide = (nodes, nodestep, rankstep) => { | ||
const rank = {}; | ||
@@ -174,6 +186,8 @@ let rankKeys = []; | ||
let nextLeft = _.get(rank, [nextKey, 0, 'left'], nextKey); | ||
if (maxRank[currentKey] - nextLeft > rankstep) { | ||
rank[nextKey].forEach((item) => { | ||
item.left = maxRank[currentKey]; | ||
if (nextLeft - maxRank[currentKey] < rankstep) { | ||
rank[nextKey].forEach(function (item) { | ||
item.left = maxRank[currentKey] + rankstep; | ||
}); | ||
let _tmpGap = maxRank[currentKey] + rankstep - nextLeft; | ||
maxRank[nextKey] += _tmpGap; | ||
} | ||
@@ -180,0 +194,0 @@ } |
@@ -27,2 +27,3 @@ import {Node} from 'butterfly-dag'; | ||
this.height = this.options.height = $(this.dom).height(); | ||
} | ||
@@ -139,3 +140,24 @@ draw(obj) { | ||
titleDom = $(`<div class="title"></div>`); | ||
ReactDOM.render(titleRender(title, this), titleDom[0]); | ||
ReactDOM.render(titleRender(title, this), titleDom[0], () => { | ||
if (this.height === 0 || this.width === 0) { | ||
this.width = this.options.width = $(this.dom).width(); | ||
this.height = this.options.height = $(this.dom).height(); | ||
this.endpoints.forEach((item) => item.updatePos()); | ||
this.emit('custom.edge.redraw', { | ||
node: this | ||
}) | ||
} else { | ||
let points = []; | ||
this.endpoints.forEach((item) => { | ||
if (item.options._isNodeSelf) { | ||
item.updatePos(); | ||
points.push(item); | ||
} | ||
}); | ||
this.emit('custom.edge.redraw', { | ||
node: this, | ||
points | ||
}) | ||
} | ||
}); | ||
} else if (title) { | ||
@@ -142,0 +164,0 @@ titleDom = $(`<div class="title">${title}</div>`); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
260212
4549