Skip to content

Commit

Permalink
Fix palette node link splicing on Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed Jan 10, 2016
1 parent 9bca2a9 commit 4c67716
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
26 changes: 17 additions & 9 deletions editor/js/ui/palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,25 @@ RED.palette = (function() {

if (!spliceTimer) {
spliceTimer = setTimeout(function() {

var svgRect = chartSVG.createSVGRect();
svgRect.x = mouseX;
svgRect.y = mouseY;
svgRect.width = 1;
svgRect.height = 1;
var nodes = [];
var bestDistance = Infinity;
var bestLink = null;
var nodes = chartSVG.getIntersectionList(svgRect,chartSVG);
mouseX /= RED.view.scale();
mouseY /= RED.view.scale();
if (chartSVG.getIntersectionList) {
var svgRect = chartSVG.createSVGRect();
svgRect.x = mouseX;
svgRect.y = mouseY;
svgRect.width = 1;
svgRect.height = 1;
nodes = chartSVG.getIntersectionList(svgRect,chartSVG);
mouseX /= 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++) {
if (d3.select(nodes[i]).classed('link_background')) {
var length = nodes[i].getTotalLength();
Expand Down
11 changes: 11 additions & 0 deletions editor/js/ui/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,17 @@ RED.view = (function() {
},
scale: function() {
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;
}
};
})();

0 comments on commit 4c67716

Please sign in to comment.