mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +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
|
@ -443,6 +443,10 @@ function normalizeWheelEventDelta(evt) {
|
|||
return delta;
|
||||
}
|
||||
|
||||
function isValidRotation(angle) {
|
||||
return Number.isInteger(angle) && angle % 90 === 0;
|
||||
}
|
||||
|
||||
function cloneObj(obj) {
|
||||
let result = Object.create(null);
|
||||
for (let i in obj) {
|
||||
|
@ -655,6 +659,7 @@ export {
|
|||
MAX_AUTO_SCALE,
|
||||
SCROLLBAR_PADDING,
|
||||
VERTICAL_PADDING,
|
||||
isValidRotation,
|
||||
cloneObj,
|
||||
RendererType,
|
||||
mozL10n,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue