Move the reset-calls to occur last in the toolbar-constructors

By invoking the `reset` methods *last* in the `Toolbar`/`SecondaryToolbar`-constructors, we ensure that the "toolbarreset"/"secondarytoolbarreset"-events are actually handle when the viewer loads. Note that previously those events were dispatched *before* the relevant event-listeners had been attached.
With this small change we can avoid inconsistent initial toolbar-state, specifically in the case when the viewer is *reloaded* (since Firefox keeps the HTML-state on "soft" reloads).
This commit is contained in:
Jonas Jenwald 2022-08-09 21:33:18 +02:00
parent 2b0b8cd665
commit 047522a34a
2 changed files with 4 additions and 4 deletions

View File

@ -152,14 +152,14 @@ class SecondaryToolbar {
this.eventBus = eventBus;
this.opened = false;
this.reset();
// Bind the event listeners for click, cursor tool, and scroll/spread mode
// actions.
this.#bindClickListeners();
this.#bindCursorToolsListener(options);
this.#bindScrollModeListener(options);
this.#bindSpreadModeListener(options);
this.reset();
}
/**

View File

@ -111,10 +111,10 @@ class Toolbar {
editorInkParamsToolbar: options.editorInkParamsToolbar,
};
this.reset();
// Bind the event listeners for click and various other actions.
this.#bindListeners(options);
this.reset();
}
setPageNumber(pageNumber, pageLabel) {