1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

[Editor] Fix the position in the page of a drawing after it has been moved with the keyboard

When a drawing was moved with arrow keys and then printed or saved, the drawing wasn't moved finally.
So the fix is just about calling onTranslated once the translation is done.
This commit is contained in:
Calixte Denizet 2025-02-22 15:19:10 +01:00
parent a648e1e769
commit 301f1bbf2b
6 changed files with 84 additions and 30 deletions

View file

@ -280,9 +280,9 @@ class DrawingEditor extends AnnotationEditor {
}
/** @inheritdoc */
_onTranslating(x, y) {
_onTranslating(_x, _y) {
this.parent?.drawLayer.updateProperties(this._drawId, {
bbox: this.#rotateBox(x, y),
bbox: this.#rotateBox(),
});
}

View file

@ -476,6 +476,10 @@ class AnnotationEditor {
this.div.scrollIntoView({ block: "nearest" });
}
translationDone() {
this._onTranslated(this.x, this.y);
}
drag(tx, ty) {
this.#initialRect ||= [this.x, this.y, this.width, this.height];
const {

View file

@ -2264,6 +2264,7 @@ class AnnotationEditorUIManager {
for (const editor of editors) {
if (this.#allEditors.has(editor.id)) {
editor.translateInPage(totalX, totalY);
editor.translationDone();
}
}
},
@ -2271,6 +2272,7 @@ class AnnotationEditorUIManager {
for (const editor of editors) {
if (this.#allEditors.has(editor.id)) {
editor.translateInPage(-totalX, -totalY);
editor.translationDone();
}
}
},
@ -2280,6 +2282,7 @@ class AnnotationEditorUIManager {
for (const editor of editors) {
editor.translateInPage(x, y);
editor.translationDone();
}
}