Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link head out of place with "metro" router. #1246

Open
emiliojoseav opened this issue Jan 27, 2020 · 1 comment
Open

Link head out of place with "metro" router. #1246

emiliojoseav opened this issue Jan 27, 2020 · 1 comment
Labels

Comments

@emiliojoseav
Copy link

emiliojoseav commented Jan 27, 2020

Hi, something is happening with the links head using "metro" router. When I have 2 boxes connected by a link, depending of the boxes position, the head of the link seams to move out of its natural place.

It happens the same with bouth APIS, "joint.dia.Link" and " joint.shapes.standard.Link".
Here is my Link code:

var CustomLink = joint.dia.Link.define('standard.Link', {
        attrs: {
            line: {
                connection: true,
                stroke: '#3498DB',
                strokeWidth: 3,
                strokeLinejoin: 'round',
                targetMarker: {
                    'type': 'path',
                    'd': 'M 10 -5 0 0 10 5 z'
                }
            }
        },
        router: { name: 'metro' },
        connector: { name: 'rounded', args: { radius: 20 } }
    }, {
            markup: [{
                tagName: 'path',
                selector: 'wrapper',
                attributes: {
                    'cursor': 'pointer'
                }
            }, {
                tagName: 'path',
                selector: 'line',
                attributes: {
                    'fill': 'none'
                }
            }]
        });

To solve the problem I'm using "manhattan router":
router: { name: 'manhattan', args: { padding: 20 } },

This is the JointJS Google Group thread:
https://groups.google.com/forum/#!topic/jointjs/BQc1qjR6pJ4

Greetings, Emilio.

@kumilingus kumilingus added the bug label Jan 28, 2020
@kumilingus
Copy link
Contributor

Hi, perhaps you can work around this issue by moving the link anchors. e.g if you have 2 port groups (one on the left in and one on the right out) you can move anchors outside the port to left resp. right.

paper.options.defaultAnchor = function(...args) {
        const magnet = args[1];
        const endType = args[4];
        const endView = this.getEndView(endType);
        if (endView) {
            const group = endView.findAttribute('port-group', magnet);
            if (group) {
                if (group === 'in') {
                    return joint.anchors.left(...args);
                }
                if (group === 'out') {
                    return joint.anchors.right(...args);
                }
            }
        }
        return joint.anchors.center(...args);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants