[Editor] Avoid to resize and redraw the ink canvas when it's useless

- and because of rounding errors it led to slightly resize again and again
the ink container;
- when zooming the size is changing but not the ratio, so in this case we
don't need to change the dimension of the container.
This commit is contained in:
Calixte Denizet 2022-07-07 18:39:10 +02:00
parent 403ed07ad9
commit 9c4077ebc4

View File

@ -580,7 +580,10 @@ class InkEditor extends AnnotationEditor {
this.canvas.style.visibility = "hidden"; this.canvas.style.visibility = "hidden";
if (this.#aspectRatio) { if (
this.#aspectRatio &&
Math.abs(this.#aspectRatio - width / height) > 1e-2
) {
height = Math.ceil(width / this.#aspectRatio); height = Math.ceil(width / this.#aspectRatio);
this.setDims(width, height); this.setDims(width, height);
} }
@ -848,6 +851,9 @@ class InkEditor extends AnnotationEditor {
this.#setCanvasDims(); this.#setCanvasDims();
this.#redraw(); this.#redraw();
this.#realWidth = width;
this.#realHeight = height;
this.setDims(width, height); this.setDims(width, height);
this.translate( this.translate(
prevTranslationX - this.translationX, prevTranslationX - this.translationX,