Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #5927 - Now remembers page rotation on reload #5949

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions web/pdf_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ var PDFViewer = (function pdfViewer() {
page.update(page.scale, rotation);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unrelated to the patch, please revert it.

this._setScale(this._currentScaleValue, true);
if (this._currentScale !== UNKNOWN_SCALE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

this._setScale(this._currentScaleValue, true);
}
},

/**
Expand Down Expand Up @@ -568,7 +570,8 @@ var PDFViewer = (function pdfViewer() {
scale: normalizedScaleValue,
top: intTop,
left: intLeft,
pdfOpenParams: pdfOpenParams
pdfOpenParams: pdfOpenParams,
rotation: this._pagesRotation
};
},

Expand Down
17 changes: 12 additions & 5 deletions web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,11 @@ var PDFViewerApplication = {
store.get('zoom', self.pdfViewer.currentScale);
var left = store.get('scrollLeft', '0');
var top = store.get('scrollTop', '0');
var rotation = store.get('rotation', '0') | 0;

if (rotation !== self.pageRotation) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code has changed here a bit. Instead of calling this here, let's pass the rotation as an argument into setInitialView and then have setInitialView call rotatePages

self.rotatePages(rotation, true);
}

storedHash = 'page=' + pageNum + '&zoom=' + zoom + ',' +
left + ',' + top;
Expand Down Expand Up @@ -1323,15 +1328,16 @@ var PDFViewerApplication = {
this.updateScaleControls = true;
},

rotatePages: function pdfViewRotatePages(delta) {
rotatePages: function pdfViewRotatePages(delta, noRendering) {
var pageNumber = this.page;
this.pageRotation = (this.pageRotation + 360 + delta) % 360;
this.pdfViewer.pagesRotation = this.pageRotation;
this.pdfThumbnailViewer.pagesRotation = this.pageRotation;

this.forceRendering();

this.pdfViewer.scrollPageIntoView(pageNumber);
if (!noRendering) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to avoid double negatives when possible. How about we make a setRotation(delta) function that only updates values and then change rotatePages to call setRotation and the code in this 'if' statement. Then in setInitialView you just have to call setRotation(...)

this.forceRendering();
this.pdfViewer.scrollPageIntoView(pageNumber);
}
},

/**
Expand Down Expand Up @@ -1786,7 +1792,8 @@ window.addEventListener('updateviewarea', function () {
'page': location.pageNumber,
'zoom': location.scale,
'scrollLeft': location.left,
'scrollTop': location.top
'scrollTop': location.top,
'rotation': location.rotation
}).catch(function() {
// unable to write to storage
});
Expand Down