Don't allow setting various properties, such as currentPageNumber/currentScale/currentScaleValue/pagesRotation, before {PDFViewer, PDFThumbnailViewer}.setDocument has been called

Currently a number of these properties do not work correctly if set *before* calling `setDocument`; please refer to the discussion starting in https://github.com/mozilla/pdf.js/pull/8539#issuecomment-309706629.

Rather than trying to have *some* of these methods working, but not others, it seems much more consistent to simply always require that `setDocument` has been called.
This commit is contained in:
Jonas Jenwald 2017-06-21 11:23:17 +02:00
parent 9bed695ebd
commit 735b58c3d5
2 changed files with 14 additions and 12 deletions

View file

@ -95,8 +95,15 @@ class PDFThumbnailViewer {
}
set pagesRotation(rotation) {
if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
throw new Error('Invalid thumbnails rotation angle.');
}
if (!this.pdfDocument) {
return;
}
this._pagesRotation = rotation;
for (let i = 0, l = this._thumbnails.length; i < l; i++) {
for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
this._thumbnails[i].update(rotation);
}
}