Remove one loop from BaseViewer.getPagesOverview
Currently, with `enablePrintAutoRotate = true` set, we're forced to loop through all the pages *twice* when checking for any landscape pages. This seems completely unnecessary now, and using only *one* loop should be marginally more efficient in general.
This commit is contained in:
parent
3ce94a9f6d
commit
1de466896d
@ -1347,25 +1347,21 @@ class BaseViewer {
|
||||
* @returns {Array} Array of objects with width/height/rotation fields.
|
||||
*/
|
||||
getPagesOverview() {
|
||||
const pagesOverview = this._pages.map(function (pageView) {
|
||||
return this._pages.map(pageView => {
|
||||
const viewport = pageView.pdfPage.getViewport({ scale: 1 });
|
||||
return {
|
||||
width: viewport.width,
|
||||
height: viewport.height,
|
||||
rotation: viewport.rotation,
|
||||
};
|
||||
});
|
||||
if (!this.enablePrintAutoRotate) {
|
||||
return pagesOverview;
|
||||
}
|
||||
return pagesOverview.map(function (size) {
|
||||
if (isPortraitOrientation(size)) {
|
||||
return size;
|
||||
|
||||
if (!this.enablePrintAutoRotate || isPortraitOrientation(viewport)) {
|
||||
return {
|
||||
width: viewport.width,
|
||||
height: viewport.height,
|
||||
rotation: viewport.rotation,
|
||||
};
|
||||
}
|
||||
// Landscape orientation.
|
||||
return {
|
||||
width: size.height,
|
||||
height: size.width,
|
||||
rotation: (size.rotation - 90) % 360,
|
||||
width: viewport.height,
|
||||
height: viewport.width,
|
||||
rotation: (viewport.rotation - 90) % 360,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user