Support relative positioning for link tools group

This commit is contained in:
BoykoAlex
2019-12-04 11:46:02 -05:00
parent fbdad04b14
commit 24ca3c0f52

View File

@@ -199,8 +199,25 @@ joint.shapes.flo.Link = joint.dia.Link.extend({
joint.shapes.flo.LinkView = joint.dia.LinkView.extend({
options: joint.util.deepSupplement({
linkToolsOffset: 0.5,
shortLinkLength: 40
}, joint.dia.LinkView.prototype.options),
updateToolsPosition: function() {
// Overriden to support relative offset for tools placement.
// If offset is between 0 and 1 then percentage of the connection length will be used to offset the tools group
if (this.options.linkToolsOffset < 1 && this.options.linkToolsOffset > 0) {
let connectionLength = this.getConnectionLength();
const relativeOffset = this.options.linkToolsOffset
this.options.linkToolsOffset = connectionLength * relativeOffset;
const returnValue = joint.dia.LinkView.prototype.updateToolsPosition.apply(this, arguments);
this.options.linkToolsOffset = relativeOffset;
return returnValue;
} else {
return joint.dia.LinkView.prototype.updateToolsPosition.apply(this, arguments);
}
},
_beforeArrowheadMove: function() {
if (this.model.get('source').id) {
this._oldSource = this.model.get('source');