David Benson 2020-11-11 12:44:27 +00:00 committed by GitHub
parent 5d4f1976e9
commit 82321b3496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -2099,29 +2099,27 @@ mxGraphView.prototype.getRelativePoint = function(edgeState, x, y)
var totalLength = edgeState.length; var totalLength = edgeState.length;
var segments = edgeState.segments; var segments = edgeState.segments;
// Works which line segment the point of the label is closest to // Works out which line segment the point of the label is closest to
var p0 = edgeState.absolutePoints[0]; var p0 = edgeState.absolutePoints[0];
var pe = edgeState.absolutePoints[1]; var pe = edgeState.absolutePoints[1];
var minDist = mxUtils.ptSegDistSq(p0.x, p0.y, pe.x, pe.y, x, y); var minDist = mxUtils.ptSegDistSq(p0.x, p0.y, pe.x, pe.y, x, y);
var length = 0;
var index = 0; var index = 0;
var tmp = 0; var tmp = 0;
var length = 0;
for (var i = 2; i < pointCount; i++) for (var i = 2; i < pointCount; i++)
{ {
tmp += segments[i - 2]; p0 = pe;
pe = edgeState.absolutePoints[i]; pe = edgeState.absolutePoints[i];
var dist = mxUtils.ptSegDistSq(p0.x, p0.y, pe.x, pe.y, x, y); var dist = mxUtils.ptSegDistSq(p0.x, p0.y, pe.x, pe.y, x, y);
tmp += segments[i - 2];
if (dist <= minDist) if (dist <= minDist)
{ {
minDist = dist; minDist = dist;
index = i - 1; index = i - 1;
length = tmp; length = tmp;
} }
p0 = pe;
} }
var seg = segments[index]; var seg = segments[index];