【发布时间】:2015-10-18 19:09:00
【问题描述】:
点击论文的空白处会添加一个新单元格:
paper.on({
'blank:pointerdblclick': function(event, x, y) {
var rect = new joint.shapes.app.Standard({
position: { x: x, y: y },
size: { width: 100, height: 80 },
});
graph.addCell(rect);
rect.on('change:position', function() {
paper.fitToContent();
});
}
});
但是由于change:position 事件是在blank:pointerdblclick 事件中设置的,它只会触发新元素。但应该为本文存在的所有单元格设置它。
因此,为了移动纸上的任何单元格,应该执行 fitToContent() 函数...
我该怎么做?
P.S.:标准元素的定义如下:
joint.shapes.app.Standard = joint.shapes.basic.Generic.extend({
markup: '<rect/><circle class="port-top"/><circle class="port-bottom"/><circle class="port-right"/><circle class="port-left"/><text/>',
defaults: joint.util.deepSupplement({
type: 'app.Standard',
attrs: {
...
}
}, joint.shapes.basic.Generic.prototype.defaults)
});
【问题讨论】:
标签: javascript jointjs