mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Slightly refactor the pages rotation handling code in the viewer
This changes both `PDFViewer` and `PDFThumbnailViewer` to return early in the `pagesRotation` setters if the rotation doesn't change. It also fixes an existing issue, in `PDFViewer`, that would cause errors if the rotation changes *before* the scale has been set to a non-default value. Finally, in preparation for subsequent patches, it also refactors the rotation code in `web/app.js` to update the thumbnails and trigger rendering with the new `rotationchanging` event.
This commit is contained in:
parent
c8b5ba277a
commit
5565a6f8bf
5 changed files with 67 additions and 18 deletions
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
getVisibleElements, NullL10n, scrollIntoView, watchScroll
|
||||
getVisibleElements, isValidRotation, NullL10n, scrollIntoView, watchScroll
|
||||
} from './ui_utils';
|
||||
import { PDFThumbnailView } from './pdf_thumbnail_view';
|
||||
|
||||
|
@ -95,12 +95,15 @@ class PDFThumbnailViewer {
|
|||
}
|
||||
|
||||
set pagesRotation(rotation) {
|
||||
if (!(typeof rotation === 'number' && rotation % 90 === 0)) {
|
||||
if (!isValidRotation(rotation)) {
|
||||
throw new Error('Invalid thumbnails rotation angle.');
|
||||
}
|
||||
if (!this.pdfDocument) {
|
||||
return;
|
||||
}
|
||||
if (this._pagesRotation === rotation) {
|
||||
return; // The rotation didn't change.
|
||||
}
|
||||
this._pagesRotation = rotation;
|
||||
|
||||
for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue