[Editor] Move an editor in the DOM just after having moved it on the screen
It avoids to have to remember to call moveInDOM after fixAndSetPosition is called.
This commit is contained in:
parent
b1578225fc
commit
720963bbe6
@ -377,10 +377,8 @@ class AnnotationEditorLayer {
|
|||||||
editor.isAttachedToDOM = true;
|
editor.isAttachedToDOM = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The editor must have the right position before being moved in the DOM.
|
// The editor will be correctly moved into the DOM (see fixAndSetPosition).
|
||||||
editor.fixAndSetPosition();
|
editor.fixAndSetPosition();
|
||||||
this.moveEditorInDOM(editor);
|
|
||||||
|
|
||||||
editor.onceAdded();
|
editor.onceAdded();
|
||||||
this.#uiManager.addToAnnotationStorage(editor);
|
this.#uiManager.addToAnnotationStorage(editor);
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,6 @@ class AnnotationEditor {
|
|||||||
*/
|
*/
|
||||||
translateInPage(x, y) {
|
translateInPage(x, y) {
|
||||||
this.#translate(this.pageDimensions, x, y);
|
this.#translate(this.pageDimensions, x, y);
|
||||||
this.moveInDOM();
|
|
||||||
this.div.scrollIntoView({ block: "nearest" });
|
this.div.scrollIntoView({ block: "nearest" });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,11 +397,14 @@ class AnnotationEditor {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.x = x / pageWidth;
|
this.x = x /= pageWidth;
|
||||||
this.y = y / pageHeight;
|
this.y = y /= pageHeight;
|
||||||
|
|
||||||
this.div.style.left = `${(100 * this.x).toFixed(2)}%`;
|
const { style } = this.div;
|
||||||
this.div.style.top = `${(100 * this.y).toFixed(2)}%`;
|
style.left = `${(100 * x).toFixed(2)}%`;
|
||||||
|
style.top = `${(100 * y).toFixed(2)}%`;
|
||||||
|
|
||||||
|
this.moveInDOM();
|
||||||
}
|
}
|
||||||
|
|
||||||
static #rotatePoint(x, y, angle) {
|
static #rotatePoint(x, y, angle) {
|
||||||
@ -600,7 +602,6 @@ class AnnotationEditor {
|
|||||||
const [parentWidth, parentHeight] = this.parentDimensions;
|
const [parentWidth, parentHeight] = this.parentDimensions;
|
||||||
this.setDims(parentWidth * newWidth, parentHeight * newHeight);
|
this.setDims(parentWidth * newWidth, parentHeight * newHeight);
|
||||||
this.fixAndSetPosition();
|
this.fixAndSetPosition();
|
||||||
this.moveInDOM();
|
|
||||||
},
|
},
|
||||||
undo: () => {
|
undo: () => {
|
||||||
this.width = savedWidth;
|
this.width = savedWidth;
|
||||||
@ -610,7 +611,6 @@ class AnnotationEditor {
|
|||||||
const [parentWidth, parentHeight] = this.parentDimensions;
|
const [parentWidth, parentHeight] = this.parentDimensions;
|
||||||
this.setDims(parentWidth * savedWidth, parentHeight * savedHeight);
|
this.setDims(parentWidth * savedWidth, parentHeight * savedHeight);
|
||||||
this.fixAndSetPosition();
|
this.fixAndSetPosition();
|
||||||
this.moveInDOM();
|
|
||||||
},
|
},
|
||||||
mustExec: true,
|
mustExec: true,
|
||||||
});
|
});
|
||||||
@ -856,7 +856,7 @@ class AnnotationEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
moveInDOM() {
|
moveInDOM() {
|
||||||
this.parent.moveEditorInDOM(this);
|
this.parent?.moveEditorInDOM(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
_setParentAndPosition(parent, x, y) {
|
_setParentAndPosition(parent, x, y) {
|
||||||
@ -864,7 +864,6 @@ class AnnotationEditor {
|
|||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.fixAndSetPosition();
|
this.fixAndSetPosition();
|
||||||
this.moveInDOM();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user