1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix palette node link splicing on Firefox

This commit is contained in:
Nick O'Leary 2016-01-10 22:25:20 +00:00
parent 9bca2a91c9
commit 4c6771669b
2 changed files with 28 additions and 9 deletions

View File

@ -233,17 +233,25 @@ RED.palette = (function() {
if (!spliceTimer) { if (!spliceTimer) {
spliceTimer = setTimeout(function() { spliceTimer = setTimeout(function() {
var nodes = [];
var bestDistance = Infinity;
var bestLink = null;
if (chartSVG.getIntersectionList) {
var svgRect = chartSVG.createSVGRect(); var svgRect = chartSVG.createSVGRect();
svgRect.x = mouseX; svgRect.x = mouseX;
svgRect.y = mouseY; svgRect.y = mouseY;
svgRect.width = 1; svgRect.width = 1;
svgRect.height = 1; svgRect.height = 1;
var bestDistance = Infinity; nodes = chartSVG.getIntersectionList(svgRect,chartSVG);
var bestLink = null;
var nodes = chartSVG.getIntersectionList(svgRect,chartSVG);
mouseX /= RED.view.scale(); mouseX /= RED.view.scale();
mouseY /= RED.view.scale(); mouseY /= RED.view.scale();
} else {
// Firefox doesn't do getIntersectionList and that
// makes us sad
mouseX /= RED.view.scale();
mouseY /= RED.view.scale();
nodes = RED.view.getLinksAtPoint(mouseX,mouseY);
}
for (var i=0;i<nodes.length;i++) { for (var i=0;i<nodes.length;i++) {
if (d3.select(nodes[i]).classed('link_background')) { if (d3.select(nodes[i]).classed('link_background')) {
var length = nodes[i].getTotalLength(); var length = nodes[i].getTotalLength();

View File

@ -1971,6 +1971,17 @@ RED.view = (function() {
}, },
scale: function() { scale: function() {
return scaleFactor; return scaleFactor;
},
getLinksAtPoint: function(x,y) {
var result = [];
var links = outer.selectAll(".link_background")[0];
for (var i=0;i<links.length;i++) {
var bb = links[i].getBBox();
if (x >= bb.x && y >= bb.y && x <= bb.x+bb.width && y <= bb.y+bb.height) {
result.push(links[i])
}
}
return result;
} }
}; };
})(); })();