79
上周只上了三天班,哎,为了逃团建。
写一下节点大小自适应,编辑后就根据文字长度高度改变节点大小,还有连接桩位置,太难了这个。
createDiv ({
cell }) {
cell.attr('body', 'none')
const background = cell.attrs.rect.fill
const stretchedCells = document.getElementsByClassName('x6-cell x6-node')
const stretchedCell = []
for (const i in stretchedCells) {
if (stretchedCells[i].dataset) {
if (stretchedCells[i].dataset.cellId === cell.id) {
stretchedCell.push(stretchedCells[i])
}
}
}
const theStretchedCell = stretchedCell[0].getElementsByTagName('rect')
const position = cell.position()
const pos = this.graph.localToGraph(position)
// const p = this.graph.clientToGraph(e.clientX, e.clientY)
// const width = size.width
// const height = size.height
// const size = cell.size()
const x = pos.x
const y = pos.y
const width = theStretchedCell[0].width.animVal.value
const height = theStretchedCell[