Skip to content

Use BaseViewer.previousPage more in the default viewer (PR 12870 follow-up) #14221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2413,28 +2413,29 @@ function webViewerSidebarViewChanged(evt) {
PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled =
PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;

const store = PDFViewerApplication.store;
if (store && PDFViewerApplication.isInitialViewSet) {
if (PDFViewerApplication.isInitialViewSet) {
// Only update the storage when the document has been loaded *and* rendered.
store.set("sidebarView", evt.view).catch(function () {});
PDFViewerApplication.store?.set("sidebarView", evt.view).catch(() => {
// Unable to write to storage.
});
}
}

function webViewerUpdateViewarea(evt) {
const location = evt.location,
store = PDFViewerApplication.store;
const location = evt.location;

if (store && PDFViewerApplication.isInitialViewSet) {
store
.setMultiple({
if (PDFViewerApplication.isInitialViewSet) {
// Only update the storage when the document has been loaded *and* rendered.
PDFViewerApplication.store
?.setMultiple({
page: location.pageNumber,
zoom: location.scale,
scrollLeft: location.left,
scrollTop: location.top,
rotation: location.rotation,
})
.catch(function () {
/* unable to write to storage */
.catch(() => {
// Unable to write to storage.
});
}
const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(
Expand All @@ -2453,18 +2454,20 @@ function webViewerUpdateViewarea(evt) {
}

function webViewerScrollModeChanged(evt) {
const store = PDFViewerApplication.store;
if (store && PDFViewerApplication.isInitialViewSet) {
if (PDFViewerApplication.isInitialViewSet) {
// Only update the storage when the document has been loaded *and* rendered.
store.set("scrollMode", evt.mode).catch(function () {});
PDFViewerApplication.store?.set("scrollMode", evt.mode).catch(() => {
// Unable to write to storage.
});
}
}

function webViewerSpreadModeChanged(evt) {
const store = PDFViewerApplication.store;
if (store && PDFViewerApplication.isInitialViewSet) {
if (PDFViewerApplication.isInitialViewSet) {
// Only update the storage when the document has been loaded *and* rendered.
store.set("spreadMode", evt.mode).catch(function () {});
PDFViewerApplication.store?.set("spreadMode", evt.mode).catch(() => {
// Unable to write to storage.
});
}
}

Expand Down Expand Up @@ -3057,9 +3060,8 @@ function webViewerKeyDown(evt) {
) {
break;
}
if (PDFViewerApplication.page > 1) {
PDFViewerApplication.page--;
}
pdfViewer.previousPage();

handled = true;
break;

Expand Down