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:
Jonas Jenwald 2017-08-19 14:23:40 +02:00
parent c8b5ba277a
commit 5565a6f8bf
5 changed files with 67 additions and 18 deletions

View file

@ -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,