mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Fix beamer PDF preview scroll drift on recompile (#32077)
GitOrigin-RevId: 6f15671ba7f7944446e48136b775dea7e5c9b34a
This commit is contained in:
@@ -161,11 +161,23 @@ export default class PDFJSWrapper {
|
||||
|
||||
// get the current page, offset and page size
|
||||
get currentPosition() {
|
||||
const pageIndex = this.viewer.currentPageNumber - 1
|
||||
const containerRect = this.container.getBoundingClientRect()
|
||||
|
||||
let pageIndex = this.viewer.currentPageNumber - 1
|
||||
for (let i = pageIndex; i >= 0; i--) {
|
||||
const pageView = this.viewer.getPageView(i)
|
||||
if (!pageView?.div) continue
|
||||
const pageRect = pageView.div.getBoundingClientRect()
|
||||
if (pageRect.bottom < containerRect.top) {
|
||||
pageIndex = i + 1
|
||||
break
|
||||
}
|
||||
pageIndex = i
|
||||
}
|
||||
|
||||
const pageView = this.viewer.getPageView(pageIndex)
|
||||
const pageRect = pageView.div.getBoundingClientRect()
|
||||
|
||||
const containerRect = this.container.getBoundingClientRect()
|
||||
const dy = containerRect.top - pageRect.top
|
||||
const dx = containerRect.left - pageRect.left
|
||||
const [left, top] = pageView.viewport.convertToPdfPoint(dx, dy)
|
||||
|
||||
Reference in New Issue
Block a user