Merge pull request #5087 from node-red/5083-handle-zoomed-ff

Properly handle scale factor in getLinksAtPoint for firefox
5090-fix-label-action
Nick O'Leary 2025-04-14 10:06:08 +01:00 committed by GitHub
commit a424df4272
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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])
}