-
Notifications
You must be signed in to change notification settings - Fork 852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DoubleLinkTools with new linkTools API #1322
Comments
Just for reference, I ended up overwriting the default joint.linkTools.Button.prototype.update = function() {
if (this.relatedView.isShortLink())
this.options.distance = this.options.distanceShort || this.options.distance;
else
this.options.distance = this.options.distanceLong || this.options.distance;
this.position();
return this;
};
joint.linkTools.Button.prototype.show = function() {
if (this.options.secondary && this.relatedView.isShortLink()) return;
this.el.style.display = '';
this._visible = true;
}; The used LinkView needs then to have the corresponding |
You may also extend the Button class instead. const MyButton = joint.linkTools.Button.extend({
update: function() {
if (this.relatedView.isShortLink())
this.options.distance = this.options.distanceShort || this.options.distance;
else
this.options.distance = this.options.distanceLong || this.options.distance;
this.position();
return this;
},
show: function() {
if (this.options.secondary && this.relatedView.isShortLink()) return;
this.el.style.display = '';
this._visible = true;
}
}); Anyway, we could make new joint.linkToolsButton({
distance: function(linkView) {
return (linkView.getConnectionLength() > 50) ? 20 : 10;
}
}); |
I want to achieve a similar result to what has been possible before by setting
on a custom linkView type using the new linkTools API.
I thought of different solutions how to handle the additional buttons for longer links, but I'm not sure if they are possible and what would be considered best practice:
linkTool.hide/.show()
depending on the link's length inside anUPDATE
cycleAlso another related question: Is it also possible to change some options, e.g. the
distance
of aButton
, after tool creation s.th. it would be possible to move them depending on the link's length?The text was updated successfully, but these errors were encountered: