[Editor] Don't commit the current drawing while zooming

This commit is contained in:
Calixte Denizet 2024-12-09 17:25:36 +01:00
parent 99eefb7b71
commit 166a529ddd
2 changed files with 22 additions and 0 deletions

View File

@ -76,6 +76,8 @@ class AnnotationEditorLayer {
#drawingAC = null; #drawingAC = null;
#focusedElement = null;
#textLayer = null; #textLayer = null;
#textSelectionAC = null; #textSelectionAC = null;
@ -811,6 +813,7 @@ class AnnotationEditorLayer {
"blur", "blur",
({ relatedTarget }) => { ({ relatedTarget }) => {
if (relatedTarget && !this.div.contains(relatedTarget)) { if (relatedTarget && !this.div.contains(relatedTarget)) {
this.#focusedElement = null;
this.commitOrRemove(); this.commitOrRemove();
} }
}, },
@ -819,6 +822,22 @@ class AnnotationEditorLayer {
this.#currentEditorType.startDrawing(this, this.#uiManager, false, event); this.#currentEditorType.startDrawing(this, this.#uiManager, false, event);
} }
pause(on) {
if (on) {
const { activeElement } = document;
if (this.div.contains(activeElement)) {
this.#focusedElement = activeElement;
}
return;
}
if (this.#focusedElement) {
setTimeout(() => {
this.#focusedElement?.focus();
this.#focusedElement = null;
}, 0);
}
}
endDrawingSession(isAborted = false) { endDrawingSession(isAborted = false) {
if (!this.#drawingAC) { if (!this.#drawingAC) {
return null; return null;
@ -826,6 +845,7 @@ class AnnotationEditorLayer {
this.#uiManager.setCurrentDrawingSession(null); this.#uiManager.setCurrentDrawingSession(null);
this.#drawingAC.abort(); this.#drawingAC.abort();
this.#drawingAC = null; this.#drawingAC = null;
this.#focusedElement = null;
return this.#currentEditorType.endDrawing(isAborted); return this.#currentEditorType.endDrawing(isAborted);
} }

View File

@ -140,6 +140,7 @@ class AnnotationEditorLayerBuilder {
if (!this.div) { if (!this.div) {
return; return;
} }
this.annotationEditorLayer.pause(/* on */ true);
this.div.hidden = true; this.div.hidden = true;
} }
@ -148,6 +149,7 @@ class AnnotationEditorLayerBuilder {
return; return;
} }
this.div.hidden = false; this.div.hidden = false;
this.annotationEditorLayer.pause(/* on */ false);
} }
} }