Skip to content

Commit

Permalink
fix: 馃悰 edge connection error
Browse files Browse the repository at this point in the history
can not connect edge from source to target

fix #245
  • Loading branch information
bubkoo committed Sep 27, 2020
1 parent 4115b91 commit b3a5d03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions examples/x6-example-features/src/pages/ports/dynamic.tsx
Expand Up @@ -11,8 +11,8 @@ class MyShape extends Shape.Rect {
return this.getPortsByGroup('out')
}

getUsedInPorts() {
const incomingEdges = this.getIncomingEdges() || []
getUsedInPorts(graph: Graph) {
const incomingEdges = graph.getIncomingEdges(this) || []
return incomingEdges.map((edge: Edge) => {
const portId = edge.getTargetPortId()
return this.getPort(portId!)
Expand All @@ -25,10 +25,10 @@ class MyShape extends Shape.Rect {
})
}

updateInPorts() {
updateInPorts(graph: Graph) {
var minNumberOfPorts = 2
var ports = this.getInPorts()
var usedPorts = this.getUsedInPorts()
var usedPorts = this.getUsedInPorts(graph)
var newPorts = this.getNewInPorts(
Math.max(minNumberOfPorts - usedPorts.length, 1),
)
Expand Down Expand Up @@ -154,7 +154,7 @@ export default class Example extends React.Component {
const node = targetView.cell
if (node instanceof MyShape) {
var portId = targetMagnet.getAttribute('port')
var usedInPorts = node.getUsedInPorts()
var usedInPorts = node.getUsedInPorts(graph)
if (usedInPorts.find((port) => port && port.id === portId)) {
return false
}
Expand All @@ -167,15 +167,15 @@ export default class Example extends React.Component {
})

graph.addNode(
new MyShape().resize(120, 100).position(200, 100).updateInPorts(),
new MyShape().resize(120, 100).position(200, 100).updateInPorts(graph),
)

graph.addNode(
new MyShape().resize(120, 100).position(400, 100).updateInPorts(),
new MyShape().resize(120, 100).position(400, 100).updateInPorts(graph),
)

graph.addNode(
new MyShape().resize(120, 100).position(300, 400).updateInPorts(),
new MyShape().resize(120, 100).position(300, 400).updateInPorts(graph),
)

function update(view: NodeView) {
Expand All @@ -187,7 +187,7 @@ export default class Example extends React.Component {
highlighter: magnetAvailabilityHighlighter,
})
})
cell.updateInPorts()
cell.updateInPorts(graph)
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/x6/src/global/version.ts
Expand Up @@ -3,5 +3,5 @@
/**
* Auto generated version file, do not modify it!
*/
const version = '0.10.69'
const version = '0.10.70'
export { version }
4 changes: 2 additions & 2 deletions packages/x6/src/model/model.ts
Expand Up @@ -75,11 +75,11 @@ export class Model extends Basecoat<Model.EventArgs> {
this.notify('reseted', args)
})

collection.on('cell:change:source', ({ edge }) =>
collection.on('edge:change:source', ({ edge }) =>
this.onEdgeTerminalChanged(edge, 'source'),
)

collection.on('cell:change:target', ({ edge }) => {
collection.on('edge:change:target', ({ edge }) => {
this.onEdgeTerminalChanged(edge, 'target')
})
}
Expand Down

0 comments on commit b3a5d03

Please sign in to comment.