Ben
Ben

Reputation: 31

How to set target anchor when creating a link

I'm trying to set a specific anchor point when creating a link. I believe I'm doing everything correctly, but the anchor options are being ignored. In fact, any options I pass in are being ignored.

My code looks something like this:

new joint.shapes.standard.Link().target({id: 'xxx'}, {
    anchor: {
        name: 'center',
        args: { dy: -15 }
    }
});

The target id is being correctly handled, but whatever I pass in the second parameter is totally ignored.

Has anyone come across this before?

Upvotes: 1

Views: 869

Answers (1)

Ben
Ben

Reputation: 31

After experimenting, I worked out that when passing an object with id, rather than parsing a target element, that the opts need to go inside the object with the id. This is not documented AFAIK. i.e.

.target({id: element.id, opts})

In my specific case, I'm passing the following:

.target({ id: to.id, anchor: { name: 'center', args: { dy: -15 }}})

This seems to work correctly

Upvotes: 1

Related Questions