mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[Editor] Use 2 decimals for editor positions and dimensions
I noticed that after adding an image in issue16278.pdf, the image was constantly resizing itself. It appears that it's because of rounding errors.
This commit is contained in:
parent
67e19171c4
commit
983b269e26
1 changed files with 6 additions and 4 deletions
|
@ -367,9 +367,9 @@ class AnnotationEditor {
|
|||
*/
|
||||
setDims(width, height) {
|
||||
const [parentWidth, parentHeight] = this.parentDimensions;
|
||||
this.div.style.width = `${(100 * width) / parentWidth}%`;
|
||||
this.div.style.width = `${((100 * width) / parentWidth).toFixed(2)}%`;
|
||||
if (!this.#keepAspectRatio) {
|
||||
this.div.style.height = `${(100 * height) / parentHeight}%`;
|
||||
this.div.style.height = `${((100 * height) / parentHeight).toFixed(2)}%`;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -384,10 +384,12 @@ class AnnotationEditor {
|
|||
|
||||
const [parentWidth, parentHeight] = this.parentDimensions;
|
||||
if (!widthPercent) {
|
||||
style.width = `${(100 * parseFloat(width)) / parentWidth}%`;
|
||||
style.width = `${((100 * parseFloat(width)) / parentWidth).toFixed(2)}%`;
|
||||
}
|
||||
if (!this.#keepAspectRatio && !heightPercent) {
|
||||
style.height = `${(100 * parseFloat(height)) / parentHeight}%`;
|
||||
style.height = `${((100 * parseFloat(height)) / parentHeight).toFixed(
|
||||
2
|
||||
)}%`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue