Also update the browser history when the user *manually* change pages using the pageNumber-input (PR 12493 follow-up)

This patch addresses a review comment, which pointed out that we should *also* handle the pageNumber-input, from PR 12493.

Given that a user *manually* changing pages using the pageNumber-input, on the toolbar, could be regarded as a pretty strong indication of user-intent w.r.t. navigation in the document, hence I suppose that updating the browser history in this case as well probably won't hurt.
This commit is contained in:
Jonas Jenwald 2020-10-31 10:17:28 +01:00
parent 4eaa058c16
commit 911948c5c0
4 changed files with 27 additions and 10 deletions

View file

@ -787,6 +787,22 @@ class BaseViewer {
this._scrollIntoView({ pageDiv: pageView.div });
}
/**
* @param {string} label - The page label.
* @returns {number|null} The page number corresponding to the page label,
* or `null` when no page labels exist and/or the input is invalid.
*/
pageLabelToPageNumber(label) {
if (!this._pageLabels) {
return null;
}
const i = this._pageLabels.indexOf(label);
if (i < 0) {
return null;
}
return i + 1;
}
/**
* @typedef ScrollPageIntoViewParameters
* @property {number} pageNumber - The page number.