Skip to content

Commit

Permalink
loopback edge control points further out noflo/noflo-ui#53 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
forresto committed May 25, 2014
1 parent ce2b2cb commit 2d372c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "the-graph",
"version": "0.2.3",
"keywords": [
"graph",
"flow",
"noflo"
],
"description": "Polymer elements for graph editing",
"description": "HTML custom elements for dataflow graph editing",
"dependencies": {
"polymer": "Polymer/polymer#0.2.4",
"hammerjs": "~1.1.2",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "the-graph",
"version": "0.0.0",
"version": "0.2.3",
"description": "polymer components for flow-based programming graph editing",
"main": "the-graph-editor/index.html",
"dependencies": {
Expand Down
17 changes: 9 additions & 8 deletions the-graph/the-graph-edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,19 @@
// Organic / curved edge
var c1X, c1Y, c2X, c2Y;
if (targetX-5 < sourceX) {
var curveFactor = (sourceX - targetX) * CURVE / 200;
if (Math.abs(targetY-sourceY) < TheGraph.nodeSize/2) {
// Loopback
c1X = sourceX + CURVE;
c1Y = sourceY - CURVE;
c2X = targetX - CURVE;
c2Y = targetY - CURVE;
c1X = sourceX + curveFactor;
c1Y = sourceY - curveFactor;
c2X = targetX - curveFactor;
c2Y = targetY - curveFactor;
} else {
// Stick out some
c1X = sourceX + CURVE;
c1Y = sourceY + (targetY > sourceY ? CURVE : -CURVE);
c2X = targetX - CURVE;
c2Y = targetY + (targetY > sourceY ? -CURVE : CURVE);
c1X = sourceX + curveFactor;
c1Y = sourceY + (targetY > sourceY ? curveFactor : -curveFactor);
c2X = targetX - curveFactor;
c2Y = targetY + (targetY > sourceY ? -curveFactor : curveFactor);
}
} else {
// Controls halfway between
Expand Down

0 comments on commit 2d372c2

Please sign in to comment.