mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-23 08:38:06 +02:00
Merge pull request #19144 from calixteman/no_focus_if_invisible
[Editor] Don't focus a newly added drawing if it isn't visible on screen
This commit is contained in:
commit
97c7a8eb7a
3 changed files with 66 additions and 1 deletions
|
@ -344,7 +344,9 @@ class DrawingEditor extends AnnotationEditor {
|
|||
this.#mustBeCommitted = false;
|
||||
this.commit();
|
||||
this.parent.setSelected(this);
|
||||
this.div.focus();
|
||||
if (this.isOnScreen) {
|
||||
this.div.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1402,6 +1402,12 @@ class AnnotationEditor {
|
|||
return this.div && !this.isAttachedToDOM;
|
||||
}
|
||||
|
||||
get isOnScreen() {
|
||||
const { top, left, bottom, right } = this.getClientDimensions();
|
||||
const { innerHeight, innerWidth } = window;
|
||||
return left < innerWidth && right > 0 && top < innerHeight && bottom > 0;
|
||||
}
|
||||
|
||||
#addFocusListeners() {
|
||||
if (this.#focusAC || !this.div) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue