mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Compute the transformOrigin
correctly, for negative values, when rendering AnnotationElement
s (bug 1627030)
This changes the `transformOrigin` calculations in `AnnotationElement._createContainer` and `PopupAnnotationElement.render`, to ensure that e.g. the clickable area of annotations and/or popups are both positioned correctly. The problem occurs for *negative* values, since they're not negated correctly because of how the `transformOrigin` strings were build; see issue 12406 for a more in-depth explanation. Previously, for negative values, the `transformOrigin` strings would thus be ignored since they're not valid.
This commit is contained in:
parent
139c8a8cb5
commit
fca53a8eb0
3 changed files with 19 additions and 7 deletions
|
@ -177,7 +177,7 @@ class AnnotationElement {
|
|||
]);
|
||||
|
||||
container.style.transform = `matrix(${viewport.transform.join(",")})`;
|
||||
container.style.transformOrigin = `-${rect[0]}px -${rect[1]}px`;
|
||||
container.style.transformOrigin = `${-rect[0]}px ${-rect[1]}px`;
|
||||
|
||||
if (!ignoreBorder && data.borderStyle.width > 0) {
|
||||
container.style.borderWidth = `${data.borderStyle.width}px`;
|
||||
|
@ -763,12 +763,13 @@ class PopupAnnotationElement extends AnnotationElement {
|
|||
|
||||
// Position the popup next to the parent annotation's container.
|
||||
// PDF viewers ignore a popup annotation's rectangle.
|
||||
const parentLeft = parseFloat(parentElement.style.left);
|
||||
const parentWidth = parseFloat(parentElement.style.width);
|
||||
this.container.style.transformOrigin = `-${parentLeft + parentWidth}px -${
|
||||
parentElement.style.top
|
||||
}`;
|
||||
this.container.style.left = `${parentLeft + parentWidth}px`;
|
||||
const parentTop = parseFloat(parentElement.style.top),
|
||||
parentLeft = parseFloat(parentElement.style.left),
|
||||
parentWidth = parseFloat(parentElement.style.width);
|
||||
const popupLeft = parentLeft + parentWidth;
|
||||
|
||||
this.container.style.transformOrigin = `${-popupLeft}px ${-parentTop}px`;
|
||||
this.container.style.left = `${popupLeft}px`;
|
||||
|
||||
this.container.appendChild(popup.render());
|
||||
return this.container;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue