最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - In JointJS, how an element accesses position, inPorts, outPorts? - Stack Overflow

programmeradmin1浏览0评论

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').

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论