Simplify resetting of the SecondaryToolbar
Scroll/Spread mode buttons, and add a missing comment in PDFCursorTools
The names 'resetscrollmode'/'resetspreadmode' were probably *not* great choices, given that the only thing being reset are toolbar buttons and not the actual Scroll/Spread modes. Furthermore, there's really no need for two separate events here. The patch also adds a comment that ought to have been included in PR 9040, to prevent future refactoring/removing of what may appear to be an unnecessary `Promise.resolve` call.
This commit is contained in:
parent
b39a2ba57a
commit
46e1d5daa4
@ -47,6 +47,8 @@ class PDFCursorTools {
|
||||
|
||||
this._addEventListeners();
|
||||
|
||||
// Defer the initial `switchTool` call, to give other viewer components
|
||||
// time to initialize *and* register 'cursortoolchanged' event listeners.
|
||||
Promise.resolve().then(() => {
|
||||
this.switchTool(cursorToolOnLoad);
|
||||
});
|
||||
|
@ -142,8 +142,7 @@ class SecondaryToolbar {
|
||||
this._updateUIState();
|
||||
|
||||
// Reset the Scroll/Spread buttons too, since they're document specific.
|
||||
this.eventBus.dispatch('resetscrollmode', { source: this, });
|
||||
this.eventBus.dispatch('resetspreadmode', { source: this, });
|
||||
this.eventBus.dispatch('secondarytoolbarreset', { source: this, });
|
||||
}
|
||||
|
||||
_updateUIState() {
|
||||
@ -212,7 +211,7 @@ class SecondaryToolbar {
|
||||
}
|
||||
this.eventBus.on('scrollmodechanged', scrollModeChanged);
|
||||
|
||||
this.eventBus.on('resetscrollmode', (evt) => {
|
||||
this.eventBus.on('secondarytoolbarreset', (evt) => {
|
||||
if (evt.source === this) {
|
||||
scrollModeChanged({ mode: ScrollMode.VERTICAL, });
|
||||
}
|
||||
@ -239,7 +238,7 @@ class SecondaryToolbar {
|
||||
}
|
||||
this.eventBus.on('spreadmodechanged', spreadModeChanged);
|
||||
|
||||
this.eventBus.on('resetspreadmode', (evt) => {
|
||||
this.eventBus.on('secondarytoolbarreset', (evt) => {
|
||||
if (evt.source === this) {
|
||||
spreadModeChanged({ mode: SpreadMode.NONE, });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user