question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Link target port points towards 0,0

See original GitHub issue

I have an issue when trying to automatically link new nodes to the previous node. The link finds its source port (the Create node in image), but the target port is pointing towards 0,0 instead of the new node CreateDatabase. Yet they are linked - moving CreateDatabase also moves the link end vertex.

react_diagrams_bad_link

The node and link are inserted on an onClick event triggerring the following function.

    addManipulator(event) {        
        let { engine } = this.props;		
        let model = engine.getDiagramModel();
        
        var node = new ManipulatorNodeModel({ 
            name: event.target.value
        });
        
        node.setPosition(500+Math.random()*100, 350+Math.random()*100);
        model.addNode(node);

        var previousNode = model.nodes[this.props.previousNodeId];
        if(previousNode) {
            var fromPort = previousNode.getOutPorts()[0]; // Assume 1 port only
            var toPort = node.getInPorts()[0]; // Assume 1 port only
            var link = fromPort.link(toPort);
            model.addLink(link);
        }

        this.props.registerPreviousNode(node.id);
        this.props.reDrawDiagram(Date.now());
    }

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
Letrabcommented, Oct 20, 2019

Got this problem as well (v6). Solved it with doing reportPosition for all ports:

Fixing after drawing:

    _.forEach(model.getNodes(), node => {
      _.forEach(node.getPorts(), port => {
        port.reportPosition()
      });
    })

Or fixing before drawing:

            link.setSourcePort(outPort);
            link.setTargetPort(inPort);
            inPort.reportPosition()
            outPort.reportPosition()
            this.state.model.addAll(link);
2reactions
magnafilixcommented, Nov 19, 2019

@Letrab thank you! Your solution works perfectly!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relative URL to a different port number in a hyperlink?
Here is a method to change the URL just after the page loads, ... if (port) { target.href = window.location.origin; target.port = port[1];...
Read more >
Joints js connect to ports on a specified point alone
Hi,. How can i allow a link to be connected to a port on a specified point alone , in the below diagram...
Read more >
<a>: The Anchor element - HTML: HyperText Markup Language
The HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the ...
Read more >
How to use Nmap to scan for open ports - TechTarget
To launch a default scan, the bare minimum you need is a target. ... system call to obtain the port state information, meaning...
Read more >
Working with Ports (Outdated) - JointJS
A link might then point not to the element as a whole but to a certain port instead. JointJS has a built-in support...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found