Properly handle scale factor in getLinksAtPoint for firefox

pull/5087/head
Nick O'Leary 2025-03-24 16:34:01 +00:00
parent 23c44db30d
commit 5251e848b9
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 8 additions and 2 deletions

View File

@ -401,7 +401,7 @@ RED.palette = (function() {
} else {
// Firefox doesn't do getIntersectionList and that
// makes us sad
nodes = RED.view.getLinksAtPoint(mouseX,mouseY);
nodes = RED.view.getLinksAtPoint(mouseX / RED.view.scale(), mouseY / RED.view.scale());
}
var mx = mouseX / RED.view.scale();
var my = mouseY / RED.view.scale();

View File

@ -1908,7 +1908,7 @@ RED.view = (function() {
} else {
// Firefox doesn"t do getIntersectionList and that
// makes us sad
nodes = RED.view.getLinksAtPoint(mouseX*scaleFactor,mouseY*scaleFactor);
nodes = RED.view.getLinksAtPoint(mouseX, mouseY);
}
for (var i=0;i<nodes.length;i++) {
if (d3.select(nodes[i]).classed("red-ui-flow-link-background")) {
@ -6333,6 +6333,12 @@ RED.view = (function() {
var links = outer.selectAll(".red-ui-flow-link-background")[0];
for (var i=0;i<links.length;i++) {
var bb = links[i].getBBox();
if (bb.height === 0) {
// For horizontal links, add some real height to make them easier
// to hit.
bb.y -= Math.max(5, 5 / scaleFactor);
bb.height = Math.max(10, 10 / scaleFactor);
}
if (x >= bb.x && y >= bb.y && x <= bb.x+bb.width && y <= bb.y+bb.height) {
result.push(links[i])
}