Skip to content

Commit

Permalink
Merge pull request #18560 from Snuffleupagus/editor-bind-event-handlers
Browse files Browse the repository at this point in the history
Define a few editor event handler functions inline
  • Loading branch information
timvandermeij authored Aug 5, 2024
2 parents 7c89657 + 0eac5e9 commit 9ac05e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
4 changes: 1 addition & 3 deletions src/display/editor/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class HighlightEditor extends AnnotationEditor {

#isFreeHighlight = false;

#boundKeydown = this.#keydown.bind(this);

#lastPoint = null;

#opacity;
Expand Down Expand Up @@ -568,7 +566,7 @@ class HighlightEditor extends AnnotationEditor {
if (this.#isFreeHighlight) {
div.classList.add("free");
} else {
this.div.addEventListener("keydown", this.#boundKeydown, {
this.div.addEventListener("keydown", this.#keydown.bind(this), {
signal: this._uiManager._signal,
});
}
Expand Down
28 changes: 13 additions & 15 deletions src/display/editor/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,16 +612,6 @@ class AnnotationEditorUIManager {

#boundKeyup = this.keyup.bind(this);

#boundOnEditingAction = this.onEditingAction.bind(this);

#boundOnPageChanging = this.onPageChanging.bind(this);

#boundOnScaleChanging = this.onScaleChanging.bind(this);

#boundOnSetPreference = this.onSetPreference.bind(this);

#boundOnRotationChanging = this.onRotationChanging.bind(this);

#previousStates = {
isEditing: false,
isEmpty: true,
Expand Down Expand Up @@ -794,13 +784,21 @@ class AnnotationEditorUIManager {
this.#viewer = viewer;
this.#altTextManager = altTextManager;
this._eventBus = eventBus;
this._eventBus._on("editingaction", this.#boundOnEditingAction, { signal });
this._eventBus._on("pagechanging", this.#boundOnPageChanging, { signal });
this._eventBus._on("scalechanging", this.#boundOnScaleChanging, { signal });
this._eventBus._on("rotationchanging", this.#boundOnRotationChanging, {
this._eventBus._on("editingaction", this.onEditingAction.bind(this), {
signal,
});
this._eventBus._on("pagechanging", this.onPageChanging.bind(this), {
signal,
});
this._eventBus._on("scalechanging", this.onScaleChanging.bind(this), {
signal,
});
this._eventBus._on("rotationchanging", this.onRotationChanging.bind(this), {
signal,
});
this._eventBus._on("setpreference", this.onSetPreference.bind(this), {
signal,
});
this._eventBus._on("setpreference", this.#boundOnSetPreference, { signal });
this.#addSelectionListener();
this.#addDragAndDropListeners();
this.#addKeyboardManager();
Expand Down

0 comments on commit 9ac05e7

Please sign in to comment.