Skip to content
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

Improve block connectors #223

Merged
merged 2 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ npm start
| French | ![Progress](http://progressed.io/bar/100) |
| Chinese | ![Progress](http://progressed.io/bar/100) |
| Catalan | ![Progress](http://progressed.io/bar/100) |
| Basque | ![Progress](http://progressed.io/bar/100) |
| Galician | ![Progress](http://progressed.io/bar/97) |
| Basque | ![Progress](http://progressed.io/bar/95) |

**Contribute!**

Expand Down
4 changes: 2 additions & 2 deletions app/scripts/graphics/joint.connectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ joint.connectors.ice = function(sourcePoint, targetPoint, vertices) {
var dVertices = [];
_.each(vertices, function(vertex) { dVertices.push(vertex.x, vertex.y); });

full.push(sourcePoint.x + sx, sourcePoint.y + sy);
full.push(sourcePoint.x, sourcePoint.y);
wrap.push(sourcePoint.x - sx, sourcePoint.y - sy);

full = full.concat(dVertices);
wrap = wrap.concat(dVertices);

full.push(targetPoint.x + tx, targetPoint.y + ty);
full.push(targetPoint.x, targetPoint.y);
wrap.push(targetPoint.x - tx, targetPoint.y - ty);

return {
Expand Down
16 changes: 14 additions & 2 deletions app/scripts/graphics/joint.routers.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,21 @@ joint.routers.ice = (function(g, _, joint) {
// enable/disable linkView perpendicular option
this.options.perpendicular = !!opt.perpendicular;

// Force source/target BBoxes to be points

this.sourceBBox.x += this.sourceBBox.width / 2;
this.sourceBBox.y += this.sourceBBox.height / 2;
this.sourceBBox.width = 0;
this.sourceBBox.height = 0;

this.targetBBox.x += this.targetBBox.width / 2;
this.targetBBox.y += this.targetBBox.height / 2;
this.targetBBox.width = 0;
this.targetBBox.height = 0;

// expand boxes by specific padding
var sourceBBox = g.rect(this.sourceBBox).moveAndExpand(opt.paddingBox);
var targetBBox = g.rect(this.targetBBox).moveAndExpand(opt.paddingBox);
var sourceBBox = g.rect(this.sourceBBox);
var targetBBox = g.rect(this.targetBBox);

// pathfinding
var map = (new ObstacleMap(opt)).build(this.paper.model, this.model);
Expand Down
44 changes: 12 additions & 32 deletions app/scripts/graphics/joint.shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ joint.shapes.ice.Model = joint.shapes.basic.Generic.extend({
stroke: 'none'
},
'.port-body': {
r: 8,
r: 16,
opacity: 0
},
'.leftPorts .port-body': {
Expand Down Expand Up @@ -1487,16 +1487,16 @@ joint.shapes.ice.Wire = joint.dia.Link.extend({

arrowheadMarkup: [
'<g class="marker-arrowhead-group marker-arrowhead-group-<%= end %>">',
'<circle class="marker-arrowhead" end="<%= end %>" r="7"/>',
'<circle class="marker-arrowhead" end="<%= end %>" r="8"/>',
'</g>'
].join(''),

toolMarkup: [
'<g class="link-tool">',
'<g class="tool-remove" event="remove">',
'<circle r="8.5" />',
'<circle r="8" />',
'<path transform="scale(.6) translate(-16, -16)" d="M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 16.447,13.087 10.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10.946,24.248 16.447,18.746 21.948,24.248z" />',
'<title>Remove link.</title>',
'<title>Remove link</title>',
'</g>',
'</g>'
].join(''),
Expand All @@ -1506,7 +1506,7 @@ joint.shapes.ice.Wire = joint.dia.Link.extend({
'<circle class="marker-vertex" idx="<%= idx %>" r="8" />',
'<path class="marker-vertex-remove-area" idx="<%= idx %>" transform="scale(.8) translate(5, -33)" d="M16,5.333c-7.732,0-14,4.701-14,10.5c0,1.982,0.741,3.833,2.016,5.414L2,25.667l5.613-1.441c2.339,1.317,5.237,2.107,8.387,2.107c7.732,0,14-4.701,14-10.5C30,10.034,23.732,5.333,16,5.333z"/>',
'<path class="marker-vertex-remove" idx="<%= idx %>" transform="scale(.6) translate(11.5, -39)" d="M24.778,21.419 19.276,15.917 24.777,10.415 21.949,7.585 16.447,13.087 10.945,7.585 8.117,10.415 13.618,15.917 8.116,21.419 10.946,24.248 16.447,18.746 21.948,24.248z">',
'<title>Remove vertex.</title>',
'<title>Remove vertex</title>',
'</path>',
'</g>'
].join(''),
Expand Down Expand Up @@ -1536,7 +1536,7 @@ joint.shapes.ice.Wire = joint.dia.Link.extend({
},

router: { name: 'ice' },
connector: { name: 'ice'},
connector: { name: 'ice' }

}, joint.dia.Link.prototype.defaults)

Expand All @@ -1545,9 +1545,9 @@ joint.shapes.ice.Wire = joint.dia.Link.extend({
joint.shapes.ice.WireView = joint.dia.LinkView.extend({

options: {
shortLinkLength: 100,
shortLinkLength: 64,
longLinkLength: 160,
linkToolsOffset: 40,
linkToolsOffset: 40
},

initialize: function() {
Expand Down Expand Up @@ -1682,30 +1682,10 @@ joint.shapes.ice.WireView = joint.dia.LinkView.extend({
updateConnection: function(opt) {
opt = opt || {};

var model = this.model;
var route;

if (opt.translateBy && model.isRelationshipEmbeddedIn(opt.translateBy)) {
// The link is being translated by an ancestor that will
// shift source point, target point and all vertices
// by an equal distance.
var tx = opt.tx || 0;
var ty = opt.ty || 0;

route = this.route = _.map(this.route, function(point) {
// translate point by point by delta translation
return g.point(point).offset(tx, ty);
});

// translate source and target connection and marker points.
this._translateConnectionPoints(tx, ty);

} else {
// Necessary path finding
route = this.route = this.findRoute(model.get('vertices') || [], opt);
// finds all the connection points taking new vertices into account
this._findConnectionPoints(route);
}
// Necessary path finding
var route = this.route = this.findRoute(this.model.get('vertices') || [], opt);
// finds all the connection points taking new vertices into account
this._findConnectionPoints(route);

var pathData = this.getPathData(route);

Expand Down
55 changes: 24 additions & 31 deletions app/styles/design.css
Original file line number Diff line number Diff line change
Expand Up @@ -492,50 +492,43 @@ g {

/* Wires makers */

.joint-link.joint-theme-default .connection-wrap {
stroke: #000000;
stroke-width: 15;
stroke-linecap: butt;
stroke-linejoin: butt;
opacity: 0;
.link.joint-theme-default .connection-wrap {
stroke: #777;
stroke-width: 14;
cursor: pointer;
opacity: 0;
}
.joint-link.joint-theme-default .connection-wrap:hover {
opacity: .4;
stroke-opacity: .4;

.link.joint-theme-default .link-tools .tool-remove circle {
fill: #ff333a;
}
.joint-link.joint-theme-default .connection {
stroke-linejoin: butt;
.link.joint-theme-default .link-tools .tool-remove path {
fill: #FFF;
}
.joint-link.joint-theme-default .link-tools .tool-remove circle {
fill: #EB2222;

.link.joint-theme-default .marker-arrowhead {
fill: #AAA;
}
.joint-link.joint-theme-default .link-tools .tool-remove path {
fill: #FFFFFF;
.link.joint-theme-default .marker-arrowhead:hover {
fill: #888;
}

/* <circle> element inside .marker-vertex-group <g> element */
.joint-link.joint-theme-default .marker-vertex {
fill: #64b0ce;
.link.joint-theme-default .marker-vertex {
fill: #AAA;
}
.joint-link.joint-theme-default .marker-vertex:hover {
fill: #317d9b;
stroke: none;
.link.joint-theme-default .marker-vertex:hover {
fill: #888;
}

.joint-link.joint-theme-default .marker-arrowhead {
fill: #64b0ce;
.link.joint-theme-default .marker-vertex-remove {
fill: #FFF;
transition: opacity 0.4s;
}
.joint-link.joint-theme-default .marker-arrowhead:hover {
fill: #317d9b;
stroke: none;
.link.joint-theme-default .marker-vertex-remove-area {
fill: #333;
transition: opacity 0.4s;
}

/* <circle> element used to remove a vertex */
.joint-link.joint-theme-default .marker-vertex-remove {
fill: #FFFFFF;

}
/* Resizer */

.resizer {
Expand Down