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.

Ports lose styling when adding additional ports.

See original GitHub issue

Hello!

I’ve found an issue where adding ports to an Element seems to undo styling previously applied to other ports. Here’s an example:

elem.attr('[port="port_a"]/fill', 'rgb(200, 200, 0)')
elem.set('inPorts', [...elem.get('inPorts'), 'port_b'])

The styling on port_a will go away.

Thanks!

EDIT: updating ports after styling is import for the application I’m working on because we deal with a lot of dynamic ports.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vtalascommented, Jul 26, 2016

you can pass ports directly throuht the constructor as well …

var rect = new joint.shapes.basic.Rect({
    position: { x: 425, y: 60 },
    size: { width: 200, height: 100 },
    attrs: {
        text: { text: 'left', fill: '#6a6c8a' },
        rect: { stroke: '#31d0c6', 'stroke-width': 2 }
    },
    ports: {
        groups: {
            // groups definition 
        },
        items: [
            { group: 'in', attrs: { text: { text: 'in1' } } },
            { group: 'in', attrs: { text: { text: 'in2' } } },

            { group: 'out', attrs: { text: { text: 'out1' } } }
        ]
    }
});
1reaction
vtalascommented, Jul 26, 2016

Good to hear it’s going well. You can define your own groups easily like this:

var rect = new joint.shapes.basic.Rect({
    position: { x: 425, y: 60 },
    size: { width: 200, height: 100 },
    attrs: {
        text: { text: 'left', fill: '#6a6c8a' },
        rect: { stroke: '#31d0c6', 'stroke-width': 2 }
    },
    ports: {
        groups: {
            'in': {
                position: 'left',
                label: {
                    position: 'left'
                },
                attrs: {
                    text: { fill: '#000000' },
                    circle: { fill: '#ffffff', stroke: 'green', 'stroke-width': 2, r: 10, magnet: 'passive' }
                }
            },
            'out': {
                position: 'right',
                label: {
                    position: 'right'
                },
                attrs: {
                    text: { fill: '#000000' },
                    circle: { fill: '#ffffff', stroke: 'red', 'stroke-width': 2, r: 10, magnet: true }
                }
            }
        }
    }
});

rect.addPort({ group: 'in', attrs: { text: { text: 'in1' } } });
rect.addPort({ group: 'in', attrs: { text: { text: 'in2' } } });

rect.addPort({ group: 'out', attrs: { text: { text: 'out1' } } });
rect.addPort({ group: 'out', attrs: { text: { text: 'out2' } } });
rect.addPort({ group: 'out', attrs: { text: { text: 'out3' } } });

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add or remove ports from a broadcast domain
Display the ports that are currently assigned or unassigned to a broadcast domain by using the network port show command. · Add or...
Read more >
how is port position saved and used in EA? - Sparx Systems
I hope somebody can help. I am adding ports to an element in EA via automation interface and the position of the port...
Read more >
The new iMac's paltry port selection doesn't bode ... - Engadget
Multiple reports say the laptop will lose the much-maligned Touch Bar and get a new magnetic charger, among other things. Based on the...
Read more >
Relative URL to a different port number in a hyperlink?
How about these: Modify the port number on click: <a href="/other/" onclick="javascript:event.target.port=8080">Look at another port</a>.
Read more >
Supply Chain Latest: West Coast Ports to Cede Cargo to East ...
Charted Territory. relates to Cargo Shift to US East Coast May Be Permanent Loss for Pacific Ports. New Tools | Assessing supply chain ......
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