mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Define a few editor event handler functions inline
Given that we're removing event listeners with `AbortSignal` it's no longer necessary to keep a reference to a few of the event handler functions in order to remove them. Hence we can simply inline the relevant `bind`-calls instead, which reduces the code-size a tiny bit.
This commit is contained in:
parent
829c9f553d
commit
0eac5e9d6f
2 changed files with 14 additions and 18 deletions
|
@ -53,8 +53,6 @@ class HighlightEditor extends AnnotationEditor {
|
||||||
|
|
||||||
#isFreeHighlight = false;
|
#isFreeHighlight = false;
|
||||||
|
|
||||||
#boundKeydown = this.#keydown.bind(this);
|
|
||||||
|
|
||||||
#lastPoint = null;
|
#lastPoint = null;
|
||||||
|
|
||||||
#opacity;
|
#opacity;
|
||||||
|
@ -568,7 +566,7 @@ class HighlightEditor extends AnnotationEditor {
|
||||||
if (this.#isFreeHighlight) {
|
if (this.#isFreeHighlight) {
|
||||||
div.classList.add("free");
|
div.classList.add("free");
|
||||||
} else {
|
} else {
|
||||||
this.div.addEventListener("keydown", this.#boundKeydown, {
|
this.div.addEventListener("keydown", this.#keydown.bind(this), {
|
||||||
signal: this._uiManager._signal,
|
signal: this._uiManager._signal,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -612,16 +612,6 @@ class AnnotationEditorUIManager {
|
||||||
|
|
||||||
#boundKeyup = this.keyup.bind(this);
|
#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 = {
|
#previousStates = {
|
||||||
isEditing: false,
|
isEditing: false,
|
||||||
isEmpty: true,
|
isEmpty: true,
|
||||||
|
@ -794,13 +784,21 @@ class AnnotationEditorUIManager {
|
||||||
this.#viewer = viewer;
|
this.#viewer = viewer;
|
||||||
this.#altTextManager = altTextManager;
|
this.#altTextManager = altTextManager;
|
||||||
this._eventBus = eventBus;
|
this._eventBus = eventBus;
|
||||||
this._eventBus._on("editingaction", this.#boundOnEditingAction, { signal });
|
this._eventBus._on("editingaction", this.onEditingAction.bind(this), {
|
||||||
this._eventBus._on("pagechanging", this.#boundOnPageChanging, { signal });
|
signal,
|
||||||
this._eventBus._on("scalechanging", this.#boundOnScaleChanging, { signal });
|
});
|
||||||
this._eventBus._on("rotationchanging", this.#boundOnRotationChanging, {
|
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,
|
signal,
|
||||||
});
|
});
|
||||||
this._eventBus._on("setpreference", this.#boundOnSetPreference, { signal });
|
|
||||||
this.#addSelectionListener();
|
this.#addSelectionListener();
|
||||||
this.#addDragAndDropListeners();
|
this.#addDragAndDropListeners();
|
||||||
this.#addKeyboardManager();
|
this.#addKeyboardManager();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue