fix outline may jump to previous page issue

This commit is contained in:
Xiliang Chen 2016-01-21 11:39:30 +13:00 committed by Jonas Jenwald
parent ca81f4df18
commit 6cb77d6580

View File

@ -627,7 +627,13 @@ var PDFViewer = (function pdfViewer() {
pageView.viewport.convertToViewportPoint(x + width, y + height)
];
var left = Math.min(boundingRect[0][0], boundingRect[1][0]);
var top = Math.min(boundingRect[0][1], boundingRect[1][1]);
// Some pdf generator will generate a large top value (e.g. 10000)
// for outline destination
// which exceeds the hight of the page
// Therefore we have to ensure top is not less 0
// otherwise viewer will scroll to previous page
// See PR 6903 and bug 874482 for more discussion
var top = Math.max(Math.min(boundingRect[0][1], boundingRect[1][1]), 0);
scrollIntoView(pageView.div, { left: left, top: top });
},