mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
[Editor] Slightly postpone the move in the DOM in order to not block the UI (bug 1854991)
This commit is contained in:
parent
57d196e349
commit
29bc103fad
1 changed files with 16 additions and 1 deletions
|
@ -59,6 +59,8 @@ class AnnotationEditor {
|
|||
|
||||
#isInEditMode = false;
|
||||
|
||||
#moveInDOMTimeout = null;
|
||||
|
||||
_initialOptions = Object.create(null);
|
||||
|
||||
_uiManager = null;
|
||||
|
@ -1046,7 +1048,16 @@ class AnnotationEditor {
|
|||
}
|
||||
|
||||
moveInDOM() {
|
||||
this.parent?.moveEditorInDOM(this);
|
||||
// Moving the editor in the DOM can be expensive, so we wait a bit before.
|
||||
// It's important to not block the UI (for example when changing the font
|
||||
// size in a FreeText).
|
||||
if (this.#moveInDOMTimeout) {
|
||||
clearTimeout(this.#moveInDOMTimeout);
|
||||
}
|
||||
this.#moveInDOMTimeout = setTimeout(() => {
|
||||
this.#moveInDOMTimeout = null;
|
||||
this.parent?.moveEditorInDOM(this);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
_setParentAndPosition(parent, x, y) {
|
||||
|
@ -1253,6 +1264,10 @@ class AnnotationEditor {
|
|||
this.#altTextButton?.remove();
|
||||
this.#altTextButton = null;
|
||||
this.#altTextTooltip = null;
|
||||
if (this.#moveInDOMTimeout) {
|
||||
clearTimeout(this.#moveInDOMTimeout);
|
||||
this.#moveInDOMTimeout = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue