Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor] Disable pointer events in the parent layer while an editor is resized #17045

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/display/editor/annotation_editor_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,16 @@ class AnnotationEditorLayer {
this.#uiManager.addCommands(params);
}

togglePointerEvents(enabled = false) {
this.div.classList.toggle("disabled", !enabled);
}

/**
* Enable pointer events on the main div in order to enable
* editor creation.
*/
enable() {
this.div.style.pointerEvents = "auto";
this.togglePointerEvents(true);
const annotationElementIds = new Set();
for (const editor of this.#editors.values()) {
editor.enableEditing();
Expand Down Expand Up @@ -235,7 +239,7 @@ class AnnotationEditorLayer {
*/
disable() {
this.#isDisabling = true;
this.div.style.pointerEvents = "none";
this.togglePointerEvents(false);
const hiddenAnnotationIds = new Set();
for (const editor of this.#editors.values()) {
editor.disableEditing();
Expand Down
2 changes: 2 additions & 0 deletions src/display/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ class AnnotationEditor {
const savedDraggable = this._isDraggable;
this._isDraggable = false;
const pointerMoveOptions = { passive: true, capture: true };
this.parent.togglePointerEvents(false);
window.addEventListener(
"pointermove",
boundResizerPointermove,
Expand All @@ -643,6 +644,7 @@ class AnnotationEditor {
window.getComputedStyle(event.target).cursor;

const pointerUpCallback = () => {
this.parent.togglePointerEvents(true);
this.#toggleAltTextButton(true);
this._isDraggable = savedDraggable;
window.removeEventListener("pointerup", pointerUpCallback);
Expand Down
4 changes: 4 additions & 0 deletions web/annotation_editor_layer_builder.css
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
height: 100%;
}

.annotationEditorLayer.disabled {
pointer-events: none;
}

.annotationEditorLayer.freetextEditing {
cursor: var(--editorFreeText-editing-cursor);
}
Expand Down