From 798df873c4b1c3ecd42fad8e72e21ea7d7df863e Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 16 Mar 2023 10:35:04 +0000 Subject: [PATCH] Merge pull request #12200 from overleaf/ii-pdf-view-moves-to-the-left [web] Make pdf view consistent when recompiling GitOrigin-RevId: 1c76a1c8e0b8b024c7d0d033f92ff900e70909a6 --- .../js/features/pdf-preview/util/pdf-js-wrapper.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.js b/services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.js index 6ed84aa54f..5da610806d 100644 --- a/services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.js +++ b/services/web/frontend/js/features/pdf-preview/util/pdf-js-wrapper.js @@ -213,9 +213,13 @@ export default class PDFJSWrapper { destArray, }) - // scroll the page down by an extra few pixels to account for the pdf.js viewer page border + // scroll the page left and down by an extra few pixels to account for the pdf.js viewer page border + const pageIndex = this.viewer.currentPageNumber - 1 + const pageView = this.viewer.getPageView(pageIndex) + const offset = parseFloat(getComputedStyle(pageView.div).borderWidth) this.viewer.container.scrollBy({ - top: -9, + top: -offset, + left: -offset, }) }