Merge pull request #13155 from Snuffleupagus/rotation-normalization
Move rotation normalization from `PDFViewerApplication` and into `BaseViewer`
This commit is contained in:
commit
34542d814f
@ -250,8 +250,11 @@ class PageViewport {
|
|||||||
const centerX = (viewBox[2] + viewBox[0]) / 2;
|
const centerX = (viewBox[2] + viewBox[0]) / 2;
|
||||||
const centerY = (viewBox[3] + viewBox[1]) / 2;
|
const centerY = (viewBox[3] + viewBox[1]) / 2;
|
||||||
let rotateA, rotateB, rotateC, rotateD;
|
let rotateA, rotateB, rotateC, rotateD;
|
||||||
rotation = rotation % 360;
|
// Normalize the rotation, by clamping it to the [0, 360) range.
|
||||||
rotation = rotation < 0 ? rotation + 360 : rotation;
|
rotation %= 360;
|
||||||
|
if (rotation < 0) {
|
||||||
|
rotation += 360;
|
||||||
|
}
|
||||||
switch (rotation) {
|
switch (rotation) {
|
||||||
case 180:
|
case 180:
|
||||||
rotateA = -1;
|
rotateA = -1;
|
||||||
|
@ -1856,11 +1856,7 @@ const PDFViewerApplication = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
rotatePages(delta) {
|
rotatePages(delta) {
|
||||||
if (!this.pdfDocument) {
|
this.pdfViewer.pagesRotation += delta;
|
||||||
return;
|
|
||||||
}
|
|
||||||
const newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
|
|
||||||
this.pdfViewer.pagesRotation = newRotation;
|
|
||||||
// Note that the thumbnail viewer is updated, and rendering is triggered,
|
// Note that the thumbnail viewer is updated, and rendering is triggered,
|
||||||
// in the 'rotationchanging' event handler.
|
// in the 'rotationchanging' event handler.
|
||||||
},
|
},
|
||||||
|
@ -388,6 +388,11 @@ class BaseViewer {
|
|||||||
if (!this.pdfDocument) {
|
if (!this.pdfDocument) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Normalize the rotation, by clamping it to the [0, 360) range.
|
||||||
|
rotation %= 360;
|
||||||
|
if (rotation < 0) {
|
||||||
|
rotation += 360;
|
||||||
|
}
|
||||||
if (this._pagesRotation === rotation) {
|
if (this._pagesRotation === rotation) {
|
||||||
return; // The rotation didn't change.
|
return; // The rotation didn't change.
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user