[api-minor] Change {PDFPageView, PDFThumbnailView}.update to take a parameter object

The old `update`-signature started to annoy me back when I added optional content support to the viewer, since we're (often) forced to pass in a bunch of arguments that we don't care about whenever these methods are called.

This is tagged `api-minor` since `PDFPageView` is being used in the `pageviewer` component example, and it's thus possible that these changes could affect some users; the next commit adds fallback handling for the old format.
This commit is contained in:
Jonas Jenwald 2021-08-31 17:08:43 +02:00
parent 258cf1decc
commit 7c81a8dd40
4 changed files with 17 additions and 15 deletions

View file

@ -405,9 +405,9 @@ class BaseViewer {
const pageNumber = this._currentPageNumber;
for (let i = 0, ii = this._pages.length; i < ii; i++) {
const pageView = this._pages[i];
pageView.update(pageView.scale, rotation);
const updateArgs = { rotation };
for (const pageView of this._pages) {
pageView.update(updateArgs);
}
// Prevent errors in case the rotation changes *before* the scale has been
// set to a non-default value.
@ -717,8 +717,9 @@ class BaseViewer {
}
this._doc.style.setProperty("--zoom-factor", newScale);
for (let i = 0, ii = this._pages.length; i < ii; i++) {
this._pages[i].update(newScale);
const updateArgs = { scale: newScale };
for (const pageView of this._pages) {
pageView.update(updateArgs);
}
this._currentScale = newScale;
@ -1435,8 +1436,9 @@ class BaseViewer {
}
this._optionalContentConfigPromise = promise;
const updateArgs = { optionalContentConfigPromise: promise };
for (const pageView of this._pages) {
pageView.update(pageView.scale, pageView.rotation, promise);
pageView.update(updateArgs);
}
this.update();