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 badgeRDX = 0;
|
||||||
let badgeLDX = 0;
|
let badgeLDX = 0;
|
||||||
|
const scale = RED.view.scale()
|
||||||
for (let i=0,l=evt.el.__annotations__.length;i<l;i++) {
|
for (let i=0,l=evt.el.__annotations__.length;i<l;i++) {
|
||||||
const annotation = evt.el.__annotations__[i];
|
const annotation = evt.el.__annotations__[i];
|
||||||
if (annotations.hasOwnProperty(annotation.id)) {
|
if (annotations.hasOwnProperty(annotation.id)) {
|
||||||
|
@ -42,15 +42,17 @@ RED.view.annotations = (function() {
|
||||||
}
|
}
|
||||||
if (isBadge) {
|
if (isBadge) {
|
||||||
if (showAnnotation) {
|
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
|
let annotationX
|
||||||
if (!opts.align || opts.align === 'right') {
|
if (!opts.align || opts.align === 'right') {
|
||||||
annotationX = evt.node.w - 3 - badgeRDX - rect.width
|
annotationX = evt.node.w - 3 - badgeRDX - rectWidth
|
||||||
badgeRDX += rect.width + 4;
|
badgeRDX += rectWidth + 4;
|
||||||
|
|
||||||
} else if (opts.align === 'left') {
|
} else if (opts.align === 'left') {
|
||||||
annotationX = 3 + badgeLDX
|
annotationX = 3 + badgeLDX
|
||||||
badgeLDX += rect.width + 4;
|
badgeLDX += rectWidth + 4;
|
||||||
}
|
}
|
||||||
annotation.element.setAttribute("transform", "translate("+annotationX+", -8)");
|
annotation.element.setAttribute("transform", "translate("+annotationX+", -8)");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue