From 3c7088dc44c504cad487631fd96ba9cc4fa4e23e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 27 Dec 2015 12:46:20 +0100 Subject: [PATCH] Do not modify `data.rect` in `AnnotationElement_createContainer`, since that will corrupt the annotation position on subsequent calls Fixes 6804; this regressed in PR 6714. --- src/display/annotation_layer.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index 9a1545d81..17cbb2a72 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -109,7 +109,9 @@ var AnnotationElement = (function AnnotationElementClosure() { container.setAttribute('data-annotation-id', data.id); - data.rect = Util.normalizeRect([ + // Do *not* modify `data.rect`, since that will corrupt the annotation + // position on subsequent calls to `_createContainer` (see issue 6804). + var rect = Util.normalizeRect([ data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], @@ -119,7 +121,7 @@ var AnnotationElement = (function AnnotationElementClosure() { CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')'); CustomStyle.setProp('transformOrigin', container, - -data.rect[0] + 'px ' + -data.rect[1] + 'px'); + -rect[0] + 'px ' + -rect[1] + 'px'); if (data.borderStyle.width > 0) { container.style.borderWidth = data.borderStyle.width + 'px'; @@ -174,8 +176,8 @@ var AnnotationElement = (function AnnotationElementClosure() { } } - container.style.left = data.rect[0] + 'px'; - container.style.top = data.rect[1] + 'px'; + container.style.left = rect[0] + 'px'; + container.style.top = rect[1] + 'px'; container.style.width = width + 'px'; container.style.height = height + 'px'; @@ -461,7 +463,7 @@ var PopupAnnotationElement = (function PopupAnnotationElementClosure() { /** * @class - * @alias PopupElement + * @alias PopupElement */ var PopupElement = (function PopupElementClosure() { var BACKGROUND_ENLIGHT = 0.7;