mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Replace onScrollModeChanged
and onSpreadModeChanged
with one function
Given that these event handlers are virtually identical, obviously with the exception of the name-parameter, let's reduce a little bit of code duplication.
This commit is contained in:
parent
22ec252193
commit
aae223f79b
1 changed files with 12 additions and 17 deletions
29
web/app.js
29
web/app.js
|
@ -1969,15 +1969,19 @@ const PDFViewerApplication = {
|
|||
eventBus._on("switchscrollmode", evt => (pdfViewer.scrollMode = evt.mode), {
|
||||
signal,
|
||||
});
|
||||
eventBus._on("scrollmodechanged", onScrollModeChanged.bind(this), {
|
||||
signal,
|
||||
});
|
||||
eventBus._on(
|
||||
"scrollmodechanged",
|
||||
onViewerModesChanged.bind(this, "scrollMode"),
|
||||
{ signal }
|
||||
);
|
||||
eventBus._on("switchspreadmode", evt => (pdfViewer.spreadMode = evt.mode), {
|
||||
signal,
|
||||
});
|
||||
eventBus._on("spreadmodechanged", onSpreadModeChanged.bind(this), {
|
||||
signal,
|
||||
});
|
||||
eventBus._on(
|
||||
"spreadmodechanged",
|
||||
onViewerModesChanged.bind(this, "spreadMode"),
|
||||
{ signal }
|
||||
);
|
||||
eventBus._on("imagealttextsettings", onImageAltTextSettings.bind(this), {
|
||||
signal,
|
||||
});
|
||||
|
@ -2402,19 +2406,10 @@ function onUpdateViewarea({ location }) {
|
|||
}
|
||||
}
|
||||
|
||||
function onScrollModeChanged(evt) {
|
||||
function onViewerModesChanged(name, evt) {
|
||||
if (this.isInitialViewSet && !this.pdfViewer.isInPresentationMode) {
|
||||
// Only update the storage when the document has been loaded *and* rendered.
|
||||
this.store?.set("scrollMode", evt.mode).catch(() => {
|
||||
// Unable to write to storage.
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onSpreadModeChanged(evt) {
|
||||
if (this.isInitialViewSet && !this.pdfViewer.isInPresentationMode) {
|
||||
// Only update the storage when the document has been loaded *and* rendered.
|
||||
this.store?.set("spreadMode", evt.mode).catch(() => {
|
||||
this.store?.set(name, evt.mode).catch(() => {
|
||||
// Unable to write to storage.
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue