mirror of https://github.com/node-red/node-red.git
Merge pull request #4981 from node-red/4978-zoom-annotation-fix
Apply zoom scale when calculating annotation positionspull/4949/head^2
commit
69753a9940
|
@ -11,7 +11,7 @@ RED.view.annotations = (function() {
|
|||
}
|
||||
let badgeRDX = 0;
|
||||
let badgeLDX = 0;
|
||||
|
||||
const scale = RED.view.scale()
|
||||
for (let i=0,l=evt.el.__annotations__.length;i<l;i++) {
|
||||
const annotation = evt.el.__annotations__[i];
|
||||
if (annotations.hasOwnProperty(annotation.id)) {
|
||||
|
@ -42,15 +42,17 @@ RED.view.annotations = (function() {
|
|||
}
|
||||
if (isBadge) {
|
||||
if (showAnnotation) {
|
||||
const rect = annotation.element.getBoundingClientRect();
|
||||
// getBoundingClientRect is in real-world scale so needs to be adjusted according to
|
||||
// the current scale factor
|
||||
const rectWidth = annotation.element.getBoundingClientRect().width / scale;
|
||||
let annotationX
|
||||
if (!opts.align || opts.align === 'right') {
|
||||
annotationX = evt.node.w - 3 - badgeRDX - rect.width
|
||||
badgeRDX += rect.width + 4;
|
||||
annotationX = evt.node.w - 3 - badgeRDX - rectWidth
|
||||
badgeRDX += rectWidth + 4;
|
||||
|
||||
} else if (opts.align === 'left') {
|
||||
annotationX = 3 + badgeLDX
|
||||
badgeLDX += rect.width + 4;
|
||||
badgeLDX += rectWidth + 4;
|
||||
}
|
||||
annotation.element.setAttribute("transform", "translate("+annotationX+", -8)");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue