admin管理员组

文章数量:1430083

I am using jointJS for my academic project, I have such a question, How an element accesses position, inPorts, outPorts? For example, we create an element like this,

var m1 = new joint.shapes.devs.Model({
position: { x: 50, y: 50 },
size: { width: 90, height: 90 },
inPorts: ['in1','in2'],
outPorts: ['out'],
attrs: {
    '.label': { text: 'Model', 'ref-x': .4, 'ref-y': .2 },
    rect: { fill: '#2ECC71' },
    '.inPorts circle': { fill: '#16A085' },
    '.outPorts circle': { fill: '#E74C3C' }
}
});
graph.addCell(m1);

I want to get position and inPorts from m1, I have tried m1( 'position' ) and m1.position() , but it didn't work.

Can someone solve this problem? Thank you in advance.

I am using jointJS for my academic project, I have such a question, How an element accesses position, inPorts, outPorts? For example, we create an element like this,

var m1 = new joint.shapes.devs.Model({
position: { x: 50, y: 50 },
size: { width: 90, height: 90 },
inPorts: ['in1','in2'],
outPorts: ['out'],
attrs: {
    '.label': { text: 'Model', 'ref-x': .4, 'ref-y': .2 },
    rect: { fill: '#2ECC71' },
    '.inPorts circle': { fill: '#16A085' },
    '.outPorts circle': { fill: '#E74C3C' }
}
});
graph.addCell(m1);

I want to get position and inPorts from m1, I have tried m1( 'position' ) and m1.position() , but it didn't work.

Can someone solve this problem? Thank you in advance.

Share Improve this question asked Feb 23, 2015 at 9:29 YabingYabing 431 silver badge5 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

You can use m1.get('position') and m1.get('inPorts'). You could also use m1.prop('position') and m1.prop('inPorts'). The difference is that get(property) is only for accessing flat properties while prop(path) is able to get nested properties as well (e.g. m1.prop('attrs/rect/fill').

本文标签: